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

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

Issue 1912833002: Pepper takes ownership of a mailbox before passing it to the texture layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 7 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } 780 }
781 } 781 }
782 } 782 }
783 783
784 void PepperPluginInstanceImpl::CommitBackingTexture() { 784 void PepperPluginInstanceImpl::CommitBackingTexture() {
785 if (!texture_layer_) { 785 if (!texture_layer_) {
786 UpdateLayer(true); 786 UpdateLayer(true);
787 return; 787 return;
788 } 788 }
789 789
790 gpu::Mailbox mailbox; 790 PassTextureFromGraphics3DToTextureLayer();
791 gpu::SyncToken sync_token;
792 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
793 DCHECK(!mailbox.IsZero());
794 DCHECK(sync_token.HasData());
795 texture_layer_->SetTextureMailboxWithoutReleaseCallback(
796 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D));
797 texture_layer_->SetNeedsDisplay(); 791 texture_layer_->SetNeedsDisplay();
798 } 792 }
799 793
794 void PepperPluginInstanceImpl::PassTextureFromGraphics3DToTextureLayer() {
795 DCHECK(bound_graphics_3d_);
796
797 gpu::Mailbox mailbox;
798 gpu::SyncToken sync_token;
799 bound_graphics_3d_->TakeBackingMailbox(&mailbox, &sync_token);
800 DCHECK(!mailbox.IsZero());
801 DCHECK(sync_token.HasData());
802
803 cc::TextureMailbox texture_mailbox(mailbox, sync_token, GL_TEXTURE_2D);
804 std::unique_ptr<cc::SingleReleaseCallback> callback(
805 cc::SingleReleaseCallback::Create(
806 base::Bind(&PPB_Graphics3D_Impl::ReturnBackingMailbox,
807 bound_graphics_3d_, mailbox)));
808
809 texture_layer_->SetTextureMailbox(texture_mailbox, std::move(callback));
810 }
811
800 void PepperPluginInstanceImpl::InstanceCrashed() { 812 void PepperPluginInstanceImpl::InstanceCrashed() {
801 // Force free all resources and vars. 813 // Force free all resources and vars.
802 HostGlobals::Get()->InstanceCrashed(pp_instance()); 814 HostGlobals::Get()->InstanceCrashed(pp_instance());
803 815
804 // Free any associated graphics. 816 // Free any associated graphics.
805 SetFullscreen(false); 817 SetFullscreen(false);
806 FlashSetFullscreen(false, false); 818 FlashSetFullscreen(false, false);
807 // Unbind current 2D or 3D graphics context. 819 // Unbind current 2D or 3D graphics context.
808 BindGraphics(pp_instance(), 0); 820 BindGraphics(pp_instance(), 0);
809 InvalidateRect(gfx::Rect()); 821 InvalidateRect(gfx::Rect());
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 2022
2011 NOTREACHED(); 2023 NOTREACHED();
2012 #endif // ENABLE_PRINTING 2024 #endif // ENABLE_PRINTING
2013 return false; 2025 return false;
2014 } 2026 }
2015 2027
2016 void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) { 2028 void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
2017 if (!container_) 2029 if (!container_)
2018 return; 2030 return;
2019 2031
2020 gpu::Mailbox mailbox; 2032 bool want_3d_layer = !!bound_graphics_3d_.get();
2021 gpu::SyncToken sync_token;
2022 if (bound_graphics_3d_.get()) {
2023 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
2024 }
2025 bool want_3d_layer = !mailbox.IsZero() && sync_token.HasData();
2026 bool want_2d_layer = !!bound_graphics_2d_platform_; 2033 bool want_2d_layer = !!bound_graphics_2d_platform_;
2027 bool want_texture_layer = want_3d_layer || want_2d_layer; 2034 bool want_texture_layer = want_3d_layer || want_2d_layer;
2028 bool want_compositor_layer = !!bound_compositor_; 2035 bool want_compositor_layer = !!bound_compositor_;
2029 2036
2030 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { 2037 if (throttler_ && throttler_->IsHiddenForPlaceholder()) {
2031 want_3d_layer = false; 2038 want_3d_layer = false;
2032 want_2d_layer = false; 2039 want_2d_layer = false;
2033 want_texture_layer = false; 2040 want_texture_layer = false;
2034 want_compositor_layer = false; 2041 want_compositor_layer = false;
2035 } 2042 }
(...skipping 18 matching lines...) Expand all
2054 } 2061 }
2055 compositor_layer_ = NULL; 2062 compositor_layer_ = NULL;
2056 } 2063 }
2057 2064
2058 if (want_texture_layer) { 2065 if (want_texture_layer) {
2059 bool opaque = false; 2066 bool opaque = false;
2060 if (want_3d_layer) { 2067 if (want_3d_layer) {
2061 DCHECK(bound_graphics_3d_.get()); 2068 DCHECK(bound_graphics_3d_.get());
2062 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); 2069 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL);
2063 opaque = bound_graphics_3d_->IsOpaque(); 2070 opaque = bound_graphics_3d_->IsOpaque();
2064 texture_layer_->SetTextureMailboxWithoutReleaseCallback( 2071
2065 cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D)); 2072 PassTextureFromGraphics3DToTextureLayer();
2066 } else { 2073 } else {
2067 DCHECK(bound_graphics_2d_platform_); 2074 DCHECK(bound_graphics_2d_platform_);
2068 texture_layer_ = cc::TextureLayer::CreateForMailbox(this); 2075 texture_layer_ = cc::TextureLayer::CreateForMailbox(this);
2069 bound_graphics_2d_platform_->AttachedToNewLayer(); 2076 bound_graphics_2d_platform_->AttachedToNewLayer();
2070 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque(); 2077 opaque = bound_graphics_2d_platform_->IsAlwaysOpaque();
2071 texture_layer_->SetFlipped(false); 2078 texture_layer_->SetFlipped(false);
2072 } 2079 }
2073 2080
2074 // Ignore transparency in fullscreen, since that's what Flash always 2081 // Ignore transparency in fullscreen, since that's what Flash always
2075 // wants to do, and that lets it not recreate a context if 2082 // wants to do, and that lets it not recreate a context if
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
3347 } 3354 }
3348 3355
3349 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { 3356 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const {
3350 rect->set_x(rect->x() / viewport_to_dip_scale_); 3357 rect->set_x(rect->x() / viewport_to_dip_scale_);
3351 rect->set_y(rect->y() / viewport_to_dip_scale_); 3358 rect->set_y(rect->y() / viewport_to_dip_scale_);
3352 rect->set_width(rect->width() / viewport_to_dip_scale_); 3359 rect->set_width(rect->width() / viewport_to_dip_scale_);
3353 rect->set_height(rect->height() / viewport_to_dip_scale_); 3360 rect->set_height(rect->height() / viewport_to_dip_scale_);
3354 } 3361 }
3355 3362
3356 } // namespace content 3363 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698