diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 18:33:24 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 18:33:24 +0000 |
commit | ceb36f7d5cec71407b265aba887cd64216d24731 (patch) | |
tree | ea977c72eb7882c1629a5c78f56b1a9e7e3e6b60 /webkit/plugins/ppapi | |
parent | 80211f670f34191d80b875086aaf7b5b06a743d4 (diff) | |
download | chromium_src-ceb36f7d5cec71407b265aba887cd64216d24731.zip chromium_src-ceb36f7d5cec71407b265aba887cd64216d24731.tar.gz chromium_src-ceb36f7d5cec71407b265aba887cd64216d24731.tar.bz2 |
Add Vector2d classes that represent offsets, instead of using Point.
Previously Point served two purposes, to be a position in 2d space, and also
an offset from the origin. This introduces a Vector2d class to represent an
offset, allowing typesafety checks for geometric operations.
The following are now the case:
Point +/- Vector = Point
- A point plus/minus an offset gives you a point at a position offset by the
vector.
Vector +/- Vector = Vector
- Two offsets can be added together to make a new offset.
Point - Point = Vector
- Subtracting one point from another gives you the offset between the two
points.
We add some new methods to perform these operations:
Rect::OffsetFromOrigin() gives the offset between the position of the rect
and the origin.
Point::OffsetFromOrigin() gives the offset between the point and the origin.
PointAtOffsetFromOrigin(Vector2d) converts a Vector2d to a Point at the given
offset away from the origin.
Rect::Offset(), Point::Add(), and Point::Subtract() now receive a Vector2d
instead of a point.
BUG=147395
R=sky
Review URL: https://codereview.chromium.org/11269022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 3 |
2 files changed, 5 insertions, 5 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index c0c6c78..57e157f 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -1167,9 +1167,10 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint( return false; gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); + gfx::Vector2d plugin_offset = plugin_origin.OffsetFromOrigin(); // Convert |paint_bounds| to be relative to the left-top corner of the plugin. gfx::Rect relative_paint_bounds(paint_bounds); - relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y()); + relative_paint_bounds.Offset(-plugin_offset); gfx::Rect pixel_plugin_backing_store_rect( 0, 0, image_data->width(), image_data->height()); @@ -1192,9 +1193,9 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint( } *dib = image_data->PlatformImage()->GetTransportDIB(); - plugin_backing_store_rect.Offset(plugin_origin); + plugin_backing_store_rect.Offset(plugin_offset); *location = plugin_backing_store_rect; - clip_page.Offset(plugin_origin); + clip_page.Offset(plugin_offset); *clip = clip_page; // The plugin scale factor is inverted, e.g. for a device scale factor of 2x // the plugin scale factor is 0.5. diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index aaad035..c7013d2 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -705,8 +705,7 @@ void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image, void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip, int dx, int dy, gfx::Rect* invalidated_rect) { - gfx::ScrollCanvas(image_data_->GetCanvas(), - clip, gfx::Point(dx, dy)); + gfx::ScrollCanvas(image_data_->GetCanvas(), clip, gfx::Vector2d(dx, dy)); *invalidated_rect = clip; } |