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

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: Cleaned up the code 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..4d22edc155549e59eac0f701c1aff75b457a8e97 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());
+
+ UpdateLayerTransform();
+}
+
void PepperPluginInstanceImpl::UpdateLayerTransform() {
if (!bound_graphics_2d_platform_ || !texture_layer_) {
// Currently the transform is only applied for Graphics2D.
@@ -1564,11 +1571,26 @@ 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,
wjmaclean 2016/04/14 20:14:16 I hadn't realized this is the continuation of an e
alessandroa 2016/04/21 15:39:21 Acknowledged.
+ (1 / scale) * plugin_size_in_dip.height()
wjmaclean 2016/04/14 20:14:16 Why is this wrapping around? Is this line longer t
alessandroa 2016/04/21 15:39:21 Yep .. much longer but solved
+ -Translate.y() / scale);
texture_layer_->SetUV(
- gfx::PointF(0.0f, 0.0f),
+ gfx::PointF(top_left.x() / graphics_2d_size_in_dip.width(),
+ top_left.y() / graphics_2d_size_in_dip.height()),
gfx::PointF(
- plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(),
- plugin_size_in_dip.height() / graphics_2d_size_in_dip.height()));
+ 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