summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/pepper/pepper_parent_context_provider.cc15
-rw-r--r--content/renderer/pepper/pepper_parent_context_provider.h30
-rw-r--r--content/renderer/pepper/pepper_platform_context_3d_impl.cc88
-rw-r--r--content/renderer/pepper/pepper_platform_context_3d_impl.h14
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.cc20
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.h6
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc59
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.h6
8 files changed, 76 insertions, 162 deletions
diff --git a/content/renderer/pepper/pepper_parent_context_provider.cc b/content/renderer/pepper/pepper_parent_context_provider.cc
deleted file mode 100644
index 9cb7a1f..0000000
--- a/content/renderer/pepper/pepper_parent_context_provider.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/pepper/pepper_parent_context_provider.h"
-
-namespace content {
-
-PepperParentContextProvider::PepperParentContextProvider() {
-}
-
-PepperParentContextProvider::~PepperParentContextProvider() {
-}
-
-} // namespace content
diff --git a/content/renderer/pepper/pepper_parent_context_provider.h b/content/renderer/pepper/pepper_parent_context_provider.h
deleted file mode 100644
index a96f7c6..0000000
--- a/content/renderer/pepper/pepper_parent_context_provider.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_PEPPER_PEPPER_PARENT_CONTEXT_PROVIDER_H_
-#define CONTENT_RENDERER_PEPPER_PEPPER_PARENT_CONTEXT_PROVIDER_H_
-
-#include "base/basictypes.h"
-
-namespace content {
-class WebGraphicsContext3DCommandBufferImpl;
-
-// Defines the mechanism by which a Pepper 3D context fetches its
-// parent context for display to the screen.
-class PepperParentContextProvider {
- public:
- virtual WebGraphicsContext3DCommandBufferImpl*
- GetParentContextForPlatformContext3D() = 0;
-
- protected:
- PepperParentContextProvider();
- virtual ~PepperParentContextProvider();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PepperParentContextProvider);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_PEPPER_PEPPER_PARENT_CONTEXT_PROVIDER_H_
diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.cc b/content/renderer/pepper/pepper_platform_context_3d_impl.cc
index 1fede2b..64c1625 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,24 +20,15 @@
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) {
- // 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_gles2->FreeTextureId(parent_texture_id_);
- }
+ DestroyParentContextProviderAndBackingTexture();
if (command_buffer_) {
DCHECK(channel_.get());
@@ -54,9 +45,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 +114,53 @@ 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;
+ return SetParentAndCreateBackingTextureIfNeeded();
+}
- parent_context_provider_ = NULL;
- parent_context_ = parent_context->AsWeakPtr();
+bool PlatformContext3DImpl::SetParentAndCreateBackingTextureIfNeeded() {
+ if (parent_context_provider_ &&
+ !parent_context_provider_->DestroyedOnMainThread() &&
+ parent_texture_id_)
+ return true;
+
+ parent_context_provider_ =
+ RenderThreadImpl::current()->OffscreenContextProviderForMainThread();
+ if (!parent_context_provider_->InitializeOnMainThread() ||
+ !parent_context_provider_->BindToCurrentThread()) {
+ DestroyParentContextProviderAndBackingTexture();
+ return false;
+ }
// 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_texture_id_ = parent_gles2->MakeTextureId();
CommandBufferProxyImpl* parent_command_buffer =
- parent_context_->GetCommandBufferProxy();
+ parent_context_provider_->Context3d()->GetCommandBufferProxy();
if (!command_buffer_->SetParent(parent_command_buffer, parent_texture_id_))
return false;
return true;
}
-void PlatformContext3DImpl::SetParentContext(
- PepperParentContextProvider* parent_context_provider) {
- if (parent_context_.get() && parent_texture_id_ != 0) {
+void PlatformContext3DImpl::DestroyParentContextProviderAndBackingTexture() {
+ if (!parent_context_provider_)
+ return;
+
+ 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_gles2->helper()->CommandBufferHelper::Flush();
+ parent_context_provider_->Context3d()->GetImplementation();
+ parent_gles2->helper()->CommandBufferHelper::Finish();
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_texture_id_ = parent_gles2->MakeTextureId();
-
- CommandBufferProxyImpl* parent_command_buffer =
- parent_context_->GetCommandBufferProxy();
- command_buffer_->SetParent(parent_command_buffer, parent_texture_id_);
+ parent_context_provider_ = NULL;
}
unsigned PlatformContext3DImpl::GetBackingTextureId() {
@@ -189,7 +169,9 @@ unsigned PlatformContext3DImpl::GetBackingTextureId() {
}
WebKit::WebGraphicsContext3D* PlatformContext3DImpl::GetParentContext() {
- return parent_context_.get();
+ if (!parent_context_provider_)
+ return NULL;
+ return parent_context_provider_->Context3d();
}
bool PlatformContext3DImpl::IsOpaque() {
diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.h b/content/renderer/pepper/pepper_platform_context_3d_impl.h
index f5ae686..a17d6ee 100644
--- a/content/renderer/pepper/pepper_platform_context_3d_impl.h
+++ b/content/renderer/pepper/pepper_platform_context_3d_impl.h
@@ -20,15 +20,13 @@ class CommandBuffer;
} // namespace gpu
namespace content {
+class ContextProviderCommandBuffer;
class GpuChannelHost;
-class PepperParentContextProvider;
-
class PlatformContext3DImpl
: public webkit::ppapi::PluginDelegate::PlatformContext3D {
public:
- explicit PlatformContext3DImpl(
- PepperParentContextProvider* parent_context_provider);
+ explicit PlatformContext3DImpl();
virtual ~PlatformContext3DImpl();
virtual bool Init(const int32* attrib_list,
@@ -43,17 +41,15 @@ class PlatformContext3DImpl
const ConsoleMessageCallback& callback) OVERRIDE;
virtual bool Echo(const base::Closure& task) OVERRIDE;
- virtual void SetParentContext(
- PepperParentContextProvider* parent_context_provider);
+ bool SetParentAndCreateBackingTextureIfNeeded();
+ void DestroyParentContextProviderAndBackingTexture();
private:
bool InitRaw();
void OnContextLost();
void OnConsoleMessage(const std::string& msg, int id);
- // Implicitly weak pointer; must outlive this instance.
- PepperParentContextProvider* parent_context_provider_;
- base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> parent_context_;
+ scoped_refptr<ContextProviderCommandBuffer> parent_context_provider_;
scoped_refptr<GpuChannelHost> channel_;
unsigned int parent_texture_id_;
bool has_alpha_;
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
index b79ae62..cb5497a 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
@@ -832,7 +832,7 @@ webkit::ppapi::PluginDelegate::PlatformContext3D*
const webkit_glue::WebPreferences& prefs = render_view_->webkit_preferences();
if (!prefs.accelerated_compositing_for_plugins_enabled)
return NULL;
- return new PlatformContext3DImpl(this);
+ return new PlatformContext3DImpl;
#else
return NULL;
#endif
@@ -840,7 +840,8 @@ webkit::ppapi::PluginDelegate::PlatformContext3D*
void PepperPluginDelegateImpl::ReparentContext(
webkit::ppapi::PluginDelegate::PlatformContext3D* context) {
- static_cast<PlatformContext3DImpl*>(context)->SetParentContext(this);
+ static_cast<PlatformContext3DImpl*>(context)->
+ SetParentAndCreateBackingTextureIfNeeded();
}
webkit::ppapi::PluginDelegate::PlatformVideoCapture*
@@ -1573,21 +1574,6 @@ int PepperPluginDelegateImpl::GetSessionID(PP_DeviceType_Dev type,
#endif
}
-WebGraphicsContext3DCommandBufferImpl*
-PepperPluginDelegateImpl::GetParentContextForPlatformContext3D() {
- if (!offscreen_context3d_ || offscreen_context3d_->DestroyedOnMainThread()) {
- offscreen_context3d_ =
- RenderThreadImpl::current()->OffscreenContextProviderForMainThread();
-
- if (!offscreen_context3d_->InitializeOnMainThread() ||
- !offscreen_context3d_->BindToCurrentThread()) {
- offscreen_context3d_ = NULL;
- return NULL;
- }
- }
- return offscreen_context3d_->Context3d();
-}
-
MouseLockDispatcher::LockTarget*
PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter(
webkit::ppapi::PluginInstance* instance) {
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h
index 67a3438..5a66214 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h
@@ -18,7 +18,6 @@
#include "base/observer_list.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/renderer/mouse_lock_dispatcher.h"
-#include "content/renderer/pepper/pepper_parent_context_provider.h"
#include "content/renderer/render_view_pepper_helper.h"
#include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h"
#include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
@@ -63,7 +62,6 @@ class PepperPluginDelegateImpl
: public webkit::ppapi::PluginDelegate,
public RenderViewPepperHelper,
public base::SupportsWeakPtr<PepperPluginDelegateImpl>,
- public PepperParentContextProvider,
public RenderViewObserver {
public:
explicit PepperPluginDelegateImpl(RenderViewImpl* render_view);
@@ -382,10 +380,6 @@ class PepperPluginDelegateImpl
int plugin_child_id,
bool is_external);
- // Implementation of PepperParentContextProvider.
- virtual WebGraphicsContext3DCommandBufferImpl*
- GetParentContextForPlatformContext3D() OVERRIDE;
-
MouseLockDispatcher::LockTarget* GetOrCreateLockTargetAdapter(
webkit::ppapi::PluginInstance* instance);
void UnSetAndDeleteLockTargetAdapter(webkit::ppapi::PluginInstance* instance);
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index 3154bbbd..0aa6f5e 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -332,8 +332,7 @@ class PepperWidget : public WebWidget {
}
virtual bool isAcceleratedCompositingActive() const {
- return widget_->context() && widget_->plugin() &&
- (widget_->plugin()->GetBackingTextureId() != 0);
+ return widget_->plugin() && widget_->plugin()->GetBackingTextureId();
}
private:
@@ -450,16 +449,22 @@ void RenderWidgetFullscreenPepper::DidChangeCursor(
webkit::ppapi::PluginDelegate::PlatformContext3D*
RenderWidgetFullscreenPepper::CreateContext3D() {
-#ifdef ENABLE_GPU
- return new PlatformContext3DImpl(this);
-#else
- return NULL;
-#endif
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
+ return NULL;
+ return new PlatformContext3DImpl;
}
void RenderWidgetFullscreenPepper::ReparentContext(
webkit::ppapi::PluginDelegate::PlatformContext3D* context) {
- static_cast<PlatformContext3DImpl*>(context)->SetParentContext(this);
+ PlatformContext3DImpl* context_impl =
+ static_cast<PlatformContext3DImpl*>(context);
+
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
+ context_impl->DestroyParentContextProviderAndBackingTexture();
+ else
+ context_impl->SetParentAndCreateBackingTextureIfNeeded();
}
bool RenderWidgetFullscreenPepper::OnMessageReceived(const IPC::Message& msg) {
@@ -558,14 +563,11 @@ void RenderWidgetFullscreenPepper::Composite() {
void RenderWidgetFullscreenPepper::CreateContext() {
DCHECK(!context_);
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableFlashFullscreen3d))
- return;
WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.depth = false;
attributes.stencil = false;
attributes.antialias = false;
- attributes.shareResources = false;
+ attributes.shareResources = true;
attributes.preferDiscreteGPU = true;
context_ = WebGraphicsContext3DCommandBufferImpl::CreateViewContext(
RenderThreadImpl::current(),
@@ -684,13 +686,28 @@ bool RenderWidgetFullscreenPepper::InitContext() {
}
bool RenderWidgetFullscreenPepper::CheckCompositing() {
- bool compositing =
- webwidget_ && webwidget_->isAcceleratedCompositingActive();
+ bool compositing = webwidget_ && webwidget_->isAcceleratedCompositingActive();
+ if (compositing) {
+ if (context_ && context_->isContextLost()) {
+ DestroyContext(context_, program_, buffer_);
+ context_ = NULL;
+ }
+ if (!context_)
+ CreateContext();
+ if (!context_)
+ compositing = false;
+ }
+
if (compositing != is_accelerated_compositing_active_) {
- if (compositing)
+ if (compositing) {
didActivateCompositor(-1);
- else
+ } else {
+ if (context_) {
+ DestroyContext(context_, program_, buffer_);
+ context_ = NULL;
+ }
didDeactivateCompositor();
+ }
}
return compositing;
}
@@ -704,14 +721,4 @@ void RenderWidgetFullscreenPepper::SwapBuffers() {
didCommitAndDrawCompositorFrame();
}
-WebGraphicsContext3DCommandBufferImpl*
-RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() {
- if (!context_) {
- CreateContext();
- }
- if (!context_)
- return NULL;
- return context_;
-}
-
} // namespace content
diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h
index a20d53c..c7b5422 100644
--- a/content/renderer/render_widget_fullscreen_pepper.h
+++ b/content/renderer/render_widget_fullscreen_pepper.h
@@ -9,7 +9,6 @@
#include "base/memory/weak_ptr.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/renderer/mouse_lock_dispatcher.h"
-#include "content/renderer/pepper/pepper_parent_context_provider.h"
#include "content/renderer/render_widget_fullscreen.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
@@ -32,7 +31,6 @@ class WebGraphicsContext3DCommandBufferImpl;
class RenderWidgetFullscreenPepper :
public RenderWidgetFullscreen,
public webkit::ppapi::FullscreenContainer,
- public PepperParentContextProvider,
public WebGraphicsContext3DSwapBuffersClient {
public:
static RenderWidgetFullscreenPepper* Create(
@@ -111,10 +109,6 @@ class RenderWidgetFullscreenPepper :
// and notify the browser.
bool CheckCompositing();
- // Implementation of PepperParentContextProvider.
- virtual WebGraphicsContext3DCommandBufferImpl*
- GetParentContextForPlatformContext3D() OVERRIDE;
-
// URL that is responsible for this widget, passed to ggl::CreateViewContext.
GURL active_url_;