Index: content/renderer/pepper/pepper_graphics_2d_host.cc |
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc |
index 5212bcef8707856599fa6210d12074583c130eff..a93c1ddb70110effaef35985be460d89fc5afdb0 100644 |
--- a/content/renderer/pepper/pepper_graphics_2d_host.cc |
+++ b/content/renderer/pepper/pepper_graphics_2d_host.cc |
@@ -130,7 +130,7 @@ void ConvertImageData(PPB_ImageData_Impl* src_image, |
} // namespace |
struct PepperGraphics2DHost::QueuedOperation { |
- enum Type { PAINT, SCROLL, REPLACE, }; |
+ enum Type { PAINT, SCROLL, REPLACE, TRANSFORM }; |
QueuedOperation(Type t) |
: type(t), paint_x(0), paint_y(0), scroll_dx(0), scroll_dy(0) {} |
@@ -148,6 +148,9 @@ struct PepperGraphics2DHost::QueuedOperation { |
// Valid when type == REPLACE. |
scoped_refptr<PPB_ImageData_Impl> replace_image; |
+ |
+ // Valid when type == TRANSFORM |
+ gfx::Transform transform; |
}; |
// static |
@@ -223,6 +226,8 @@ int32_t PepperGraphics2DHost::OnResourceMessageReceived( |
OnHostMsgFlush) |
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetScale, |
OnHostMsgSetScale) |
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetLayerTransform, |
+ OnHostMsgSetLayerTransform) |
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData, |
OnHostMsgReadImageData) |
PPAPI_END_MESSAGE_MAP() |
@@ -492,13 +497,11 @@ int32_t PepperGraphics2DHost::OnHostMsgFlush( |
// Don't allow more than one pending flush at a time. |
if (HasPendingFlush()) |
return PP_ERROR_INPROGRESS; |
wjmaclean
2016/04/13 14:47:18
Please restore the blank line below.
alessandroa
2016/04/21 15:39:20
Done.
|
- |
PP_Resource old_image_data = 0; |
flush_reply_context_ = context->MakeReplyMessageContext(); |
if (is_running_in_process_) |
return Flush(NULL); |
- // Reuse image data when running out of process. |
wjmaclean
2016/04/13 14:47:18
Why are you deleting this comment? Doesn't it appl
alessandroa
2016/04/21 15:39:20
It was a stupid mistake :) solved. I thought it wa
|
int32_t result = Flush(&old_image_data); |
if (old_image_data) { |
@@ -524,6 +527,29 @@ int32_t PepperGraphics2DHost::OnHostMsgSetScale( |
return PP_ERROR_BADARGUMENT; |
} |
+int32_t PepperGraphics2DHost::OnHostMsgSetLayerTransform( |
+ ppapi::host::HostMessageContext* context, |
wjmaclean
2016/04/13 14:47:18
indenting looks wrong here ... the arguments shoul
alessandroa
2016/04/21 15:39:20
Done.
|
+ float scale, |
+ const PP_Point& origin, |
+ const PP_Point& transform) { |
wjmaclean
2016/04/13 14:47:18
'transform' seems like the wrong name here ... is
alessandroa
2016/04/21 15:39:20
Done.
alessandroa
2016/04/21 15:39:20
Done.
|
+ TRACE_EVENT0("pepper", "PepperGraphics2DHost::OnHostMsgSetLayerTransform"); |
+ |
+ float S = scale; |
+ gfx::Point P(origin.x, origin.y); |
wjmaclean
2016/04/13 14:47:18
Call this 'origin' instead of 'P'
alessandroa
2016/04/21 15:39:20
Done.
|
+ gfx::Point T(transform.x, transform.y); |
wjmaclean
2016/04/13 14:47:18
Call this 'translation' instead of 'T'.
alessandroa
2016/04/21 15:39:20
Done.
|
+ gfx::Transform transform_matrix; |
+ |
+ transform_matrix.Translate(SkFloatToScalar((1 - S) * P.x() - T.x()), |
wjmaclean
2016/04/13 14:47:18
Perhaps add a comment explaining in words what the
alessandroa
2016/04/21 15:39:20
Done. I simplified all this part :) You will see i
|
+ SkFloatToScalar((1 - S) * P.y() - T.y())); |
wjmaclean
2016/04/13 14:47:18
this indentation is wrong
|
+ transform_matrix.Scale(S, S); |
+ |
+ QueuedOperation operation(QueuedOperation::TRANSFORM); |
+ operation.transform = transform_matrix; |
+ queued_operations_.push_back(operation); |
+ return PP_OK; |
+} |
+ |
+ |
int32_t PepperGraphics2DHost::OnHostMsgReadImageData( |
ppapi::host::HostMessageContext* context, |
PP_Resource image, |
@@ -590,10 +616,15 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { |
bool done_replace_contents = false; |
bool no_update_visible = true; |
bool is_plugin_visible = true; |
+ |
for (size_t i = 0; i < queued_operations_.size(); i++) { |
QueuedOperation& operation = queued_operations_[i]; |
gfx::Rect op_rect; |
switch (operation.type) { |
+ case QueuedOperation::TRANSFORM: |
+ ExecuteTransform(operation.transform); |
+ no_update_visible = false; |
+ break; |
case QueuedOperation::PAINT: |
ExecutePaintImageData(operation.paint_image.get(), |
operation.paint_x, |
@@ -679,6 +710,10 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) { |
return PP_OK_COMPLETIONPENDING; |
} |
+void PepperGraphics2DHost::ExecuteTransform(gfx::Transform transform) { |
+ bound_instance_->SetLayerTransform(transform); |
+} |
+ |
void PepperGraphics2DHost::ExecutePaintImageData(PPB_ImageData_Impl* image, |
int x, |
int y, |
@@ -707,7 +742,6 @@ void PepperGraphics2DHost::ExecutePaintImageData(PPB_ImageData_Impl* image, |
} else { |
// We're guaranteed to have a mapped canvas since we mapped it in Init(). |
SkCanvas* backing_canvas = image_data_->GetCanvas(); |
- |
wjmaclean
2016/04/13 14:47:18
please restore this blank line.
alessandroa
2016/04/21 15:39:20
Done.
|
// We want to replace the contents of the bitmap rather than blend. |
SkPaint paint; |
paint.setXfermodeMode(SkXfermode::kSrc_Mode); |