mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 13:45:43 +01:00
Revert to use an image surface for CairoWidgets
This partially reverts2edbda2526and is a follow up to0b266a54f, to fix performance issues with MS Windows graphics performance.
This commit is contained in:
parent
c59c46a70a
commit
563a8b15e0
2 changed files with 35 additions and 13 deletions
|
|
@ -58,9 +58,9 @@ CairoWidget::CairoWidget ()
|
|||
{
|
||||
_name_proxy.connect (sigc::mem_fun (*this, &CairoWidget::on_name_changed));
|
||||
#ifdef USE_CAIRO_IMAGE_SURFACE
|
||||
_use_intermediate_surface = true;
|
||||
_use_image_surface = true;
|
||||
#else
|
||||
_use_intermediate_surface = NULL != getenv("ARDOUR_IMAGE_SURFACE");
|
||||
_use_image_surface = NULL != getenv("ARDOUR_IMAGE_SURFACE");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,8 @@ CairoWidget::set_canvas_widget ()
|
|||
ensure_style ();
|
||||
gtk_widget_set_realized (GTK_WIDGET(gobj()), true);
|
||||
_canvas_widget = true;
|
||||
_use_intermediate_surface = false;
|
||||
_use_image_surface = false;
|
||||
image_surface.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -97,9 +98,13 @@ CairoWidget::use_nsglview ()
|
|||
}
|
||||
|
||||
void
|
||||
CairoWidget::use_intermediate_surface (bool yn)
|
||||
CairoWidget::use_image_surface (bool yn)
|
||||
{
|
||||
_use_intermediate_surface = yn;
|
||||
if (_use_image_surface == yn) {
|
||||
return;
|
||||
}
|
||||
image_surface.clear ();
|
||||
_use_image_surface = yn;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -158,9 +163,14 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
|
|||
return true;
|
||||
}
|
||||
#endif
|
||||
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context ();
|
||||
if (_use_intermediate_surface) {
|
||||
cr->push_group ();
|
||||
Cairo::RefPtr<Cairo::Context> cr;
|
||||
if (_use_image_surface) {
|
||||
if (!image_surface) {
|
||||
image_surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, get_width(), get_height());
|
||||
}
|
||||
cr = Cairo::Context::create (image_surface);
|
||||
} else {
|
||||
cr = get_window()->create_cairo_context ();
|
||||
}
|
||||
|
||||
cr->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
||||
|
|
@ -188,9 +198,15 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
|
|||
|
||||
render (cr, &expose_area);
|
||||
|
||||
if (_use_intermediate_surface) {
|
||||
cr->pop_group_to_source ();
|
||||
cr->paint ();
|
||||
if (_use_image_surface) {
|
||||
image_surface->flush();
|
||||
/* now blit our private surface back to the GDK one */
|
||||
Cairo::RefPtr<Cairo::Context> window_context = get_window()->create_cairo_context ();
|
||||
window_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
||||
window_context->clip ();
|
||||
window_context->set_source (image_surface, 0, 0);
|
||||
window_context->set_operator (Cairo::OPERATOR_SOURCE);
|
||||
window_context->paint ();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -245,6 +261,11 @@ CairoWidget::on_size_allocate (Gtk::Allocation& alloc)
|
|||
memcpy (&_allocation, &alloc, sizeof(Gtk::Allocation));
|
||||
}
|
||||
|
||||
if (_use_image_surface) {
|
||||
image_surface.clear ();
|
||||
image_surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, alloc.get_width(), alloc.get_height());
|
||||
}
|
||||
|
||||
if (_canvas_widget) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue