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_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "ui/gfx/gl/gpu_preference.h" |
19 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
21 | 22 |
22 class GpuChannelHost; | 23 class GpuChannelHost; |
23 class CommandBufferProxy; | 24 class CommandBufferProxy; |
24 class GURL; | 25 class GURL; |
25 class TransportTextureHost; | 26 class TransportTextureHost; |
26 | 27 |
27 namespace gpu { | 28 namespace gpu { |
28 namespace gles2 { | 29 namespace gles2 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // | 101 // |
101 // The render_view_id is currently also only used on Mac OS X. | 102 // The render_view_id is currently also only used on Mac OS X. |
102 // TODO(kbr): clean up the arguments to this function and make them | 103 // TODO(kbr): clean up the arguments to this function and make them |
103 // more cross-platform. | 104 // more cross-platform. |
104 static RendererGLContext* CreateViewContext( | 105 static RendererGLContext* CreateViewContext( |
105 GpuChannelHost* channel, | 106 GpuChannelHost* channel, |
106 int render_view_id, | 107 int render_view_id, |
107 RendererGLContext* share_group, | 108 RendererGLContext* share_group, |
108 const char* allowed_extensions, | 109 const char* allowed_extensions, |
109 const int32* attrib_list, | 110 const int32* attrib_list, |
110 const GURL& active_arl); | 111 const GURL& active_url, |
| 112 gfx::GpuPreference gpu_preference); |
111 | 113 |
112 // Create a RendererGLContext that renders to an offscreen frame buffer. If | 114 // Create a RendererGLContext that renders to an offscreen frame buffer. If |
113 // parent is not NULL, that RendererGLContext can access a copy of the created | 115 // parent is not NULL, that RendererGLContext can access a copy of the created |
114 // RendererGLContext's frame buffer that is updated every time SwapBuffers is | 116 // RendererGLContext's frame buffer that is updated every time SwapBuffers is |
115 // called. It is not as general as shared RendererGLContexts in other | 117 // called. It is not as general as shared RendererGLContexts in other |
116 // implementations of OpenGL. If parent is not NULL, it must be used on the | 118 // implementations of OpenGL. If parent is not NULL, it must be used on the |
117 // same thread as the parent. A child RendererGLContext may not outlive its | 119 // same thread as the parent. A child RendererGLContext may not outlive its |
118 // parent. attrib_list must be NULL or a NONE-terminated list of | 120 // parent. attrib_list must be NULL or a NONE-terminated list of |
119 // attribute/value pairs. | 121 // attribute/value pairs. |
120 static RendererGLContext* CreateOffscreenContext( | 122 static RendererGLContext* CreateOffscreenContext( |
121 GpuChannelHost* channel, | 123 GpuChannelHost* channel, |
122 const gfx::Size& size, | 124 const gfx::Size& size, |
123 RendererGLContext* share_group, | 125 RendererGLContext* share_group, |
124 const char* allowed_extensions, | 126 const char* allowed_extensions, |
125 const int32* attrib_list, | 127 const int32* attrib_list, |
126 const GURL& active_url); | 128 const GURL& active_url, |
| 129 gfx::GpuPreference gpu_preference); |
127 | 130 |
128 // Sets the parent context. If any parent textures have been created for | 131 // Sets the parent context. If any parent textures have been created for |
129 // another parent, it is important to delete them before changing the parent. | 132 // another parent, it is important to delete them before changing the parent. |
130 bool SetParent(RendererGLContext* parent); | 133 bool SetParent(RendererGLContext* parent); |
131 | 134 |
132 // For an offscreen frame buffer RendererGLContext, return the texture ID with | 135 // For an offscreen frame buffer RendererGLContext, return the texture ID with |
133 // respect to the parent RendererGLContext. Returns zero if RendererGLContext | 136 // respect to the parent RendererGLContext. Returns zero if RendererGLContext |
134 // does not have a parent. | 137 // does not have a parent. |
135 uint32 GetParentTextureId(); | 138 uint32 GetParentTextureId(); |
136 | 139 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 181 |
179 private: | 182 private: |
180 explicit RendererGLContext(GpuChannelHost* channel); | 183 explicit RendererGLContext(GpuChannelHost* channel); |
181 | 184 |
182 bool Initialize(bool onscreen, | 185 bool Initialize(bool onscreen, |
183 int render_view_id, | 186 int render_view_id, |
184 const gfx::Size& size, | 187 const gfx::Size& size, |
185 RendererGLContext* share_group, | 188 RendererGLContext* share_group, |
186 const char* allowed_extensions, | 189 const char* allowed_extensions, |
187 const int32* attrib_list, | 190 const int32* attrib_list, |
188 const GURL& active_url); | 191 const GURL& active_url, |
| 192 gfx::GpuPreference gpu_preference); |
189 void Destroy(); | 193 void Destroy(); |
190 | 194 |
191 void OnContextLost(); | 195 void OnContextLost(); |
192 | 196 |
193 scoped_refptr<GpuChannelHost> channel_; | 197 scoped_refptr<GpuChannelHost> channel_; |
194 base::WeakPtr<RendererGLContext> parent_; | 198 base::WeakPtr<RendererGLContext> parent_; |
195 base::Callback<void(ContextLostReason)> context_lost_callback_; | 199 base::Callback<void(ContextLostReason)> context_lost_callback_; |
196 uint32 parent_texture_id_; | 200 uint32 parent_texture_id_; |
197 CommandBufferProxy* command_buffer_; | 201 CommandBufferProxy* command_buffer_; |
198 gpu::gles2::GLES2CmdHelper* gles2_helper_; | 202 gpu::gles2::GLES2CmdHelper* gles2_helper_; |
199 int32 transfer_buffer_id_; | 203 int32 transfer_buffer_id_; |
200 gpu::gles2::GLES2Implementation* gles2_implementation_; | 204 gpu::gles2::GLES2Implementation* gles2_implementation_; |
201 Error last_error_; | 205 Error last_error_; |
202 int frame_number_; | 206 int frame_number_; |
203 | 207 |
204 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); | 208 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); |
205 }; | 209 }; |
206 | 210 |
207 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 211 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
OLD | NEW |