Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "android_webview/browser/gl_surface_factory.h" | |
| 6 | |
| 7 #include "base/lazy_instance.h" | |
| 8 #include "ui/gl/gl_bindings.h" | |
| 9 | |
| 10 namespace android_webview { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 unsigned int g_current_fbo = 0; | |
| 15 | |
| 16 class GL_EXPORT AwGLSurface : public gfx::GLSurface { | |
| 17 public: | |
| 18 // Implement GLSurface. | |
| 19 virtual void Destroy() OVERRIDE; | |
| 20 virtual bool IsOffscreen() OVERRIDE; | |
| 21 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | |
| 22 virtual bool SwapBuffers() OVERRIDE; | |
| 23 virtual gfx::Size GetSize() OVERRIDE; | |
| 24 virtual void* GetHandle() OVERRIDE; | |
| 25 virtual void* GetDisplay() OVERRIDE; | |
| 26 | |
| 27 protected: | |
| 28 virtual ~AwGLSurface(); | |
| 29 }; | |
| 30 | |
| 31 AwGLSurface::~AwGLSurface() {} | |
| 32 | |
| 33 /* | |
| 34 */ | |
| 35 | |
| 36 void AwGLSurface::Destroy() { | |
| 37 } | |
| 38 | |
| 39 bool AwGLSurface::IsOffscreen() { | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 unsigned int AwGLSurface::GetBackingFrameBufferObject() { | |
| 44 return g_current_fbo; | |
| 45 } | |
| 46 | |
| 47 bool AwGLSurface::SwapBuffers() { | |
| 48 return true; | |
| 49 } | |
| 50 | |
| 51 gfx::Size AwGLSurface::GetSize() { | |
| 52 return gfx::Size(); | |
| 53 } | |
| 54 | |
| 55 void* AwGLSurface::GetHandle() { | |
| 56 return NULL; | |
| 57 } | |
| 58 | |
| 59 void* AwGLSurface::GetDisplay() { | |
| 60 return NULL; | |
| 61 } | |
| 62 | |
| 63 base::LazyInstance<GLSurfaceFactory>::Leaky g_gl_surface_factory; | |
| 64 | |
| 65 } // namespace | |
| 66 | |
| 67 // static | |
| 68 void GLSurfaceFactory::Install() { | |
| 69 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
| |
| 70 } | |
| 71 | |
| 72 // static | |
| 73 void GLSurfaceFactory::SetCurrentFBO(unsigned int fbo) { | |
| 74 g_current_fbo = fbo; | |
| 75 } | |
| 76 | |
| 77 GLSurfaceFactory::GLSurfaceFactory() {} | |
| 78 | |
| 79 GLSurfaceFactory::~GLSurfaceFactory() {} | |
| 80 | |
| 81 scoped_refptr<gfx::GLSurface> GLSurfaceFactory::CreateNonOwnedViewSurface() { | |
| 82 return new AwGLSurface; | |
| 83 } | |
| 84 | |
| 85 } // namespace android_webview | |
| OLD | NEW |