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

Side by Side Diff: ui/gfx/gl/gl_surface.h

Issue 10392068: ui: Move gl/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac_rel Created 8 years, 7 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
« no previous file with comments | « ui/gfx/gl/gl_share_group.cc ('k') | ui/gfx/gl/gl_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef UI_GFX_GL_GL_SURFACE_H_
6 #define UI_GFX_GL_GL_SURFACE_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "build/build_config.h"
11 #include "ui/gfx/gl/gl_export.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gfx/size.h"
14
15 namespace gfx {
16
17 class GLContext;
18
19 #if defined(OS_ANDROID)
20 class AndroidNativeWindow;
21 #endif
22
23 // Encapsulates a surface that can be rendered to with GL, hiding platform
24 // specific management.
25 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
26 public:
27 GLSurface();
28
29 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the
30 // EGL surface associated to be recreated without destroying the associated
31 // context. The implementation of this function for other GLSurface derived
32 // classes is in a pending changelist.
33 virtual bool Initialize();
34
35 // Destroys the surface.
36 virtual void Destroy() = 0;
37
38 virtual bool Resize(const gfx::Size& size);
39
40 // Returns true if this surface is offscreen.
41 virtual bool IsOffscreen() = 0;
42
43 // Swaps front and back buffers. This has no effect for off-screen
44 // contexts.
45 virtual bool SwapBuffers() = 0;
46
47 // Get the size of the surface.
48 virtual gfx::Size GetSize() = 0;
49
50 #if defined(OS_ANDROID)
51 virtual void SetNativeWindow(AndroidNativeWindow* window) { }
52 #endif
53
54 // Get the underlying platform specific surface "handle".
55 virtual void* GetHandle() = 0;
56
57 // Returns space separated list of surface specific extensions.
58 // The surface must be current.
59 virtual std::string GetExtensions();
60
61 // Returns the internal frame buffer object name if the surface is backed by
62 // FBO. Otherwise returns 0.
63 virtual unsigned int GetBackingFrameBufferObject();
64
65 // Copy part of the backbuffer to the frontbuffer.
66 virtual bool PostSubBuffer(int x, int y, int width, int height);
67
68 static bool InitializeOneOff();
69
70 // Called after a context is made current with this surface. Returns false
71 // on error.
72 virtual bool OnMakeCurrent(GLContext* context);
73
74 // Used for explicit buffer management. Expect buffers to be destroyed only
75 // when surface is not visible.
76 enum BufferAllocationState {
77 BUFFER_ALLOCATION_FRONT_AND_BACK,
78 BUFFER_ALLOCATION_FRONT_ONLY,
79 BUFFER_ALLOCATION_NONE
80 };
81 virtual void SetBufferAllocation(BufferAllocationState state);
82
83 // Get a handle used to share the surface with another process. Returns null
84 // if this is not possible.
85 virtual void* GetShareHandle();
86
87 // Get the platform specific display on which this surface resides, if
88 // available.
89 virtual void* GetDisplay();
90
91 // Get the platfrom specific configuration for this surface, if available.
92 virtual void* GetConfig();
93
94 // Get the GL pixel format of the surface, if available.
95 virtual unsigned GetFormat();
96
97 // Create a GL surface that renders directly to a view.
98 static scoped_refptr<GLSurface> CreateViewGLSurface(
99 bool software,
100 gfx::AcceleratedWidget window);
101
102 // Create a GL surface used for offscreen rendering.
103 static scoped_refptr<GLSurface> CreateOffscreenGLSurface(
104 bool software,
105 const gfx::Size& size);
106
107 static GLSurface* GetCurrent();
108
109 protected:
110 virtual ~GLSurface();
111 static bool InitializeOneOffInternal();
112 static void SetCurrent(GLSurface* surface);
113
114 private:
115 friend class base::RefCounted<GLSurface>;
116 friend class GLContext;
117 DISALLOW_COPY_AND_ASSIGN(GLSurface);
118 };
119
120 // Implementation of GLSurface that forwards all calls through to another
121 // GLSurface.
122 class GL_EXPORT GLSurfaceAdapter : public GLSurface {
123 public:
124 explicit GLSurfaceAdapter(GLSurface* surface);
125
126 virtual bool Initialize() OVERRIDE;
127 virtual void Destroy() OVERRIDE;
128 virtual bool Resize(const gfx::Size& size) OVERRIDE;
129 virtual bool IsOffscreen() OVERRIDE;
130 virtual bool SwapBuffers() OVERRIDE;
131 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
132 virtual std::string GetExtensions() OVERRIDE;
133 virtual gfx::Size GetSize() OVERRIDE;
134 virtual void* GetHandle() OVERRIDE;
135 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
136 virtual bool OnMakeCurrent(GLContext* context) OVERRIDE;
137 virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE;
138 virtual void* GetShareHandle() OVERRIDE;
139 virtual void* GetDisplay() OVERRIDE;
140 virtual void* GetConfig() OVERRIDE;
141 virtual unsigned GetFormat() OVERRIDE;
142
143 GLSurface* surface() const { return surface_.get(); }
144
145 protected:
146 virtual ~GLSurfaceAdapter();
147
148 private:
149 scoped_refptr<GLSurface> surface_;
150 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter);
151 };
152
153 } // namespace gfx
154
155 #endif // UI_GFX_GL_GL_SURFACE_H_
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_share_group.cc ('k') | ui/gfx/gl/gl_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698