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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bit_cast.h" 10 #include "base/bit_cast.h"
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 1538
1539 bool PepperPluginInstanceImpl::LoadTextInputInterface() { 1539 bool PepperPluginInstanceImpl::LoadTextInputInterface() {
1540 if (!plugin_textinput_interface_) { 1540 if (!plugin_textinput_interface_) {
1541 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( 1541 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>(
1542 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); 1542 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE));
1543 } 1543 }
1544 1544
1545 return !!plugin_textinput_interface_; 1545 return !!plugin_textinput_interface_;
1546 } 1546 }
1547 1547
1548 void PepperPluginInstanceImpl::SetLayerTransform(gfx::Transform transform) {
1549 transform_ = transform;
1550 UpdateLayerTransform();
1551 }
1552
1548 void PepperPluginInstanceImpl::UpdateLayerTransform() { 1553 void PepperPluginInstanceImpl::UpdateLayerTransform() {
1549 if (!bound_graphics_2d_platform_ || !texture_layer_) { 1554 if (!bound_graphics_2d_platform_ || !texture_layer_) {
1550 // Currently the transform is only applied for Graphics2D. 1555 // Currently the transform is only applied for Graphics2D.
1551 return; 1556 return;
1552 } 1557 }
1553 // Set the UV coordinates of the texture based on the size of the Graphics2D 1558 // Set the UV coordinates of the texture based on the size of the Graphics2D
1554 // context. By default a texture gets scaled to the size of the layer. But 1559 // context. By default a texture gets scaled to the size of the layer. But
1555 // if the size of the Graphics2D context doesn't match the size of the plugin 1560 // if the size of the Graphics2D context doesn't match the size of the plugin
1556 // then it will be incorrectly stretched. This also affects how the plugin 1561 // then it will be incorrectly stretched. This also affects how the plugin
1557 // is painted when it is being resized. If the Graphics2D contents are 1562 // is painted when it is being resized. If the Graphics2D contents are
1558 // stretched when a plugin is resized while waiting for a new frame from the 1563 // stretched when a plugin is resized while waiting for a new frame from the
1559 // plugin to be rendered, then flickering behavior occurs as in 1564 // plugin to be rendered, then flickering behavior occurs as in
1560 // crbug.com/353453. 1565 // crbug.com/353453.
1561 gfx::SizeF graphics_2d_size_in_dip = 1566 gfx::SizeF graphics_2d_size_in_dip =
1562 gfx::ScaleSize(gfx::SizeF(bound_graphics_2d_platform_->Size()), 1567 gfx::ScaleSize(gfx::SizeF(bound_graphics_2d_platform_->Size()),
1563 bound_graphics_2d_platform_->GetScale()); 1568 bound_graphics_2d_platform_->GetScale());
1564 gfx::Size plugin_size_in_dip(view_data_.rect.size.width, 1569 gfx::Size plugin_size_in_dip(view_data_.rect.size.width,
1565 view_data_.rect.size.height); 1570 view_data_.rect.size.height);
1566 1571
1572 // Adding the SetLayerTransform from Graphics2D to the UV.
1573 // If the transform_ is te identity matrix
wjmaclean 2016/04/13 14:47:19 the
alessandroa 2016/04/21 15:39:21 Done.
1574 // then UV will be top_left (0,0) and
1575 // lower_right (plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(),
1576 // plugin_size_in_dip.height() / graphics_2d_size_in_dip.height())
1577 gfx::PointF Translate = gfx::PointF(transform_.matrix().getFloat(0,3),
wjmaclean 2016/04/13 14:47:19 Add a comment to warn the reader here that we're a
alessandroa 2016/04/21 15:39:21 Nice one :)
1578 transform_.matrix().getFloat(1,3));
1579 float scale = transform_.matrix().getFloat(0,0);
1580 gfx::PointF top_left = gfx::PointF(-1 * Translate.x() / scale ,
wjmaclean 2016/04/13 14:47:18 -Translate.x() ?
alessandroa 2016/04/21 15:39:21 Done.
1581 -1 * Translate.y() / scale);
1582 gfx::PointF lower_right = gfx::PointF((1 / scale) * plugin_size_in_dip.width()
1583 - 1 * Translate.x() / scale,
wjmaclean 2016/04/13 14:47:18 Ditto. Also, even if you are using -1, you shouldn
alessandroa 2016/04/21 15:39:21 Acknowledged.
1584 (1 / scale) * plugin_size_in_dip.height()
1585 - 1 * Translate.y() / scale);
1567 texture_layer_->SetUV( 1586 texture_layer_->SetUV(
1568 gfx::PointF(0.0f, 0.0f), 1587 gfx::PointF(top_left.x() / graphics_2d_size_in_dip.width(),
1588 top_left.y() / graphics_2d_size_in_dip.height()),
1569 gfx::PointF( 1589 gfx::PointF(
1570 plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(), 1590 lower_right.x() / graphics_2d_size_in_dip.width(),
1571 plugin_size_in_dip.height() / graphics_2d_size_in_dip.height())); 1591 lower_right.y() / graphics_2d_size_in_dip.height()));
1572 } 1592 }
1573 1593
1574 bool PepperPluginInstanceImpl::PluginHasFocus() const { 1594 bool PepperPluginInstanceImpl::PluginHasFocus() const {
1575 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); 1595 return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_);
1576 } 1596 }
1577 1597
1578 void PepperPluginInstanceImpl::SendFocusChangeNotification() { 1598 void PepperPluginInstanceImpl::SendFocusChangeNotification() {
1579 // Keep a reference on the stack. RenderViewImpl::PepperFocusChanged may 1599 // Keep a reference on the stack. RenderViewImpl::PepperFocusChanged may
1580 // remove the <embed> from the DOM, which will make the PepperWebPluginImpl 1600 // remove the <embed> from the DOM, which will make the PepperWebPluginImpl
1581 // drop its reference, usually the last one. This is similar to possible 1601 // drop its reference, usually the last one. This is similar to possible
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 } 3344 }
3325 3345
3326 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { 3346 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const {
3327 rect->set_x(rect->x() / viewport_to_dip_scale_); 3347 rect->set_x(rect->x() / viewport_to_dip_scale_);
3328 rect->set_y(rect->y() / viewport_to_dip_scale_); 3348 rect->set_y(rect->y() / viewport_to_dip_scale_);
3329 rect->set_width(rect->width() / viewport_to_dip_scale_); 3349 rect->set_width(rect->width() / viewport_to_dip_scale_);
3330 rect->set_height(rect->height() / viewport_to_dip_scale_); 3350 rect->set_height(rect->height() / viewport_to_dip_scale_);
3331 } 3351 }
3332 3352
3333 } // namespace content 3353 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698