diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 15:44:27 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-05 15:44:27 +0000 |
commit | 0bdc754eb5c321040a93258632db3d8f618e4d57 (patch) | |
tree | 646e9c7fb232bba842262fbebeb755577ef1fbc4 /skia | |
parent | 742d4d048e70431a7294594a42133d2f79b15138 (diff) | |
download | chromium_src-0bdc754eb5c321040a93258632db3d8f618e4d57.zip chromium_src-0bdc754eb5c321040a93258632db3d8f618e4d57.tar.gz chromium_src-0bdc754eb5c321040a93258632db3d8f618e4d57.tar.bz2 |
Makes canvas_paint_linux use the event region, not the event
rectangle. This is needed as gtk/gdk may set complex clips, so that if
we paint everything we can end up painting on top of other widgets.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/242134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/canvas_paint_linux.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/skia/ext/canvas_paint_linux.h b/skia/ext/canvas_paint_linux.h index 0f03603..26e8113 100644 --- a/skia/ext/canvas_paint_linux.h +++ b/skia/ext/canvas_paint_linux.h @@ -23,7 +23,7 @@ class CanvasPaintT : public T { explicit CanvasPaintT(GdkEventExpose* event) : context_(NULL), window_(event->window), - rectangle_(event->area), + region_(gdk_region_copy(event->region)), composite_alpha_(false) { init(true); } @@ -31,7 +31,7 @@ class CanvasPaintT : public T { CanvasPaintT(GdkEventExpose* event, bool opaque) : context_(NULL), window_(event->window), - rectangle_(event->area), + region_(gdk_region_copy(event->region)), composite_alpha_(false) { init(opaque); } @@ -45,12 +45,14 @@ class CanvasPaintT : public T { if (composite_alpha_) cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_surface_t* source_surface = cairo_get_target(context_); - cairo_set_source_surface(cr, source_surface, rectangle_.x, rectangle_.y); - cairo_rectangle(cr, rectangle_.x, rectangle_.y, - rectangle_.width, rectangle_.height); + GdkRectangle bounds = rectangle(); + cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y); + gdk_cairo_region(cr, region_); cairo_fill(cr); cairo_destroy(cr); } + + gdk_region_destroy(region_); } // Sets whether the bitmap is composited in such a way that the alpha channel @@ -63,30 +65,33 @@ class CanvasPaintT : public T { // Returns true if the invalid region is empty. The caller should call this // function to determine if anything needs painting. bool is_empty() const { - return rectangle_.width == 0 || rectangle_.height == 0; + return gdk_region_empty(region_); } - const GdkRectangle& rectangle() const { - return rectangle_; + GdkRectangle rectangle() const { + GdkRectangle bounds; + gdk_region_get_clipbox(region_, &bounds); + return bounds; } private: void init(bool opaque) { - if (!T::initialize(rectangle_.width, rectangle_.height, opaque, NULL)) { + GdkRectangle bounds = rectangle(); + if (!T::initialize(bounds.width, bounds.height, opaque, NULL)) { // Cause a deliberate crash; *(char*) 0 = 0; } // Need to translate so that the dirty region appears at the origin of the // surface. - T::translate(-SkIntToScalar(rectangle_.x), -SkIntToScalar(rectangle_.y)); + T::translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y)); context_ = T::getTopPlatformDevice().beginPlatformPaint(); } cairo_t* context_; GdkWindow* window_; - GdkRectangle rectangle_; + GdkRegion* region_; // See description above setter. bool composite_alpha_; |