OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/common/gpu/client/command_buffer_metrics.h" |
16 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 17 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
17 #include "gpu/blink/webgraphicscontext3d_impl.h" | 18 #include "gpu/blink/webgraphicscontext3d_impl.h" |
18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
21 #include "ui/gl/gpu_preference.h" | 22 #include "ui/gl/gpu_preference.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace gpu { | 25 namespace gpu { |
25 | 26 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 144 } |
144 | 145 |
145 CONTENT_EXPORT bool InitializeOnCurrentThread(); | 146 CONTENT_EXPORT bool InitializeOnCurrentThread(); |
146 | 147 |
147 //---------------------------------------------------------------------- | 148 //---------------------------------------------------------------------- |
148 // WebGraphicsContext3D methods | 149 // WebGraphicsContext3D methods |
149 virtual bool isContextLost(); | 150 virtual bool isContextLost(); |
150 | 151 |
151 virtual blink::WGC3Denum getGraphicsResetStatusARB(); | 152 virtual blink::WGC3Denum getGraphicsResetStatusARB(); |
152 | 153 |
| 154 void SetContextType(CommandBufferContextType type) { |
| 155 context_type_ = type; |
| 156 } |
153 private: | 157 private: |
154 // These are the same error codes as used by EGL. | 158 // These are the same error codes as used by EGL. |
155 enum Error { | 159 enum Error { |
156 SUCCESS = 0x3000, | 160 SUCCESS = 0x3000, |
157 BAD_ATTRIBUTE = 0x3004, | 161 BAD_ATTRIBUTE = 0x3004, |
158 CONTEXT_LOST = 0x300E | 162 CONTEXT_LOST = 0x300E |
159 }; | 163 }; |
160 | 164 |
161 // Initialize the underlying GL context. May be called multiple times; second | 165 // Initialize the underlying GL context. May be called multiple times; second |
162 // and subsequent calls are ignored. Must be called from the thread that is | 166 // and subsequent calls are ignored. Must be called from the thread that is |
(...skipping 14 matching lines...) Expand all Loading... |
177 // NOTE: on Mac OS X, this entry point is only used to set up the | 181 // NOTE: on Mac OS X, this entry point is only used to set up the |
178 // accelerated compositor's output. On this platform, we actually pass | 182 // accelerated compositor's output. On this platform, we actually pass |
179 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, | 183 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, |
180 // because the facility to allocate a fake PluginWindowHandle is | 184 // because the facility to allocate a fake PluginWindowHandle is |
181 // already in place. We could add more entry points and messages to | 185 // already in place. We could add more entry points and messages to |
182 // allocate both fake PluginWindowHandles and NativeViewIds and map | 186 // allocate both fake PluginWindowHandles and NativeViewIds and map |
183 // from fake NativeViewIds to PluginWindowHandles, but this seems like | 187 // from fake NativeViewIds to PluginWindowHandles, but this seems like |
184 // unnecessary complexity at the moment. | 188 // unnecessary complexity at the moment. |
185 bool CreateContext(bool onscreen); | 189 bool CreateContext(bool onscreen); |
186 | 190 |
187 virtual void OnGpuChannelLost(); | 191 virtual void OnContextLost(); |
188 | 192 |
189 bool lose_context_when_out_of_memory_; | 193 bool lose_context_when_out_of_memory_; |
190 blink::WebGraphicsContext3D::Attributes attributes_; | 194 blink::WebGraphicsContext3D::Attributes attributes_; |
191 | 195 |
192 bool visible_; | 196 bool visible_; |
193 | 197 |
194 // State needed by MaybeInitializeGL. | 198 // State needed by MaybeInitializeGL. |
195 scoped_refptr<GpuChannelHost> host_; | 199 scoped_refptr<GpuChannelHost> host_; |
196 int32 surface_id_; | 200 int32 surface_id_; |
197 GURL active_url_; | 201 GURL active_url_; |
| 202 CommandBufferContextType context_type_; |
198 | 203 |
199 gfx::GpuPreference gpu_preference_; | 204 gfx::GpuPreference gpu_preference_; |
200 | 205 |
201 scoped_ptr<CommandBufferProxyImpl> command_buffer_; | 206 scoped_ptr<CommandBufferProxyImpl> command_buffer_; |
202 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 207 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
203 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | 208 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
204 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; | 209 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; |
205 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; | 210 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; |
206 Error last_error_; | 211 Error last_error_; |
207 SharedMemoryLimits mem_limits_; | 212 SharedMemoryLimits mem_limits_; |
208 scoped_refptr<ShareGroup> share_group_; | 213 scoped_refptr<ShareGroup> share_group_; |
209 | 214 |
210 // Member variables should appear before the WeakPtrFactory, to ensure | 215 // Member variables should appear before the WeakPtrFactory, to ensure |
211 // that any WeakPtrs to Controller are invalidated before its members | 216 // that any WeakPtrs to Controller are invalidated before its members |
212 // variable's destructors are executed, rendering them invalid. | 217 // variable's destructors are executed, rendering them invalid. |
213 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; | 218 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; |
214 }; | 219 }; |
215 | 220 |
216 } // namespace content | 221 } // namespace content |
217 | 222 |
218 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 223 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
OLD | NEW |