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 |