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

Unified Diff: content/renderer/pepper/pepper_platform_context_3d_impl.cc

Issue 12673002: pepper: Use the RenderThread's shared context as the parent context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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_platform_context_3d_impl.cc
diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.cc b/content/renderer/pepper/pepper_platform_context_3d_impl.cc
index 1fede2bcead605deb354a411ab718838515306ef..3fee4429b24acc8ef9e27126d210de9b784173b9 100644
--- a/content/renderer/pepper/pepper_platform_context_3d_impl.cc
+++ b/content/renderer/pepper/pepper_platform_context_3d_impl.cc
@@ -5,9 +5,9 @@
#include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
#include "base/bind.h"
+#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/gpu_channel_host.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
-#include "content/renderer/pepper/pepper_parent_context_provider.h"
#include "content/renderer/render_thread_impl.h"
#include "googleurl/src/gurl.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
@@ -20,21 +20,19 @@
namespace content {
-PlatformContext3DImpl::PlatformContext3DImpl(
- PepperParentContextProvider* parent_context_provider)
- : parent_context_provider_(parent_context_provider),
- parent_texture_id_(0),
- has_alpha_(false),
- command_buffer_(NULL),
- weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+PlatformContext3DImpl::PlatformContext3DImpl()
+ : parent_texture_id_(0),
+ has_alpha_(false),
+ command_buffer_(NULL),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PlatformContext3DImpl::~PlatformContext3DImpl() {
- if (parent_context_.get() && parent_texture_id_ != 0) {
+ if (parent_texture_id_) {
// Flush any remaining commands in the parent context to make sure the
// texture id accounting stays consistent.
gpu::gles2::GLES2Implementation* parent_gles2 =
- parent_context_->GetImplementation();
+ parent_context_provider_->Context3d()->GetImplementation();
parent_gles2->helper()->CommandBufferHelper::Finish();
parent_gles2->FreeTextureId(parent_texture_id_);
}
@@ -54,9 +52,6 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list,
if (command_buffer_)
return true;
- if (!parent_context_provider_)
- return false;
-
RenderThreadImpl* render_thread = RenderThreadImpl::current();
if (!render_thread)
return false;
@@ -126,61 +121,25 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list,
base::Bind(&PlatformContext3DImpl::OnConsoleMessage,
weak_ptr_factory_.GetWeakPtr()));
- // Fetch the parent context now, after any potential shutdown of the
- // channel due to GPU switching, and creation of the Pepper 3D
- // context with the discrete GPU preference.
- WebGraphicsContext3DCommandBufferImpl* parent_context =
- parent_context_provider_->GetParentContextForPlatformContext3D();
- if (!parent_context)
- return false;
-
- parent_context_provider_ = NULL;
- parent_context_ = parent_context->AsWeakPtr();
-
- // Flush any remaining commands in the parent context to make sure the
- // texture id accounting stays consistent.
- gpu::gles2::GLES2Implementation* parent_gles2 =
- parent_context_->GetImplementation();
- parent_gles2->helper()->CommandBufferHelper::Finish();
- parent_texture_id_ = parent_gles2->MakeTextureId();
-
- CommandBufferProxyImpl* parent_command_buffer =
- parent_context_->GetCommandBufferProxy();
- if (!command_buffer_->SetParent(parent_command_buffer, parent_texture_id_))
+ parent_context_provider_ =
+ render_thread->OffscreenContextProviderForMainThread();
+ if (!parent_context_provider_->InitializeOnMainThread() ||
+ !parent_context_provider_->BindToCurrentThread()) {
piman 2013/03/08 04:43:16 Is it ok to do those every time? Should this be do
danakj 2013/03/08 18:13:34 Ya this is a noop if you already did it once. I li
piman 2013/03/08 18:27:08 It does have side effect in the sense that it crea
danakj 2013/03/08 18:40:28 It creates a context provider, which is just a wra
+ parent_context_provider_ = NULL;
return false;
-
- return true;
-}
-
-void PlatformContext3DImpl::SetParentContext(
- PepperParentContextProvider* parent_context_provider) {
- if (parent_context_.get() && parent_texture_id_ != 0) {
- // Flush any remaining commands in the parent context to make sure the
- // texture id accounting stays consistent.
- gpu::gles2::GLES2Implementation* parent_gles2 =
- parent_context_->GetImplementation();
- parent_gles2->helper()->CommandBufferHelper::Flush();
- parent_gles2->FreeTextureId(parent_texture_id_);
- parent_context_.reset();
- parent_texture_id_ = 0;
}
- WebGraphicsContext3DCommandBufferImpl* parent_context =
- parent_context_provider->GetParentContextForPlatformContext3D();
- if (!parent_context)
- return;
-
- parent_context_ = parent_context->AsWeakPtr();
// Flush any remaining commands in the parent context to make sure the
// texture id accounting stays consistent.
gpu::gles2::GLES2Implementation* parent_gles2 =
- parent_context_->GetImplementation();
- parent_gles2->helper()->CommandBufferHelper::Flush();
+ parent_context_provider_->Context3d()->GetImplementation();
+ parent_gles2->helper()->CommandBufferHelper::Finish();
parent_texture_id_ = parent_gles2->MakeTextureId();
CommandBufferProxyImpl* parent_command_buffer =
- parent_context_->GetCommandBufferProxy();
+ parent_context_provider_->Context3d()->GetCommandBufferProxy();
command_buffer_->SetParent(parent_command_buffer, parent_texture_id_);
+ return true;
}
unsigned PlatformContext3DImpl::GetBackingTextureId() {
@@ -189,7 +148,7 @@ unsigned PlatformContext3DImpl::GetBackingTextureId() {
}
WebKit::WebGraphicsContext3D* PlatformContext3DImpl::GetParentContext() {
- return parent_context_.get();
+ return parent_context_provider_->Context3d();
}
bool PlatformContext3DImpl::IsOpaque() {

Powered by Google App Engine
This is Rietveld 408576698