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..e1dc0743ea749c377e50e83eae3d0034d0a5344c |
--- /dev/null |
+++ b/android_webview/browser/gl_surface_factory.cc |
@@ -0,0 +1,85 @@ |
+// 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" |
+ |
+namespace android_webview { |
+ |
+namespace { |
+ |
+unsigned int g_current_fbo = 0; |
+ |
+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 g_current_fbo; |
+} |
+ |
+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() { |
+ gfx::SurfaceFactoryWebView::SetInstance(g_gl_surface_factory.Pointer()); |
no sievers
2013/08/06 01:50:06
do you need the LazyInstance (esp. since you are l
boliu
2013/08/06 02:14:26
For no particular reason other than it's a pattern
joth
2013/08/06 03:55:41
we use Daniel's pattern too... see content::SetCon
|
+} |
+ |
+// static |
+void GLSurfaceFactory::SetCurrentFBO(unsigned int fbo) { |
+ g_current_fbo = fbo; |
+} |
+ |
+GLSurfaceFactory::GLSurfaceFactory() {} |
+ |
+GLSurfaceFactory::~GLSurfaceFactory() {} |
+ |
+scoped_refptr<gfx::GLSurface> GLSurfaceFactory::CreateNonOwnedViewSurface() { |
+ return new AwGLSurface; |
+} |
+ |
+} // namespace android_webview |