summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-16 04:40:15 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-16 04:40:15 +0000
commit2cf020aa170470e24f94a877e434c7c6c4af0a35 (patch)
treef70f8df4f26d2b70b41c5ef842876ab85bb07176
parenta94454b8a871d06ff2f645bd70b558e2591f4195 (diff)
downloadchromium_src-2cf020aa170470e24f94a877e434c7c6c4af0a35.zip
chromium_src-2cf020aa170470e24f94a877e434c7c6c4af0a35.tar.gz
chromium_src-2cf020aa170470e24f94a877e434c7c6c4af0a35.tar.bz2
Move PlatformContext3DImpl to separate file
This is preliminary work to hook up 3D context to fullscreen pepper BUG=none TEST=run with --enable-accelerated-layers Review URL: http://codereview.chromium.org/5842003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69375 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/pepper_platform_context_3d_impl.cc94
-rw-r--r--chrome/renderer/pepper_platform_context_3d_impl.h34
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc126
4 files changed, 142 insertions, 114 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index dc253b7..8ad6da3 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -142,6 +142,8 @@
'renderer/password_autocomplete_manager.h',
'renderer/pepper_devices.cc',
'renderer/pepper_devices.h',
+ 'renderer/pepper_platform_context_3d_impl.cc',
+ 'renderer/pepper_platform_context_3d_impl.h',
'renderer/pepper_plugin_delegate_impl.cc',
'renderer/pepper_plugin_delegate_impl.h',
'renderer/pepper_scrollbar_widget.cc',
diff --git a/chrome/renderer/pepper_platform_context_3d_impl.cc b/chrome/renderer/pepper_platform_context_3d_impl.cc
new file mode 100644
index 0000000..1d86a67
--- /dev/null
+++ b/chrome/renderer/pepper_platform_context_3d_impl.cc
@@ -0,0 +1,94 @@
+// Copyright (c) 2010 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 "chrome/renderer/pepper_platform_context_3d_impl.h"
+
+#include "chrome/renderer/ggl/ggl.h"
+#include "chrome/renderer/gpu_channel_host.h"
+#include "chrome/renderer/render_thread.h"
+
+#ifdef ENABLE_GPU
+PlatformContext3DImpl::PlatformContext3DImpl(ggl::Context* parent_context)
+ : parent_context_(parent_context),
+ context_(NULL) {
+}
+
+PlatformContext3DImpl::~PlatformContext3DImpl() {
+ if (context_) {
+ ggl::DestroyContext(context_);
+ context_ = NULL;
+ }
+}
+
+bool PlatformContext3DImpl::Init() {
+ // Ignore initializing more than once.
+ if (context_)
+ return true;
+
+ RenderThread* render_thread = RenderThread::current();
+ if (!render_thread)
+ return false;
+
+ GpuChannelHost* host = render_thread->GetGpuChannel();
+ if (!host)
+ return false;
+
+ DCHECK(host->state() == GpuChannelHost::kConnected);
+
+ // TODO(apatrick): Let Pepper plugins configure their back buffer surface.
+ static const int32 attribs[] = {
+ ggl::GGL_ALPHA_SIZE, 8,
+ ggl::GGL_DEPTH_SIZE, 24,
+ ggl::GGL_STENCIL_SIZE, 8,
+ ggl::GGL_SAMPLES, 0,
+ ggl::GGL_SAMPLE_BUFFERS, 0,
+ ggl::GGL_NONE,
+ };
+
+ // TODO(apatrick): Decide which extensions to expose to Pepper plugins.
+ // Currently they get only core GLES2.
+ context_ = ggl::CreateOffscreenContext(host,
+ parent_context_,
+ gfx::Size(1, 1),
+ "",
+ attribs);
+ if (!context_)
+ return false;
+
+ return true;
+}
+
+bool PlatformContext3DImpl::SwapBuffers() {
+ DCHECK(context_);
+ return ggl::SwapBuffers(context_);
+}
+
+unsigned PlatformContext3DImpl::GetError() {
+ DCHECK(context_);
+ return ggl::GetError(context_);
+}
+
+void PlatformContext3DImpl::ResizeBackingTexture(const gfx::Size& size) {
+ DCHECK(context_);
+ ggl::ResizeOffscreenContext(context_, size);
+}
+
+void PlatformContext3DImpl::SetSwapBuffersCallback(Callback0::Type* callback) {
+ DCHECK(context_);
+ ggl::SetSwapBuffersCallback(context_, callback);
+}
+
+unsigned PlatformContext3DImpl::GetBackingTextureId() {
+ DCHECK(context_);
+ return ggl::GetParentTextureId(context_);
+}
+
+gpu::gles2::GLES2Implementation*
+ PlatformContext3DImpl::GetGLES2Implementation() {
+ DCHECK(context_);
+ return ggl::GetImplementation(context_);
+}
+
+#endif // ENABLE_GPU
+
diff --git a/chrome/renderer/pepper_platform_context_3d_impl.h b/chrome/renderer/pepper_platform_context_3d_impl.h
new file mode 100644
index 0000000..03c6bb6
--- /dev/null
+++ b/chrome/renderer/pepper_platform_context_3d_impl.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_delegate.h"
+
+#ifdef ENABLE_GPU
+
+namespace ggl {
+
+class Context;
+
+} // namespace ggl;
+
+class PlatformContext3DImpl : public pepper::PluginDelegate::PlatformContext3D {
+ public:
+ explicit PlatformContext3DImpl(ggl::Context* parent_context);
+ virtual ~PlatformContext3DImpl();
+
+ virtual bool Init();
+ virtual bool SwapBuffers();
+ virtual unsigned GetError();
+ virtual void SetSwapBuffersCallback(Callback0::Type* callback);
+ void ResizeBackingTexture(const gfx::Size& size);
+ virtual unsigned GetBackingTextureId();
+ virtual gpu::gles2::GLES2Implementation* GetGLES2Implementation();
+
+ private:
+ ggl::Context* parent_context_;
+ ggl::Context* context_;
+};
+
+#endif // ENABLE_GPU
+
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index e2fcfc7..7783dea 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -26,6 +26,7 @@
#include "chrome/renderer/command_buffer_proxy.h"
#include "chrome/renderer/ggl/ggl.h"
#include "chrome/renderer/gpu_channel_host.h"
+#include "chrome/renderer/pepper_platform_context_3d_impl.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h"
@@ -97,36 +98,6 @@ class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D {
DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl);
};
-#ifdef ENABLE_GPU
-
-class PlatformContext3DImpl : public pepper::PluginDelegate::PlatformContext3D {
- public:
- explicit PlatformContext3DImpl(WebKit::WebView* web_view)
- : web_view_(web_view),
- context_(NULL) {
- }
-
- virtual ~PlatformContext3DImpl() {
- if (context_) {
- ggl::DestroyContext(context_);
- context_ = NULL;
- }
- }
-
- virtual bool Init();
- virtual bool SwapBuffers();
- virtual unsigned GetError();
- virtual void SetSwapBuffersCallback(Callback0::Type* callback);
- void ResizeBackingTexture(const gfx::Size& size);
- virtual unsigned GetBackingTextureId();
- virtual gpu::gles2::GLES2Implementation* GetGLES2Implementation();
-
- private:
- WebKit::WebView* web_view_;
- ggl::Context* context_;
-};
-
-#endif // ENABLE_GPU
class PlatformAudioImpl
: public pepper::PluginDelegate::PlatformAudio,
@@ -191,89 +162,6 @@ class PlatformAudioImpl
DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
};
-#ifdef ENABLE_GPU
-
-bool PlatformContext3DImpl::Init() {
- // Ignore initializing more than once.
- if (context_)
- return true;
-
- WebGraphicsContext3DCommandBufferImpl* context =
- static_cast<WebGraphicsContext3DCommandBufferImpl*>(
- web_view_->graphicsContext3D());
- if (!context)
- return false;
-
- ggl::Context* parent_context = context->context();
- if (!parent_context)
- return false;
-
- RenderThread* render_thread = RenderThread::current();
- if (!render_thread)
- return false;
-
- GpuChannelHost* host = render_thread->GetGpuChannel();
- if (!host)
- return false;
-
- DCHECK(host->state() == GpuChannelHost::kConnected);
-
- // TODO(apatrick): Let Pepper plugins configure their back buffer surface.
- static const int32 attribs[] = {
- ggl::GGL_ALPHA_SIZE, 8,
- ggl::GGL_DEPTH_SIZE, 24,
- ggl::GGL_STENCIL_SIZE, 8,
- ggl::GGL_SAMPLES, 0,
- ggl::GGL_SAMPLE_BUFFERS, 0,
- ggl::GGL_NONE,
- };
-
- // TODO(apatrick): Decide which extensions to expose to Pepper plugins.
- // Currently they get only core GLES2.
- context_ = ggl::CreateOffscreenContext(host,
- parent_context,
- gfx::Size(1, 1),
- "",
- attribs);
- if (!context_)
- return false;
-
- return true;
-}
-
-bool PlatformContext3DImpl::SwapBuffers() {
- DCHECK(context_);
- return ggl::SwapBuffers(context_);
-}
-
-unsigned PlatformContext3DImpl::GetError() {
- DCHECK(context_);
- return ggl::GetError(context_);
-}
-
-void PlatformContext3DImpl::ResizeBackingTexture(const gfx::Size& size) {
- DCHECK(context_);
- ggl::ResizeOffscreenContext(context_, size);
-}
-
-void PlatformContext3DImpl::SetSwapBuffersCallback(Callback0::Type* callback) {
- DCHECK(context_);
- ggl::SetSwapBuffersCallback(context_, callback);
-}
-
-unsigned PlatformContext3DImpl::GetBackingTextureId() {
- DCHECK(context_);
- return ggl::GetParentTextureId(context_);
-}
-
-gpu::gles2::GLES2Implementation*
- PlatformContext3DImpl::GetGLES2Implementation() {
- DCHECK(context_);
- return ggl::GetImplementation(context_);
-}
-
-#endif // ENABLE_GPU
-
bool PlatformAudioImpl::Initialize(
uint32_t sample_rate, uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client) {
@@ -611,7 +499,17 @@ PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
pepper::PluginDelegate::PlatformContext3D*
PepperPluginDelegateImpl::CreateContext3D() {
#ifdef ENABLE_GPU
- return new PlatformContext3DImpl(render_view_->webview());
+ WebGraphicsContext3DCommandBufferImpl* context =
+ static_cast<WebGraphicsContext3DCommandBufferImpl*>(
+ render_view_->webview()->graphicsContext3D());
+ if (!context)
+ return NULL;
+
+ ggl::Context* parent_context = context->context();
+ if (!parent_context)
+ return NULL;
+
+ return new PlatformContext3DImpl(parent_context);
#else
return NULL;
#endif