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

Unified Diff: content/renderer/pepper/pepper_graphics_2d_host.cc

Issue 1881603002: Added SetLayerTransform to PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indentation Created 4 years, 8 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
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,

Powered by Google App Engine
This is Rietveld 408576698