summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-12-26 23:55:44 +0100
committerRobin Gareus <robin@gareus.org>2019-12-27 19:35:02 +0100
commit2edbda252619b6906e463c07ba2ea57422ccfa70 (patch)
treec62866e755f02906b149cb8f44b2beb4f65a6e79 /libs/gtkmm2ext
parentc3ab63a2eadece16ab5b5494d5815c147c6bd146 (diff)
Replace explicit image-surface with cairo pattern/group
For MacOS/X this is equivalent, rendering happens using a CGBitmapContext + image-surface. Windows and Linux needs profiling for respective equivalent surfaces.
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/cairo_widget.cc43
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/cairo_widget.h5
2 files changed, 13 insertions, 35 deletions
diff --git a/libs/gtkmm2ext/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc
index b06e443ec0..bbc4452238 100644
--- a/libs/gtkmm2ext/cairo_widget.cc
+++ b/libs/gtkmm2ext/cairo_widget.cc
@@ -58,9 +58,9 @@ CairoWidget::CairoWidget ()
{
_name_proxy.connect (sigc::mem_fun (*this, &CairoWidget::on_name_changed));
#ifdef USE_CAIRO_IMAGE_SURFACE
- _use_image_surface = true;
+ _use_intermediate_surface = true;
#else
- _use_image_surface = NULL != getenv("ARDOUR_IMAGE_SURFACE");
+ _use_intermediate_surface = NULL != getenv("ARDOUR_IMAGE_SURFACE");
#endif
}
@@ -82,8 +82,7 @@ CairoWidget::set_canvas_widget ()
ensure_style ();
gtk_widget_set_realized (GTK_WIDGET(gobj()), true);
_canvas_widget = true;
- _use_image_surface = false;
- image_surface.clear ();
+ _use_intermediate_surface = false;
}
void
@@ -98,13 +97,9 @@ CairoWidget::use_nsglview ()
}
void
-CairoWidget::use_image_surface (bool yn)
+CairoWidget::use_intermediate_surface (bool yn)
{
- if (_use_image_surface == yn) {
- return;
- }
- image_surface.clear ();
- _use_image_surface = yn;
+ _use_intermediate_surface = yn;
}
int
@@ -163,14 +158,9 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
return true;
}
#endif
- 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 ();
+ Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context ();
+ if (_use_intermediate_surface) {
+ cr->push_group ();
}
cr->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
@@ -198,15 +188,9 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
render (cr, &expose_area);
- 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 ();
+ if (_use_intermediate_surface) {
+ cr->pop_group_to_source ();
+ cr->paint ();
}
return true;
@@ -261,11 +245,6 @@ 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;
}
diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h
index 0dbd8fe8a0..7c7456eaa3 100644
--- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h
+++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h
@@ -40,7 +40,7 @@ public:
void set_canvas_widget ();
void use_nsglview ();
- void use_image_surface (bool yn = true);
+ void use_intermediate_surface (bool yn = true);
/* swizzle Gtk::Widget methods for Canvas::Widget */
void queue_draw ();
@@ -143,13 +143,12 @@ protected:
static sigc::slot<void,Gtk::Widget*> focus_handler;
private:
- Cairo::RefPtr<Cairo::Surface> image_surface;
Glib::SignalProxyProperty _name_proxy;
sigc::connection _parent_style_change;
Widget * _current_parent;
bool _canvas_widget;
void* _nsglview;
- bool _use_image_surface;
+ bool _use_intermediate_surface;
Gdk::Rectangle _allocation;
};