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 #include "ui/gl/gl_surface.h" | |
| 10 | |
| 11 namespace android_webview { | |
| 12 | |
| 13 unsigned int GLSurfaceFactory::current_fbo_ = 0; | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 // This surface is used to represent the underlying surface provided by the App | |
| 18 // inside a hardware draw. Note that offscreen contexts will not be using this | |
| 19 // GLSurface. | |
| 20 class GL_EXPORT AwGLSurface : public gfx::GLSurface { | |
| 21 public: | |
| 22 // Implement GLSurface. | |
| 23 virtual void Destroy() OVERRIDE; | |
| 24 virtual bool IsOffscreen() OVERRIDE; | |
| 25 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | |
| 26 virtual bool SwapBuffers() OVERRIDE; | |
| 27 virtual gfx::Size GetSize() OVERRIDE; | |
| 28 virtual void* GetHandle() OVERRIDE; | |
| 29 virtual void* GetDisplay() OVERRIDE; | |
| 30 | |
| 31 protected: | |
| 32 virtual ~AwGLSurface(); | |
| 33 }; | |
| 34 | |
| 35 AwGLSurface::~AwGLSurface() {} | |
| 36 | |
| 37 void AwGLSurface::Destroy() { | |
| 38 } | |
| 39 | |
| 40 bool AwGLSurface::IsOffscreen() { | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 unsigned int AwGLSurface::GetBackingFrameBufferObject() { | |
| 45 return GLSurfaceFactory::GetCurrentFBO(); | |
| 46 } | |
| 47 | |
| 48 bool AwGLSurface::SwapBuffers() { | |
| 49 return true; | |
| 50 } | |
| 51 | |
| 52 gfx::Size AwGLSurface::GetSize() { | |
| 53 return gfx::Size(); | |
| 54 } | |
| 55 | |
| 56 void* AwGLSurface::GetHandle() { | |
| 57 return NULL; | |
| 58 } | |
| 59 | |
| 60 void* AwGLSurface::GetDisplay() { | |
| 61 return NULL; | |
| 62 } | |
| 63 | |
| 64 base::LazyInstance<GLSurfaceFactory>::Leaky g_gl_surface_factory; | |
| 65 | |
| 66 } // namespace | |
| 67 | |
| 68 // static | |
| 69 void GLSurfaceFactory::Install() { | |
| 70 DCHECK(!gfx::SurfaceFactoryAndroid::GetInstance()); | |
| 71 gfx::SurfaceFactoryAndroid::SetInstance(g_gl_surface_factory.Pointer()); | |
| 72 } | |
| 73 | |
| 74 // static | |
| 75 void GLSurfaceFactory::SetCurrentFBO(unsigned int fbo) { | |
|
joth
2013/08/06 03:55:41
To make it clear at any moment only one surface ca
| |
| 76 current_fbo_ = fbo; | |
| 77 } | |
| 78 | |
| 79 unsigned int GLSurfaceFactory::GetCurrentFBO() { | |
| 80 return current_fbo_; | |
| 81 } | |
| 82 | |
| 83 GLSurfaceFactory::GLSurfaceFactory() {} | |
| 84 | |
| 85 GLSurfaceFactory::~GLSurfaceFactory() {} | |
| 86 | |
| 87 scoped_refptr<gfx::GLSurface> GLSurfaceFactory::CreateNonOwnedViewSurface() { | |
| 88 return new AwGLSurface; | |
| 89 } | |
| 90 | |
| 91 } // namespace android_webview | |
| OLD | NEW |