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 79821bb55a0b06764cdc9dafe0eb6aced70006ef..35263083263728dabf56874abec883387fce1ee3 100644 |
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc |
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc |
@@ -350,22 +350,44 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback) { |
// calls, leaving our callback stranded. So we still need to check whether |
// the repainted area is visible to determine how to deal with the callback. |
if (bound_instance_ && !op_rect.IsEmpty()) { |
+ // Convert op_rect from context coordinates to logical pixels, taking care |
brettw
2012/07/17 19:27:50
This seems kind of complicated. Can you separate t
Josh Horwich
2012/07/17 22:53:36
Done.
|
+ // to include partially-covered logical pixels (aka DIPs) |
+ gfx::Rect scaled_op_rect = op_rect; |
+ bool scroll_use_invalidate = false; |
+ int scaled_dx = operation.scroll_dx; |
+ int scaled_dy = operation.scroll_dy; |
+ if (scale_ != 1.0f && scale_ > 0.0f) { |
+ scaled_op_rect.ScaleBounds(scale_); |
+ if (operation.type == QueuedOperation::SCROLL) { |
+ // For scrolling, we need to ensure that the entire area can be |
+ // properly scrolled without including pixels outside of the requested |
+ // scroll. We do this by reversing the scale and making sure the |
+ // affected dimensions are exactly the original - the loss of |
+ // fractional precision in intermediate calculations is intentional. |
+ gfx::Rect unscaled_op_rect = scaled_op_rect; |
+ unscaled_op_rect.ScaleBounds(1.0f / scale_); |
+ scaled_dx = static_cast<int>(scaled_dx * scale_); |
+ scaled_dy = static_cast<int>(scaled_dy * scale_); |
+ if (unscaled_op_rect != op_rect || |
+ static_cast<int>(scaled_dx / scale_) != operation.scroll_dx || |
+ static_cast<int>(scaled_dy / scale_) != operation.scroll_dy) |
+ scroll_use_invalidate = true; |
+ } |
+ } |
// Set |nothing_visible| to false if the change overlaps the visible area. |
gfx::Rect visible_changed_rect = |
PP_ToGfxRect(bound_instance_->view_data().clip_rect). |
- Intersect(op_rect); |
+ Intersect(scaled_op_rect); |
if (!visible_changed_rect.IsEmpty()) |
nothing_visible = false; |
- // Notify the plugin of the entire change (op_rect), even if it is |
+ // Notify the plugin of the entire change (scaled_op_rect), even if it is |
// partially or completely off-screen. |
- if (operation.type == QueuedOperation::SCROLL) { |
- bound_instance_->ScrollRect(operation.scroll_dx, operation.scroll_dy, |
- op_rect); |
- } else { |
- bound_instance_->InvalidateRect(op_rect); |
- } |
+ if (operation.type == QueuedOperation::SCROLL && !scroll_use_invalidate) |
+ bound_instance_->ScrollRect(scaled_dx, scaled_dy, scaled_op_rect); |
+ else |
+ bound_instance_->InvalidateRect(scaled_op_rect); |
} |
} |
queued_operations_.clear(); |
@@ -524,6 +546,10 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, |
CGContextClipToRect(canvas, bounds); |
+ // TODO(jhorwich) Figure out if this code is even active anymore, and if so |
+ // how to properly handle scaling. |
+ DCHECK_EQ(1.0f, scale_); |
+ |
// TODO(brettw) bug 56673: do a direct memcpy instead of going through CG |
// if the is_always_opaque_ flag is set. Must ensure bitmap is still clipped. |