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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1586883002: Converted Ppapi post swap buffer sync point to use sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some .get() booleans Created 4 years, 11 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (!container_ || view_data_.rect.size.width == 0 || 746 if (!container_ || view_data_.rect.size.width == 0 ||
747 view_data_.rect.size.height == 0) 747 view_data_.rect.size.height == 0)
748 return; // Nothing to do. 748 return; // Nothing to do.
749 if (rect.IsEmpty()) 749 if (rect.IsEmpty())
750 container_->invalidate(); 750 container_->invalidate();
751 else 751 else
752 container_->invalidateRect(rect); 752 container_->invalidateRect(rect);
753 } 753 }
754 754
755 cc::Layer* layer = 755 cc::Layer* layer =
756 texture_layer_.get() ? texture_layer_.get() : compositor_layer_.get(); 756 texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
757 if (layer) { 757 if (layer) {
758 if (rect.IsEmpty()) { 758 if (rect.IsEmpty()) {
759 layer->SetNeedsDisplay(); 759 layer->SetNeedsDisplay();
760 } else { 760 } else {
761 layer->SetNeedsDisplayRect(rect); 761 layer->SetNeedsDisplayRect(rect);
762 } 762 }
763 } 763 }
764 } 764 }
765 765
766 void PepperPluginInstanceImpl::ScrollRect(int dx, 766 void PepperPluginInstanceImpl::ScrollRect(int dx,
767 int dy, 767 int dy,
768 const gfx::Rect& rect) { 768 const gfx::Rect& rect) {
769 cc::Layer* layer = 769 cc::Layer* layer =
770 texture_layer_.get() ? texture_layer_.get() : compositor_layer_.get(); 770 texture_layer_ ? texture_layer_.get() : compositor_layer_.get();
771 if (layer) { 771 if (layer) {
772 InvalidateRect(rect); 772 InvalidateRect(rect);
773 } else if (fullscreen_container_) { 773 } else if (fullscreen_container_) {
774 fullscreen_container_->ScrollRect(dx, dy, rect); 774 fullscreen_container_->ScrollRect(dx, dy, rect);
775 } else { 775 } else {
776 if (full_frame_ && !IsViewAccelerated()) { 776 if (full_frame_ && !IsViewAccelerated()) {
777 container_->scrollRect(rect); 777 container_->scrollRect(rect);
778 } else { 778 } else {
779 // Can't do optimized scrolling since there could be other elements on top 779 // Can't do optimized scrolling since there could be other elements on top
780 // of us or the view renders via the accelerated compositor which is 780 // of us or the view renders via the accelerated compositor which is
781 // incompatible with the move and backfill scrolling model. 781 // incompatible with the move and backfill scrolling model.
782 InvalidateRect(rect); 782 InvalidateRect(rect);
783 } 783 }
784 } 784 }
785 } 785 }
786 786
787 void PepperPluginInstanceImpl::CommitBackingTexture() { 787 void PepperPluginInstanceImpl::CommitBackingTexture() {
788 if (!texture_layer_.get()) 788 if (!texture_layer_) {
789 UpdateLayer(true);
789 return; 790 return;
791 }
792
790 gpu::Mailbox mailbox; 793 gpu::Mailbox mailbox;
791 uint32_t sync_point = 0; 794 gpu::SyncToken sync_token;
792 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); 795 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
793 DCHECK(!mailbox.IsZero()); 796 DCHECK(!mailbox.IsZero());
794 DCHECK_NE(sync_point, 0u); 797 DCHECK(sync_token.HasData());
795 texture_layer_->SetTextureMailboxWithoutReleaseCallback( 798 texture_layer_->SetTextureMailboxWithoutReleaseCallback(
796 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), GL_TEXTURE_2D)); 799 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D));
797 texture_layer_->SetNeedsDisplay(); 800 texture_layer_->SetNeedsDisplay();
798 } 801 }
799 802
800 void PepperPluginInstanceImpl::InstanceCrashed() { 803 void PepperPluginInstanceImpl::InstanceCrashed() {
801 // Force free all resources and vars. 804 // Force free all resources and vars.
802 HostGlobals::Get()->InstanceCrashed(pp_instance()); 805 HostGlobals::Get()->InstanceCrashed(pp_instance());
803 806
804 // Free any associated graphics. 807 // Free any associated graphics.
805 SetFullscreen(false); 808 SetFullscreen(false);
806 FlashSetFullscreen(false, false); 809 FlashSetFullscreen(false, false);
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 bool PepperPluginInstanceImpl::LoadTextInputInterface() { 1526 bool PepperPluginInstanceImpl::LoadTextInputInterface() {
1524 if (!plugin_textinput_interface_) { 1527 if (!plugin_textinput_interface_) {
1525 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( 1528 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>(
1526 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); 1529 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE));
1527 } 1530 }
1528 1531
1529 return !!plugin_textinput_interface_; 1532 return !!plugin_textinput_interface_;
1530 } 1533 }
1531 1534
1532 void PepperPluginInstanceImpl::UpdateLayerTransform() { 1535 void PepperPluginInstanceImpl::UpdateLayerTransform() {
1533 if (!bound_graphics_2d_platform_ || !texture_layer_.get()) { 1536 if (!bound_graphics_2d_platform_ || !texture_layer_) {
1534 // Currently the transform is only applied for Graphics2D. 1537 // Currently the transform is only applied for Graphics2D.
1535 return; 1538 return;
1536 } 1539 }
1537 // Set the UV coordinates of the texture based on the size of the Graphics2D 1540 // Set the UV coordinates of the texture based on the size of the Graphics2D
1538 // context. By default a texture gets scaled to the size of the layer. But 1541 // context. By default a texture gets scaled to the size of the layer. But
1539 // if the size of the Graphics2D context doesn't match the size of the plugin 1542 // if the size of the Graphics2D context doesn't match the size of the plugin
1540 // then it will be incorrectly stretched. This also affects how the plugin 1543 // then it will be incorrectly stretched. This also affects how the plugin
1541 // is painted when it is being resized. If the Graphics2D contents are 1544 // is painted when it is being resized. If the Graphics2D contents are
1542 // stretched when a plugin is resized while waiting for a new frame from the 1545 // stretched when a plugin is resized while waiting for a new frame from the
1543 // plugin to be rendered, then flickering behavior occurs as in 1546 // plugin to be rendered, then flickering behavior occurs as in
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 printing::PdfMetafileSkia* metafile = 1970 printing::PdfMetafileSkia* metafile =
1968 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); 1971 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
1969 if (metafile) 1972 if (metafile)
1970 return metafile->InitFromData(mapper.data(), mapper.size()); 1973 return metafile->InitFromData(mapper.data(), mapper.size());
1971 1974
1972 NOTREACHED(); 1975 NOTREACHED();
1973 #endif // ENABLE_PRINTING 1976 #endif // ENABLE_PRINTING
1974 return false; 1977 return false;
1975 } 1978 }
1976 1979
1977 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { 1980 void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
1978 if (!container_) 1981 if (!container_)
1979 return; 1982 return;
1980 1983
1981 gpu::Mailbox mailbox; 1984 gpu::Mailbox mailbox;
1982 uint32_t sync_point = 0; 1985 gpu::SyncToken sync_token;
1983 if (bound_graphics_3d_.get()) { 1986 if (bound_graphics_3d_.get()) {
1984 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); 1987 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
1985 DCHECK_EQ(mailbox.IsZero(), sync_point == 0);
1986 } 1988 }
1987 bool want_3d_layer = !mailbox.IsZero(); 1989 bool want_3d_layer = !mailbox.IsZero() && sync_token.HasData();
1988 bool want_2d_layer = !!bound_graphics_2d_platform_; 1990 bool want_2d_layer = !!bound_graphics_2d_platform_;
1989 bool want_texture_layer = want_3d_layer || want_2d_layer; 1991 bool want_texture_layer = want_3d_layer || want_2d_layer;
1990 bool want_compositor_layer = !!bound_compositor_; 1992 bool want_compositor_layer = !!bound_compositor_;
1991 1993
1992 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { 1994 if (throttler_ && throttler_->IsHiddenForPlaceholder()) {
1993 want_3d_layer = false; 1995 want_3d_layer = false;
1994 want_2d_layer = false; 1996 want_2d_layer = false;
1995 want_texture_layer = false; 1997 want_texture_layer = false;
1996 want_compositor_layer = false; 1998 want_compositor_layer = false;
1997 } 1999 }
1998 2000
1999 if (!device_changed && (want_texture_layer == !!texture_layer_.get()) && 2001 if (!force_creation && (want_texture_layer == !!texture_layer_) &&
2000 (want_3d_layer == layer_is_hardware_) && 2002 (want_3d_layer == layer_is_hardware_) &&
2001 (want_compositor_layer == !!compositor_layer_.get()) && 2003 (want_compositor_layer == !!compositor_layer_.get()) &&
2002 layer_bound_to_fullscreen_ == !!fullscreen_container_) { 2004 layer_bound_to_fullscreen_ == !!fullscreen_container_) {
2003 UpdateLayerTransform(); 2005 UpdateLayerTransform();
2004 return; 2006 return;
2005 } 2007 }
2006 2008
2007 if (texture_layer_.get() || compositor_layer_.get()) { 2009 if (texture_layer_ || compositor_layer_) {
2008 if (!layer_bound_to_fullscreen_) 2010 if (!layer_bound_to_fullscreen_)
2009 container_->setWebLayer(NULL); 2011 container_->setWebLayer(NULL);
2010 else if (fullscreen_container_) 2012 else if (fullscreen_container_)
2011 fullscreen_container_->SetLayer(NULL); 2013 fullscreen_container_->SetLayer(NULL);
2012 web_layer_.reset(); 2014 web_layer_.reset();
2013 if (texture_layer_) { 2015 if (texture_layer_) {
2014 texture_layer_->ClearClient(); 2016 texture_layer_->ClearClient();
2015 texture_layer_ = NULL; 2017 texture_layer_ = NULL;
2016 } 2018 }
2017 compositor_layer_ = NULL; 2019 compositor_layer_ = NULL;
2018 } 2020 }
2019 2021
2020 if (want_texture_layer) { 2022 if (want_texture_layer) {
2021 bool opaque = false; 2023 bool opaque = false;
2022 if (want_3d_layer) { 2024 if (want_3d_layer) {
2023 DCHECK(bound_graphics_3d_.get()); 2025 DCHECK(bound_graphics_3d_.get());
2024 texture_layer_ = cc::TextureLayer::CreateForMailbox( 2026 texture_layer_ = cc::TextureLayer::CreateForMailbox(
2025 cc_blink::WebLayerImpl::LayerSettings(), NULL); 2027 cc_blink::WebLayerImpl::LayerSettings(), NULL);
2026 opaque = bound_graphics_3d_->IsOpaque(); 2028 opaque = bound_graphics_3d_->IsOpaque();
2027 texture_layer_->SetTextureMailboxWithoutReleaseCallback( 2029 texture_layer_->SetTextureMailboxWithoutReleaseCallback(
2028 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), 2030 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D));
2029 GL_TEXTURE_2D));
2030 } else { 2031 } else {
2031 DCHECK(bound_graphics_2d_platform_); 2032 DCHECK(bound_graphics_2d_platform_);
2032 texture_layer_ = cc::TextureLayer::CreateForMailbox( 2033 texture_layer_ = cc::TextureLayer::CreateForMailbox(
2033 cc_blink::WebLayerImpl::LayerSettings(), this); 2034 cc_blink::WebLayerImpl::LayerSettings(), this);
2034 bound_graphics_2d_platform_->AttachedToNewLayer(); 2035 bound_graphics_2d_platform_->AttachedToNewLayer();
2035 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); 2036 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque();
2036 texture_layer_->SetFlipped(false); 2037 texture_layer_->SetFlipped(false);
2037 } 2038 }
2038 2039
2039 // Ignore transparency in fullscreen, since that's what Flash always 2040 // Ignore transparency in fullscreen, since that's what Flash always
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 3292
3292 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { 3293 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() {
3293 if (initialized_ && !javascript_used_ && is_flash_plugin_) { 3294 if (initialized_ && !javascript_used_ && is_flash_plugin_) {
3294 javascript_used_ = true; 3295 javascript_used_ = true;
3295 RenderThread::Get()->RecordAction( 3296 RenderThread::Get()->RecordAction(
3296 base::UserMetricsAction("Flash.JavaScriptUsed")); 3297 base::UserMetricsAction("Flash.JavaScriptUsed"));
3297 } 3298 }
3298 } 3299 }
3299 3300
3300 } // namespace content 3301 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/ppb_graphics_3d_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698