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

Unified Diff: chrome/renderer/pepper_platform_context_3d_impl.cc

Issue 5842003: Move PlatformContext3DImpl to separate file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « chrome/renderer/pepper_platform_context_3d_impl.h ('k') | chrome/renderer/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/pepper_platform_context_3d_impl.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 0000000000000000000000000000000000000000..1d86a67b3e455cc6c463e18119e115ed048ed120
--- /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
+
« no previous file with comments | « chrome/renderer/pepper_platform_context_3d_impl.h ('k') | chrome/renderer/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698