summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xchrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/webgles2context_impl.cc60
-rw-r--r--chrome/renderer/webgles2context_impl.h31
3 files changed, 93 insertions, 0 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 774af6d..cf6f8bf 100755
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -155,6 +155,8 @@
'renderer/user_script_slave.h',
'renderer/visitedlink_slave.cc',
'renderer/visitedlink_slave.h',
+ 'renderer/webgles2context_impl.cc',
+ 'renderer/webgles2context_impl.h',
'renderer/webgraphicscontext3d_command_buffer_impl.cc',
'renderer/webgraphicscontext3d_command_buffer_impl.h',
'renderer/webplugin_delegate_proxy.cc',
diff --git a/chrome/renderer/webgles2context_impl.cc b/chrome/renderer/webgles2context_impl.cc
new file mode 100644
index 0000000..36d15f7
--- /dev/null
+++ b/chrome/renderer/webgles2context_impl.cc
@@ -0,0 +1,60 @@
+// 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.
+
+#if defined(ENABLE_GPU)
+
+#include "chrome/renderer/webgles2context_impl.h"
+
+#include "chrome/renderer/gpu_channel_host.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
+
+
+WebGLES2ContextImpl::WebGLES2ContextImpl() : context_(NULL) {
+}
+
+WebGLES2ContextImpl::~WebGLES2ContextImpl() {
+ destroy();
+}
+
+bool WebGLES2ContextImpl::initialize(WebKit::WebView* web_view) {
+ RenderThread* render_thread = RenderThread::current();
+ if (!render_thread)
+ return false;
+ GpuChannelHost* host = render_thread->EstablishGpuChannelSync();
+ if (!host)
+ return false;
+ DCHECK(host->ready());
+
+ // If a WebView is passed then create a context rendering directly
+ // into the window used by the WebView, otherwise create an offscreen
+ // context.
+ if (web_view) {
+ RenderView* renderview = RenderView::FromWebView(web_view);
+ if (!renderview)
+ return false;
+ gfx::NativeViewId view_id = renderview->host_window();
+ context_ = ggl::CreateViewContext(host, view_id);
+ } else {
+ context_ = ggl::CreateOffscreenContext(host, NULL, gfx::Size(1, 1));
+ }
+
+ return (context_ != NULL);
+}
+
+bool WebGLES2ContextImpl::makeCurrent() {
+ return ggl::MakeCurrent(context_);
+}
+
+bool WebGLES2ContextImpl::destroy() {
+ return ggl::DestroyContext(context_);
+}
+
+bool WebGLES2ContextImpl::swapBuffers() {
+ return ggl::SwapBuffers();
+}
+
+#endif // defined(ENABLE_GPU)
+
diff --git a/chrome/renderer/webgles2context_impl.h b/chrome/renderer/webgles2context_impl.h
new file mode 100644
index 0000000..44283df3
--- /dev/null
+++ b/chrome/renderer/webgles2context_impl.h
@@ -0,0 +1,31 @@
+// 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.
+
+#ifndef CHROME_RENDERER_WEBGLES2CONTEXT_IMPL_H_
+#define CHROME_RENDERER_WEBGLES2CONTEXT_IMPL_H_
+
+#if defined(ENABLE_GPU)
+
+#include "chrome/renderer/ggl/ggl.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebGLES2Context.h"
+
+class WebGLES2ContextImpl : public WebKit::WebGLES2Context {
+ public:
+ WebGLES2ContextImpl();
+ virtual ~WebGLES2ContextImpl();
+
+ virtual bool initialize(WebKit::WebView*);
+ virtual bool makeCurrent();
+ virtual bool destroy();
+ virtual bool swapBuffers();
+
+ private:
+ // The GGL context we use for OpenGL rendering.
+ ggl::Context* context_;
+ WebKit::WebView* web_view_;
+};
+
+#endif // defined(ENABLE_GPU)
+#endif // CHROME_RENDERER_WEBGLES2CONTEXT_IMPL_H_
+