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..fc64182fc8f74d18cb6a615f5b4608237443b4da |
--- /dev/null |
+++ b/android_webview/browser/gl_surface_factory.cc |
@@ -0,0 +1,87 @@ |
+// 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 { |
+ |
+namespace { |
+ |
+unsigned int g_current_fbo = 0; |
piman
2013/08/06 03:09:45
Can we make this a member of the GLSurfaceFactory?
boliu
2013/08/06 03:33:41
Made this a static member var. (You didn't mean no
|
+ |
+// 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 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; |
piman
2013/08/06 03:09:45
Can we make this non-leaky?
boliu
2013/08/06 03:33:41
Actually this is a pattern in android_webview/. Li
|
+ |
+} // namespace |
+ |
+// static |
+void GLSurfaceFactory::Install() { |
+ DCHECK(!gfx::SurfaceFactoryAndroid::GetInstance()); |
+ gfx::SurfaceFactoryAndroid::SetInstance(g_gl_surface_factory.Pointer()); |
+} |
+ |
+// 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 |