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

Unified Diff: android_webview/browser/gl_surface_factory.cc

Issue 22277004: Add gfx::SurfaceFactoryWebview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: static member var Created 7 years, 4 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
« no previous file with comments | « android_webview/browser/gl_surface_factory.h ('k') | android_webview/browser/in_process_view_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/gl_surface_factory.cc
diff --git a/android_webview/browser/gl_surface_factory.cc b/android_webview/browser/gl_surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e87628ea09794505ce395dcaaa06f11bbe09fae8
--- /dev/null
+++ b/android_webview/browser/gl_surface_factory.cc
@@ -0,0 +1,91 @@
+// Copyright (c) 2013 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 "android_webview/browser/gl_surface_factory.h"
+
+#include "base/lazy_instance.h"
+#include "ui/gl/gl_bindings.h"
+#include "ui/gl/gl_surface.h"
+
+namespace android_webview {
+
+unsigned int GLSurfaceFactory::current_fbo_ = 0;
+
+namespace {
+
+// This surface is used to represent the underlying surface provided by the App
+// inside a hardware draw. Note that offscreen contexts will not be using this
+// GLSurface.
+class GL_EXPORT AwGLSurface : public gfx::GLSurface {
+ public:
+ // Implement GLSurface.
+ virtual void Destroy() OVERRIDE;
+ virtual bool IsOffscreen() OVERRIDE;
+ virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
+ virtual bool SwapBuffers() OVERRIDE;
+ virtual gfx::Size GetSize() OVERRIDE;
+ virtual void* GetHandle() OVERRIDE;
+ virtual void* GetDisplay() OVERRIDE;
+
+ protected:
+ virtual ~AwGLSurface();
+};
+
+AwGLSurface::~AwGLSurface() {}
+
+void AwGLSurface::Destroy() {
+}
+
+bool AwGLSurface::IsOffscreen() {
+ return false;
+}
+
+unsigned int AwGLSurface::GetBackingFrameBufferObject() {
+ return GLSurfaceFactory::GetCurrentFBO();
+}
+
+bool AwGLSurface::SwapBuffers() {
+ return true;
+}
+
+gfx::Size AwGLSurface::GetSize() {
+ return gfx::Size();
+}
+
+void* AwGLSurface::GetHandle() {
+ return NULL;
+}
+
+void* AwGLSurface::GetDisplay() {
+ return NULL;
+}
+
+base::LazyInstance<GLSurfaceFactory>::Leaky g_gl_surface_factory;
+
+} // namespace
+
+// static
+void GLSurfaceFactory::Install() {
+ DCHECK(!gfx::SurfaceFactoryAndroid::GetInstance());
+ gfx::SurfaceFactoryAndroid::SetInstance(g_gl_surface_factory.Pointer());
+}
+
+// static
+void GLSurfaceFactory::SetCurrentFBO(unsigned int fbo) {
joth 2013/08/06 03:55:41 To make it clear at any moment only one surface ca
+ current_fbo_ = fbo;
+}
+
+unsigned int GLSurfaceFactory::GetCurrentFBO() {
+ return current_fbo_;
+}
+
+GLSurfaceFactory::GLSurfaceFactory() {}
+
+GLSurfaceFactory::~GLSurfaceFactory() {}
+
+scoped_refptr<gfx::GLSurface> GLSurfaceFactory::CreateNonOwnedViewSurface() {
+ return new AwGLSurface;
+}
+
+} // namespace android_webview
« no previous file with comments | « android_webview/browser/gl_surface_factory.h ('k') | android_webview/browser/in_process_view_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698