Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | webkit/plugins/webview_plugin.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 923b88d4af73f2d488f800ba278162d082ba5df5..aaad035722715397e93259c93bf5d643a9168c3a 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -376,8 +376,7 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback,
// Set |no_update_visible| to false if the change overlaps the visible
// area.
- gfx::Rect visible_changed_rect = clip;
- visible_changed_rect.Intersect(op_rect);
+ gfx::Rect visible_changed_rect = gfx::IntersectRects(clip, op_rect);
if (!visible_changed_rect.IsEmpty())
no_update_visible = false;
@@ -561,8 +560,7 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
CGContextDrawImage(canvas, bitmap_rect, image);
#else
- gfx::Rect invalidate_rect = plugin_rect;
- invalidate_rect.Intersect(paint_rect);
+ gfx::Rect invalidate_rect = gfx::IntersectRects(plugin_rect, paint_rect);
SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect);
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->clipRect(sk_invalidate_rect);
@@ -649,20 +647,20 @@ bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale,
// Take the enclosing rectangle after scaling so a rectangle scaled down then
// scaled back up by the inverse scale would fully contain the entire area
// affected by the original rectangle.
- gfx::RectF scaled_rect = *op_rect;
- scaled_rect.Scale(scale);
- *op_rect = gfx::ToEnclosingRect(scaled_rect);
+ *op_rect = gfx::ToEnclosingRect(gfx::ScaleRect(*op_rect, scale));
if (delta) {
gfx::Point original_delta = *delta;
float inverse_scale = 1.0f / scale;
*delta = gfx::ToFlooredPoint(delta->Scale(scale));
- gfx::RectF inverse_scaled_rect = *op_rect;
- inverse_scaled_rect.Scale(inverse_scale);
- if (original_rect != gfx::ToEnclosingRect(inverse_scaled_rect) ||
- original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) {
+ gfx::Rect inverse_scaled_rect =
+ gfx::ToEnclosingRect(gfx::ScaleRect(*op_rect, inverse_scale));
+ if (original_rect != inverse_scaled_rect)
+ return false;
+ gfx::Point inverse_scaled_point =
+ gfx::ToFlooredPoint(delta->Scale(inverse_scale));
+ if (original_delta != inverse_scaled_point)
return false;
- }
}
return true;
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | webkit/plugins/webview_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698