| OLD | NEW |
| 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/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } else { | 777 } else { |
| 778 // Can't do optimized scrolling since there could be other elements on top | 778 // Can't do optimized scrolling since there could be other elements on top |
| 779 // of us or the view renders via the accelerated compositor which is | 779 // of us or the view renders via the accelerated compositor which is |
| 780 // incompatible with the move and backfill scrolling model. | 780 // incompatible with the move and backfill scrolling model. |
| 781 InvalidateRect(rect); | 781 InvalidateRect(rect); |
| 782 } | 782 } |
| 783 } | 783 } |
| 784 } | 784 } |
| 785 | 785 |
| 786 void PepperPluginInstanceImpl::CommitBackingTexture() { | 786 void PepperPluginInstanceImpl::CommitBackingTexture() { |
| 787 if (!texture_layer_.get()) | 787 if (!texture_layer_.get()) { |
| 788 UpdateLayer(true); |
| 788 return; | 789 return; |
| 790 } |
| 791 |
| 789 gpu::Mailbox mailbox; | 792 gpu::Mailbox mailbox; |
| 790 uint32_t sync_point = 0; | 793 gpu::SyncToken sync_token; |
| 791 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 794 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token); |
| 792 DCHECK(!mailbox.IsZero()); | 795 DCHECK(!mailbox.IsZero()); |
| 793 DCHECK_NE(sync_point, 0u); | 796 DCHECK(sync_token.HasData()); |
| 794 texture_layer_->SetTextureMailboxWithoutReleaseCallback( | 797 texture_layer_->SetTextureMailboxWithoutReleaseCallback( |
| 795 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), GL_TEXTURE_2D)); | 798 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D)); |
| 796 texture_layer_->SetNeedsDisplay(); | 799 texture_layer_->SetNeedsDisplay(); |
| 797 } | 800 } |
| 798 | 801 |
| 799 void PepperPluginInstanceImpl::InstanceCrashed() { | 802 void PepperPluginInstanceImpl::InstanceCrashed() { |
| 800 // Force free all resources and vars. | 803 // Force free all resources and vars. |
| 801 HostGlobals::Get()->InstanceCrashed(pp_instance()); | 804 HostGlobals::Get()->InstanceCrashed(pp_instance()); |
| 802 | 805 |
| 803 // Free any associated graphics. | 806 // Free any associated graphics. |
| 804 SetFullscreen(false); | 807 SetFullscreen(false); |
| 805 FlashSetFullscreen(false, false); | 808 FlashSetFullscreen(false, false); |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 printing::PdfMetafileSkia* metafile = | 1969 printing::PdfMetafileSkia* metafile = |
| 1967 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); | 1970 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
| 1968 if (metafile) | 1971 if (metafile) |
| 1969 return metafile->InitFromData(mapper.data(), mapper.size()); | 1972 return metafile->InitFromData(mapper.data(), mapper.size()); |
| 1970 | 1973 |
| 1971 NOTREACHED(); | 1974 NOTREACHED(); |
| 1972 #endif // ENABLE_PRINTING | 1975 #endif // ENABLE_PRINTING |
| 1973 return false; | 1976 return false; |
| 1974 } | 1977 } |
| 1975 | 1978 |
| 1976 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { | 1979 void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) { |
| 1977 if (!container_) | 1980 if (!container_) |
| 1978 return; | 1981 return; |
| 1979 | 1982 |
| 1980 gpu::Mailbox mailbox; | 1983 gpu::Mailbox mailbox; |
| 1981 uint32_t sync_point = 0; | 1984 gpu::SyncToken sync_token; |
| 1982 if (bound_graphics_3d_.get()) { | 1985 if (bound_graphics_3d_.get()) { |
| 1983 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 1986 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token); |
| 1984 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | |
| 1985 } | 1987 } |
| 1986 bool want_3d_layer = !mailbox.IsZero(); | 1988 bool want_3d_layer = !mailbox.IsZero() && sync_token.HasData(); |
| 1987 bool want_2d_layer = !!bound_graphics_2d_platform_; | 1989 bool want_2d_layer = !!bound_graphics_2d_platform_; |
| 1988 bool want_texture_layer = want_3d_layer || want_2d_layer; | 1990 bool want_texture_layer = want_3d_layer || want_2d_layer; |
| 1989 bool want_compositor_layer = !!bound_compositor_; | 1991 bool want_compositor_layer = !!bound_compositor_; |
| 1990 | 1992 |
| 1991 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { | 1993 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { |
| 1992 want_3d_layer = false; | 1994 want_3d_layer = false; |
| 1993 want_2d_layer = false; | 1995 want_2d_layer = false; |
| 1994 want_texture_layer = false; | 1996 want_texture_layer = false; |
| 1995 want_compositor_layer = false; | 1997 want_compositor_layer = false; |
| 1996 } | 1998 } |
| 1997 | 1999 |
| 1998 if (!device_changed && (want_texture_layer == !!texture_layer_.get()) && | 2000 if (!force_creation && (want_texture_layer == !!texture_layer_.get()) && |
| 1999 (want_3d_layer == layer_is_hardware_) && | 2001 (want_3d_layer == layer_is_hardware_) && |
| 2000 (want_compositor_layer == !!compositor_layer_.get()) && | 2002 (want_compositor_layer == !!compositor_layer_.get()) && |
| 2001 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 2003 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
| 2002 UpdateLayerTransform(); | 2004 UpdateLayerTransform(); |
| 2003 return; | 2005 return; |
| 2004 } | 2006 } |
| 2005 | 2007 |
| 2006 if (texture_layer_.get() || compositor_layer_.get()) { | 2008 if (texture_layer_.get() || compositor_layer_.get()) { |
| 2007 if (!layer_bound_to_fullscreen_) | 2009 if (!layer_bound_to_fullscreen_) |
| 2008 container_->setWebLayer(NULL); | 2010 container_->setWebLayer(NULL); |
| 2009 else if (fullscreen_container_) | 2011 else if (fullscreen_container_) |
| 2010 fullscreen_container_->SetLayer(NULL); | 2012 fullscreen_container_->SetLayer(NULL); |
| 2011 web_layer_.reset(); | 2013 web_layer_.reset(); |
| 2012 if (texture_layer_) { | 2014 if (texture_layer_) { |
| 2013 texture_layer_->ClearClient(); | 2015 texture_layer_->ClearClient(); |
| 2014 texture_layer_ = NULL; | 2016 texture_layer_ = NULL; |
| 2015 } | 2017 } |
| 2016 compositor_layer_ = NULL; | 2018 compositor_layer_ = NULL; |
| 2017 } | 2019 } |
| 2018 | 2020 |
| 2019 if (want_texture_layer) { | 2021 if (want_texture_layer) { |
| 2020 bool opaque = false; | 2022 bool opaque = false; |
| 2021 if (want_3d_layer) { | 2023 if (want_3d_layer) { |
| 2022 DCHECK(bound_graphics_3d_.get()); | 2024 DCHECK(bound_graphics_3d_.get()); |
| 2023 texture_layer_ = cc::TextureLayer::CreateForMailbox( | 2025 texture_layer_ = cc::TextureLayer::CreateForMailbox( |
| 2024 cc_blink::WebLayerImpl::LayerSettings(), NULL); | 2026 cc_blink::WebLayerImpl::LayerSettings(), NULL); |
| 2025 opaque = bound_graphics_3d_->IsOpaque(); | 2027 opaque = bound_graphics_3d_->IsOpaque(); |
| 2026 texture_layer_->SetTextureMailboxWithoutReleaseCallback( | 2028 texture_layer_->SetTextureMailboxWithoutReleaseCallback( |
| 2027 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), | 2029 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D)); |
| 2028 GL_TEXTURE_2D)); | |
| 2029 } else { | 2030 } else { |
| 2030 DCHECK(bound_graphics_2d_platform_); | 2031 DCHECK(bound_graphics_2d_platform_); |
| 2031 texture_layer_ = cc::TextureLayer::CreateForMailbox( | 2032 texture_layer_ = cc::TextureLayer::CreateForMailbox( |
| 2032 cc_blink::WebLayerImpl::LayerSettings(), this); | 2033 cc_blink::WebLayerImpl::LayerSettings(), this); |
| 2033 bound_graphics_2d_platform_->AttachedToNewLayer(); | 2034 bound_graphics_2d_platform_->AttachedToNewLayer(); |
| 2034 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); | 2035 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); |
| 2035 texture_layer_->SetFlipped(false); | 2036 texture_layer_->SetFlipped(false); |
| 2036 } | 2037 } |
| 2037 | 2038 |
| 2038 // Ignore transparency in fullscreen, since that's what Flash always | 2039 // Ignore transparency in fullscreen, since that's what Flash always |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3290 | 3291 |
| 3291 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3292 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
| 3292 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3293 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
| 3293 javascript_used_ = true; | 3294 javascript_used_ = true; |
| 3294 RenderThread::Get()->RecordAction( | 3295 RenderThread::Get()->RecordAction( |
| 3295 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3296 base::UserMetricsAction("Flash.JavaScriptUsed")); |
| 3296 } | 3297 } |
| 3297 } | 3298 } |
| 3298 | 3299 |
| 3299 } // namespace content | 3300 } // namespace content |
| OLD | NEW |