Skip to content

Instantly share code, notes, and snippets.

@x42
Created October 26, 2014 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x42/ef0b0f6e70d416b3af17 to your computer and use it in GitHub Desktop.
Save x42/ef0b0f6e70d416b3af17 to your computer and use it in GitHub Desktop.
Ardour3/Windows Gdk + Cairo performance hack -- http://gareus.org/wiki/ardour_windows_gdk_and_cairo
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc
index 133e094..cbedcd1 100644
--- a/libs/canvas/canvas.cc
+++ b/libs/canvas/canvas.cc
@@ -727,7 +727,10 @@ GtkCanvas::item_going_away (Item* item, boost::optional<Rect> bounding_box)
bool
GtkCanvas::on_expose_event (GdkEventExpose* ev)
{
+ static int on = 1;
Cairo::RefPtr<Cairo::Context> cairo_context = get_window()->create_cairo_context ();
+ cairo_surface_t *sf = cairo_context->get_group_target()->cobj();
+ cairo_surface_set_user_data(sf, (const cairo_user_data_key_t *) 0xb17b17, &on , NULL);
render (Rect (ev->area.x, ev->area.y, ev->area.x + ev->area.width, ev->area.y + ev->area.height), cairo_context);
return true;
}
diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc
index 3d28253..ed969ec 100644
--- a/libs/gtkmm2ext/fastmeter.cc
+++ b/libs/gtkmm2ext/fastmeter.cc
@@ -553,6 +553,9 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc)
void
FastMeter::render (cairo_t* cr, cairo_rectangle_t* area)
{
+ static int on = 1;
+ cairo_surface_t *sf = cairo_get_group_target(cr);
+ cairo_surface_set_user_data(sf, (const cairo_user_data_key_t *) 0xb17b17, &on , NULL);
if (orientation == Vertical) {
return vertical_expose (cr, area);
} else {
--- a/cairo-1.14.0/src/win32/cairo-win32-display-surface.c 2013-08-29 06:04:28.000000000 +0200
+++ c/cairo-1.14.0/src/win32/cairo-win32-display-surface.c 2014-10-26 20:24:56.412990453 +0100
@@ -455,23 +455,38 @@
surface->fallback =
_cairo_win32_display_surface_create_for_dc (surface->win32.dc,
surface->win32.format,
surface->win32.extents.width,
surface->win32.extents.height);
+
+#if 1 // XXX rg
+ fprintf(stderr, "NEW fallback surf %dx%d for surf=%d (%s)\n",
+ surface->win32.extents.width, surface->win32.extents.height,
+ surface->win32.base.unique_id,
+ cairo_surface_get_user_data(surface, (const cairo_user_data_key_t *)0xb17b17) ? "noblit" : "blit"
+ );
+#endif
+
if (unlikely (status = surface->fallback->status))
goto err;
+#if 1 // XXX rg
+ if (!cairo_surface_get_user_data(surface, (const cairo_user_data_key_t *)0xb17b17)) {
+#endif
if (!BitBlt (to_win32_surface(surface->fallback)->dc,
0, 0,
surface->win32.extents.width,
surface->win32.extents.height,
surface->win32.dc,
0, 0,
SRCCOPY)) {
status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
goto err;
}
+#if 1 // XXX rg
+ }
+#endif
}
surface = to_win32_display_surface (surface->fallback);
done:
GdiFlush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment