summaryrefslogtreecommitdiff
path: root/libs/canvas
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-17 16:54:16 +0100
committerRobin Gareus <robin@gareus.org>2017-03-17 16:54:16 +0100
commit7ab1becd43c38921f21d84a2f313e9895e0e72c6 (patch)
tree941cb0ab4f1da4e5ea6d3bdbc562895fba28a413 /libs/canvas
parent86ac64d5288baf2ad5d020b2b872598b7ee84d62 (diff)
Snow White and the Pharaoh (mac rendering)
Once upon a time there was a beautiful Apple tree in palace of GtkAnkhAmun in Cairo...
Diffstat (limited to 'libs/canvas')
-rw-r--r--libs/canvas/canvas.cc36
1 files changed, 34 insertions, 2 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc
index 97e001abba..a72700b94a 100644
--- a/libs/canvas/canvas.cc
+++ b/libs/canvas/canvas.cc
@@ -784,6 +784,10 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
return true;
}
+#ifdef CANVAS_PROFILE
+ const int64_t start = g_get_monotonic_time ();
+#endif
+
#ifdef OPTIONAL_CAIRO_IMAGE_SURFACE
Cairo::RefPtr<Cairo::Context> draw_context;
Cairo::RefPtr<Cairo::Context> window_context;
@@ -806,10 +810,27 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
Cairo::RefPtr<Cairo::Context> draw_context = get_window()->create_cairo_context ();
#endif
- /* draw background color */
+ draw_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+ draw_context->clip();
+#ifdef __APPLE__
+ /* group calls cairo_quartz_surface_create() which
+ * effectively uses a CGBitmapContext + image-surface
+ *
+ * This avoids expensive argb32_image_mark_image() during drawing.
+ * Although the final paint() operation still takes the slow path
+ * through image_mark_image instead of ColorMaskCopyARGB888_sse :(
+ *
+ * profiling indicates a speed up of factor 2. (~ 5-10ms render time,
+ * instead of 10-20ms, which is still slow compared to XCB and win32 surfaces (~0.2 ms)
+ *
+ * Fixing this for good likely involves changes to GdkQuartzWindow, GdkQuartzView
+ */
+ draw_context->push_group ();
+#endif
+
+ /* draw background color */
draw_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
- draw_context->clip_preserve ();
set_source_rgba (draw_context, _bg_color);
draw_context->fill ();
@@ -830,6 +851,11 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
g_free (rects);
}
+#ifdef __APPLE__
+ draw_context->pop_group_to_source ();
+ draw_context->paint ();
+#endif
+
#ifdef OPTIONAL_CAIRO_IMAGE_SURFACE
if (getenv("ARDOUR_IMAGE_SURFACE")) {
#endif
@@ -846,6 +872,12 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
}
#endif
+#ifdef CANVAS_PROFILE
+ const int64_t end = g_get_monotonic_time ();
+ const int64_t elapsed = end - start;
+ printf ("GtkCanvas::on_expose_event %f ms\n", elapsed / 1000.f);
+#endif
+
return true;
}