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

Side by Side Diff: content/renderer/gpu/renderer_gl_context.h

Issue 7669072: Use 3D graphics context shareResources flag to decide whether a context should share resources. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This API is consistent with other OpenGL setup APIs like window's WGL 5 // This API is consistent with other OpenGL setup APIs like window's WGL
6 // and pepper's PGL. This API is used to manage OpenGL RendererGLContexts in the 6 // and pepper's PGL. This API is used to manage OpenGL RendererGLContexts in the
7 // Chrome renderer process in a way that is consistent with other platforms. 7 // Chrome renderer process in a way that is consistent with other platforms.
8 8
9 #ifndef CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ 9 #ifndef CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_
10 #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ 10 #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_
(...skipping 17 matching lines...) Expand all
28 namespace gles2 { 28 namespace gles2 {
29 class GLES2CmdHelper; 29 class GLES2CmdHelper;
30 class GLES2Implementation; 30 class GLES2Implementation;
31 } 31 }
32 } 32 }
33 33
34 class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { 34 class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
35 public: 35 public:
36 // These are the same error codes as used by EGL. 36 // These are the same error codes as used by EGL.
37 enum Error { 37 enum Error {
38 SUCCESS = 0x3000, 38 SUCCESS = 0x3000,
39 NOT_INITIALIZED = 0x3001, 39 NOT_INITIALIZED = 0x3001,
40 BAD_ATTRIBUTE = 0x3004, 40 BAD_ATTRIBUTE = 0x3004,
41 BAD_RendererGLContext = 0x3006, 41 BAD_RendererGLContext = 0x3006,
42 CONTEXT_LOST = 0x300E 42 CONTEXT_LOST = 0x300E
43 }; 43 };
44 44
45 // RendererGLContext configuration attributes. These are the same as used by 45 // RendererGLContext configuration attributes. Those in the 16-bit range are
46 // EGL. Attributes are matched using a closest fit algorithm. 46 // the same as used by EGL. Those outside the 16-bit range are unique to
47 // Chromium. Attributes are matched using a closest fit algorithm.
47 enum Attribute { 48 enum Attribute {
48 ALPHA_SIZE = 0x3021, 49 ALPHA_SIZE = 0x3021,
49 BLUE_SIZE = 0x3022, 50 BLUE_SIZE = 0x3022,
50 GREEN_SIZE = 0x3023, 51 GREEN_SIZE = 0x3023,
51 RED_SIZE = 0x3024, 52 RED_SIZE = 0x3024,
52 DEPTH_SIZE = 0x3025, 53 DEPTH_SIZE = 0x3025,
53 STENCIL_SIZE = 0x3026, 54 STENCIL_SIZE = 0x3026,
54 SAMPLES = 0x3031, 55 SAMPLES = 0x3031,
55 SAMPLE_BUFFERS = 0x3032, 56 SAMPLE_BUFFERS = 0x3032,
56 HEIGHT = 0x3056, 57 HEIGHT = 0x3056,
57 WIDTH = 0x3057, 58 WIDTH = 0x3057,
58 NONE = 0x3038 // Attrib list = terminator 59 NONE = 0x3038, // Attrib list = terminator
60 SHARE_RESOURCES = 0x10000,
61 BIND_GENERATES_RESOURCES = 0x10001
59 }; 62 };
60 63
61 // Reasons that a lost context might have been provoked. 64 // Reasons that a lost context might have been provoked.
62 enum ContextLostReason { 65 enum ContextLostReason {
63 // This context definitely provoked the loss of context. 66 // This context definitely provoked the loss of context.
64 kGuilty, 67 kGuilty,
65 68
66 // This context definitely did not provoke the loss of context. 69 // This context definitely did not provoke the loss of context.
67 kInnocent, 70 kInnocent,
68 71
(...skipping 24 matching lines...) Expand all
93 // allocate both fake PluginWindowHandles and NativeViewIds and map 96 // allocate both fake PluginWindowHandles and NativeViewIds and map
94 // from fake NativeViewIds to PluginWindowHandles, but this seems like 97 // from fake NativeViewIds to PluginWindowHandles, but this seems like
95 // unnecessary complexity at the moment. 98 // unnecessary complexity at the moment.
96 // 99 //
97 // The render_view_id is currently also only used on Mac OS X. 100 // The render_view_id is currently also only used on Mac OS X.
98 // TODO(kbr): clean up the arguments to this function and make them 101 // TODO(kbr): clean up the arguments to this function and make them
99 // more cross-platform. 102 // more cross-platform.
100 static RendererGLContext* CreateViewContext( 103 static RendererGLContext* CreateViewContext(
101 GpuChannelHost* channel, 104 GpuChannelHost* channel,
102 int render_view_id, 105 int render_view_id,
103 bool share_resources,
104 RendererGLContext* share_group, 106 RendererGLContext* share_group,
105 const char* allowed_extensions, 107 const char* allowed_extensions,
106 const int32* attrib_list, 108 const int32* attrib_list,
107 const GURL& active_arl); 109 const GURL& active_arl);
108 110
109 #if defined(OS_MACOSX) 111 #if defined(OS_MACOSX)
110 // On Mac OS X only, view RendererGLContexts actually behave like offscreen 112 // On Mac OS X only, view RendererGLContexts actually behave like offscreen
111 // RendererGLContexts, and require an explicit resize operation which is 113 // RendererGLContexts, and require an explicit resize operation which is
112 // slightly different from that of offscreen RendererGLContexts. 114 // slightly different from that of offscreen RendererGLContexts.
113 void ResizeOnscreen(const gfx::Size& size); 115 void ResizeOnscreen(const gfx::Size& size);
114 #endif 116 #endif
115 117
116 // Create a RendererGLContext that renders to an offscreen frame buffer. If 118 // Create a RendererGLContext that renders to an offscreen frame buffer. If
117 // parent is not NULL, that RendererGLContext can access a copy of the created 119 // parent is not NULL, that RendererGLContext can access a copy of the created
118 // RendererGLContext's frame buffer that is updated every time SwapBuffers is 120 // RendererGLContext's frame buffer that is updated every time SwapBuffers is
119 // called. It is not as general as shared RendererGLContexts in other 121 // called. It is not as general as shared RendererGLContexts in other
120 // implementations of OpenGL. If parent is not NULL, it must be used on the 122 // implementations of OpenGL. If parent is not NULL, it must be used on the
121 // same thread as the parent. A child RendererGLContext may not outlive its 123 // same thread as the parent. A child RendererGLContext may not outlive its
122 // parent. attrib_list must be NULL or a NONE-terminated list of 124 // parent. attrib_list must be NULL or a NONE-terminated list of
123 // attribute/value pairs. 125 // attribute/value pairs.
124 static RendererGLContext* CreateOffscreenContext( 126 static RendererGLContext* CreateOffscreenContext(
125 GpuChannelHost* channel, 127 GpuChannelHost* channel,
126 const gfx::Size& size, 128 const gfx::Size& size,
127 bool share_resources,
128 RendererGLContext* share_group, 129 RendererGLContext* share_group,
129 const char* allowed_extensions, 130 const char* allowed_extensions,
130 const int32* attrib_list, 131 const int32* attrib_list,
131 const GURL& active_url); 132 const GURL& active_url);
132 133
133 // Sets the parent context. If any parent textures have been created for 134 // Sets the parent context. If any parent textures have been created for
134 // another parent, it is important to delete them before changing the parent. 135 // another parent, it is important to delete them before changing the parent.
135 bool SetParent(RendererGLContext* parent); 136 bool SetParent(RendererGLContext* parent);
136 137
137 // Resize an offscreen frame buffer. The resize occurs on the next call to 138 // Resize an offscreen frame buffer. The resize occurs on the next call to
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 bool IsCommandBufferContextLost(); 187 bool IsCommandBufferContextLost();
187 188
188 CommandBufferProxy* GetCommandBufferProxy(); 189 CommandBufferProxy* GetCommandBufferProxy();
189 190
190 private: 191 private:
191 explicit RendererGLContext(GpuChannelHost* channel); 192 explicit RendererGLContext(GpuChannelHost* channel);
192 193
193 bool Initialize(bool onscreen, 194 bool Initialize(bool onscreen,
194 int render_view_id, 195 int render_view_id,
195 const gfx::Size& size, 196 const gfx::Size& size,
196 bool share_resources,
197 bool bind_generates_resource,
198 RendererGLContext* share_group, 197 RendererGLContext* share_group,
199 const char* allowed_extensions, 198 const char* allowed_extensions,
200 const int32* attrib_list, 199 const int32* attrib_list,
201 const GURL& active_url); 200 const GURL& active_url);
202 void Destroy(); 201 void Destroy();
203 202
204 void OnSwapBuffers(); 203 void OnSwapBuffers();
205 void OnContextLost(); 204 void OnContextLost();
206 205
207 scoped_refptr<GpuChannelHost> channel_; 206 scoped_refptr<GpuChannelHost> channel_;
208 base::WeakPtr<RendererGLContext> parent_; 207 base::WeakPtr<RendererGLContext> parent_;
209 scoped_ptr<Callback0::Type> swap_buffers_callback_; 208 scoped_ptr<Callback0::Type> swap_buffers_callback_;
210 scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; 209 scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_;
211 uint32 parent_texture_id_; 210 uint32 parent_texture_id_;
212 CommandBufferProxy* command_buffer_; 211 CommandBufferProxy* command_buffer_;
213 gpu::gles2::GLES2CmdHelper* gles2_helper_; 212 gpu::gles2::GLES2CmdHelper* gles2_helper_;
214 int32 transfer_buffer_id_; 213 int32 transfer_buffer_id_;
215 gpu::gles2::GLES2Implementation* gles2_implementation_; 214 gpu::gles2::GLES2Implementation* gles2_implementation_;
216 gfx::Size size_; 215 gfx::Size size_;
217 Error last_error_; 216 Error last_error_;
218 int frame_number_; 217 int frame_number_;
219 218
220 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); 219 DISALLOW_COPY_AND_ASSIGN(RendererGLContext);
221 }; 220 };
222 221
223 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ 222 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/gpu/renderer_gl_context.cc » ('j') | content/renderer/gpu/renderer_gl_context.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698