remove offscreen pixmap rendering design from CairoWidget: this helps only when widgets are partially re-exposed due to WM-level operations, which is relatively rare compared to the update frequency for various things that this widget will be used for. Plus, in GTK3, the need for this widget will mostly go away, and we'd like to be as close to the GTK3 model as possible
git-svn-id: svn://localhost/ardour2/branches/3.0@10317 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
743f0ea0ec
commit
b02ebd72a5
|
@ -25,7 +25,6 @@ CairoWidget::CairoWidget ()
|
|||
, _height (1)
|
||||
, _active_state (CairoWidget::ActiveState (0))
|
||||
, _visual_state (CairoWidget::VisualState (0))
|
||||
, _pixmap (0)
|
||||
, _dirty (true)
|
||||
{
|
||||
|
||||
|
@ -33,54 +32,16 @@ CairoWidget::CairoWidget ()
|
|||
|
||||
CairoWidget::~CairoWidget ()
|
||||
{
|
||||
if (_pixmap) {
|
||||
g_object_unref (_pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CairoWidget::on_expose_event (GdkEventExpose *event)
|
||||
CairoWidget::on_expose_event (GdkEventExpose *ev)
|
||||
{
|
||||
Gdk::Rectangle const exposure (
|
||||
event->area.x, event->area.y, event->area.width, event->area.height
|
||||
);
|
||||
|
||||
Gdk::Rectangle r = exposure;
|
||||
Gdk::Rectangle content (0, 0, _width, _height);
|
||||
bool intersects;
|
||||
r.intersect (content, intersects);
|
||||
|
||||
if (intersects) {
|
||||
|
||||
GdkDrawable* drawable = get_window()->gobj ();
|
||||
|
||||
if (_dirty) {
|
||||
|
||||
if (_pixmap) {
|
||||
g_object_unref (_pixmap);
|
||||
}
|
||||
|
||||
_pixmap = gdk_pixmap_new (drawable, _width, _height, -1);
|
||||
|
||||
cairo_t* cr = gdk_cairo_create (_pixmap);
|
||||
render (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
gdk_draw_drawable (
|
||||
drawable,
|
||||
get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
|
||||
_pixmap,
|
||||
r.get_x(),
|
||||
r.get_y(),
|
||||
r.get_x(),
|
||||
r.get_y(),
|
||||
r.get_width(),
|
||||
r.get_height()
|
||||
);
|
||||
}
|
||||
cairo_t* cr = gdk_cairo_create (get_window ()->gobj());
|
||||
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
||||
cairo_clip (cr);
|
||||
render (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -93,8 +54,6 @@ void
|
|||
CairoWidget::set_dirty ()
|
||||
{
|
||||
ENSURE_GUI_THREAD (*this, &CairoWidget::set_dirty)
|
||||
|
||||
_dirty = true;
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
|
||||
#include <gtkmm/eventbox.h>
|
||||
|
||||
/** A parent class for widgets that are made up of a pixmap rendered using Cairo.
|
||||
* The pixmap is painted to screen on GTK expose events, but the rendering
|
||||
* is only done after set_dirty() has been called.
|
||||
/** A parent class for widgets that are rendered using Cairo.
|
||||
*/
|
||||
|
||||
class CairoWidget : public Gtk::EventBox
|
||||
|
|
Loading…
Reference in New Issue
Block a user