OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // allocate both fake PluginWindowHandles and NativeViewIds and map | 93 // allocate both fake PluginWindowHandles and NativeViewIds and map |
94 // from fake NativeViewIds to PluginWindowHandles, but this seems like | 94 // from fake NativeViewIds to PluginWindowHandles, but this seems like |
95 // unnecessary complexity at the moment. | 95 // unnecessary complexity at the moment. |
96 // | 96 // |
97 // The render_view_id is currently also only used on Mac OS X. | 97 // 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 | 98 // TODO(kbr): clean up the arguments to this function and make them |
99 // more cross-platform. | 99 // more cross-platform. |
100 static RendererGLContext* CreateViewContext( | 100 static RendererGLContext* CreateViewContext( |
101 GpuChannelHost* channel, | 101 GpuChannelHost* channel, |
102 int render_view_id, | 102 int render_view_id, |
| 103 bool share_resources, |
103 RendererGLContext* share_group, | 104 RendererGLContext* share_group, |
104 const char* allowed_extensions, | 105 const char* allowed_extensions, |
105 const int32* attrib_list, | 106 const int32* attrib_list, |
106 const GURL& active_arl); | 107 const GURL& active_arl); |
107 | 108 |
108 #if defined(OS_MACOSX) | 109 #if defined(OS_MACOSX) |
109 // On Mac OS X only, view RendererGLContexts actually behave like offscreen | 110 // On Mac OS X only, view RendererGLContexts actually behave like offscreen |
110 // RendererGLContexts, and require an explicit resize operation which is | 111 // RendererGLContexts, and require an explicit resize operation which is |
111 // slightly different from that of offscreen RendererGLContexts. | 112 // slightly different from that of offscreen RendererGLContexts. |
112 void ResizeOnscreen(const gfx::Size& size); | 113 void ResizeOnscreen(const gfx::Size& size); |
113 #endif | 114 #endif |
114 | 115 |
115 // Create a RendererGLContext that renders to an offscreen frame buffer. If | 116 // Create a RendererGLContext that renders to an offscreen frame buffer. If |
116 // parent is not NULL, that RendererGLContext can access a copy of the created | 117 // parent is not NULL, that RendererGLContext can access a copy of the created |
117 // RendererGLContext's frame buffer that is updated every time SwapBuffers is | 118 // RendererGLContext's frame buffer that is updated every time SwapBuffers is |
118 // called. It is not as general as shared RendererGLContexts in other | 119 // called. It is not as general as shared RendererGLContexts in other |
119 // implementations of OpenGL. If parent is not NULL, it must be used on the | 120 // implementations of OpenGL. If parent is not NULL, it must be used on the |
120 // same thread as the parent. A child RendererGLContext may not outlive its | 121 // same thread as the parent. A child RendererGLContext may not outlive its |
121 // parent. attrib_list must be NULL or a NONE-terminated list of | 122 // parent. attrib_list must be NULL or a NONE-terminated list of |
122 // attribute/value pairs. | 123 // attribute/value pairs. |
123 static RendererGLContext* CreateOffscreenContext( | 124 static RendererGLContext* CreateOffscreenContext( |
124 GpuChannelHost* channel, | 125 GpuChannelHost* channel, |
125 const gfx::Size& size, | 126 const gfx::Size& size, |
| 127 bool share_resources, |
126 RendererGLContext* share_group, | 128 RendererGLContext* share_group, |
127 const char* allowed_extensions, | 129 const char* allowed_extensions, |
128 const int32* attrib_list, | 130 const int32* attrib_list, |
129 const GURL& active_url); | 131 const GURL& active_url); |
130 | 132 |
131 // Sets the parent context. If any parent textures have been created for | 133 // Sets the parent context. If any parent textures have been created for |
132 // another parent, it is important to delete them before changing the parent. | 134 // another parent, it is important to delete them before changing the parent. |
133 bool SetParent(RendererGLContext* parent); | 135 bool SetParent(RendererGLContext* parent); |
134 | 136 |
135 // Resize an offscreen frame buffer. The resize occurs on the next call to | 137 // 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 Loading... |
184 bool IsCommandBufferContextLost(); | 186 bool IsCommandBufferContextLost(); |
185 | 187 |
186 CommandBufferProxy* GetCommandBufferProxy(); | 188 CommandBufferProxy* GetCommandBufferProxy(); |
187 | 189 |
188 private: | 190 private: |
189 explicit RendererGLContext(GpuChannelHost* channel); | 191 explicit RendererGLContext(GpuChannelHost* channel); |
190 | 192 |
191 bool Initialize(bool onscreen, | 193 bool Initialize(bool onscreen, |
192 int render_view_id, | 194 int render_view_id, |
193 const gfx::Size& size, | 195 const gfx::Size& size, |
| 196 bool share_resources, |
194 RendererGLContext* share_group, | 197 RendererGLContext* share_group, |
195 const char* allowed_extensions, | 198 const char* allowed_extensions, |
196 const int32* attrib_list, | 199 const int32* attrib_list, |
197 const GURL& active_url); | 200 const GURL& active_url); |
198 void Destroy(); | 201 void Destroy(); |
199 | 202 |
200 void OnSwapBuffers(); | 203 void OnSwapBuffers(); |
201 void OnContextLost(); | 204 void OnContextLost(); |
202 | 205 |
203 scoped_refptr<GpuChannelHost> channel_; | 206 scoped_refptr<GpuChannelHost> channel_; |
204 base::WeakPtr<RendererGLContext> parent_; | 207 base::WeakPtr<RendererGLContext> parent_; |
205 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 208 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
206 scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; | 209 scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; |
207 uint32 parent_texture_id_; | 210 uint32 parent_texture_id_; |
208 CommandBufferProxy* command_buffer_; | 211 CommandBufferProxy* command_buffer_; |
209 gpu::gles2::GLES2CmdHelper* gles2_helper_; | 212 gpu::gles2::GLES2CmdHelper* gles2_helper_; |
210 int32 transfer_buffer_id_; | 213 int32 transfer_buffer_id_; |
211 gpu::gles2::GLES2Implementation* gles2_implementation_; | 214 gpu::gles2::GLES2Implementation* gles2_implementation_; |
212 gfx::Size size_; | 215 gfx::Size size_; |
213 Error last_error_; | 216 Error last_error_; |
214 int frame_number_; | 217 int frame_number_; |
215 | 218 |
216 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); | 219 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); |
217 }; | 220 }; |
218 | 221 |
219 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 222 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
OLD | NEW |