Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
index 6894654d3db4f62dc46c0b073ef27158e58e30a4..a27ed1b273a62782948e8e9bde72eb3a81779b82 100644 |
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
@@ -1545,6 +1545,13 @@ bool PepperPluginInstanceImpl::LoadTextInputInterface() { |
return !!plugin_textinput_interface_; |
} |
+void PepperPluginInstanceImpl::SetLayerTransform(gfx::Transform transform) { |
+ transform_ = transform; |
+ DCHECK(transform.IsScaleOrTranslation()); |
bokan
2016/04/14 21:45:01
Any reason this can't be an arbitrary transform? T
piman
2016/04/14 23:11:35
Actually, because it's used for the UVs, it can on
alessandroa
2016/04/21 15:39:22
Acknowledged.
|
+ |
+ UpdateLayerTransform(); |
+} |
+ |
void PepperPluginInstanceImpl::UpdateLayerTransform() { |
if (!bound_graphics_2d_platform_ || !texture_layer_) { |
// Currently the transform is only applied for Graphics2D. |
@@ -1564,11 +1571,24 @@ void PepperPluginInstanceImpl::UpdateLayerTransform() { |
gfx::Size plugin_size_in_dip(view_data_.rect.size.width, |
view_data_.rect.size.height); |
+ // Adding the SetLayerTransform from Graphics2D to the UV. |
+ // If the transform_ is the identity matrix |
+ // then UV will be top_left (0,0) and |
+ // lower_right (plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(), |
+ // plugin_size_in_dip.height() / graphics_2d_size_in_dip.height()) |
+ gfx::PointF translate = gfx::PointF(transform_.matrix().getFloat(0,3), |
+ transform_.matrix().getFloat(1,3)); |
+ float scale = transform_.matrix().getFloat(0,0); |
+ gfx::PointF top_left = |
+ gfx::PointF(-translate.x() / scale, -translate.y() / scale); |
+ gfx::PointF lower_right = gfx::PointF( |
+ (1 / scale) * plugin_size_in_dip.width() - translate.x() / scale, |
+ (1 / scale) * plugin_size_in_dip.height() - translate.y() / scale); |
texture_layer_->SetUV( |
- gfx::PointF(0.0f, 0.0f), |
- gfx::PointF( |
- plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(), |
- plugin_size_in_dip.height() / graphics_2d_size_in_dip.height())); |
+ gfx::PointF(top_left.x() / graphics_2d_size_in_dip.width(), |
+ top_left.y() / graphics_2d_size_in_dip.height()), |
+ gfx::PointF(lower_right.x() / graphics_2d_size_in_dip.width(), |
+ lower_right.y() / graphics_2d_size_in_dip.height())); |
} |
bool PepperPluginInstanceImpl::PluginHasFocus() const { |