Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: android_webview/browser/gl_surface_factory.cc

Issue 22277004: Add gfx::SurfaceFactoryWebview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: implementation Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698