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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.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_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 {

Powered by Google App Engine
This is Rietveld 408576698