| 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..ee3223a838b7e50e32cc01692849d95de0daca9c 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()
|
| @@ -524,6 +529,28 @@ int32_t PepperGraphics2DHost::OnHostMsgSetScale(
|
| return PP_ERROR_BADARGUMENT;
|
| }
|
|
|
| +int32_t PepperGraphics2DHost::OnHostMsgSetLayerTransform(
|
| + ppapi::host::HostMessageContext* context,
|
| + float scale,
|
| + const PP_Point& origin,
|
| + const PP_Point& translation) {
|
| + if (scale < 0.0f)
|
| + return PP_ERROR_BADARGUMENT;
|
| +
|
| + gfx::Transform transform_matrix;
|
| + // Transform matrix contains the scale and translation applied
|
| + // with the origin the given point.
|
| + transform_matrix.Translate((1 - scale) * origin.x - translation.x,
|
| + (1 - scale) * origin.y - translation.y);
|
| + transform_matrix.Scale(scale, scale);
|
| +
|
| + 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 +617,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 +711,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,
|
|
|