| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/common/gpu/client/command_buffer_metrics.h" | 20 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 21 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 21 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 22 #include "gpu/blink/webgraphicscontext3d_impl.h" | 22 #include "gpu/blink/webgraphicscontext3d_impl.h" |
| 23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 23 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
| 26 #include "ui/gl/gpu_preference.h" | 26 #include "ui/gl/gpu_preference.h" |
| 27 #include "url/gurl.h" | |
| 28 | 27 |
| 29 namespace gpu { | 28 namespace gpu { |
| 30 | 29 |
| 31 class ContextSupport; | 30 class ContextSupport; |
| 32 class TransferBuffer; | 31 class TransferBuffer; |
| 33 | 32 |
| 34 namespace gles2 { | 33 namespace gles2 { |
| 35 class GLES2CmdHelper; | 34 class GLES2CmdHelper; |
| 36 class GLES2Implementation; | 35 class GLES2Implementation; |
| 37 class GLES2Interface; | 36 class GLES2Interface; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 virtual ~ShareGroup(); | 101 virtual ~ShareGroup(); |
| 103 | 102 |
| 104 std::vector<WebGraphicsContext3DCommandBufferImpl*> contexts_; | 103 std::vector<WebGraphicsContext3DCommandBufferImpl*> contexts_; |
| 105 base::Lock lock_; | 104 base::Lock lock_; |
| 106 | 105 |
| 107 DISALLOW_COPY_AND_ASSIGN(ShareGroup); | 106 DISALLOW_COPY_AND_ASSIGN(ShareGroup); |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 WebGraphicsContext3DCommandBufferImpl( | 109 WebGraphicsContext3DCommandBufferImpl( |
| 111 int surface_id, | 110 int surface_id, |
| 112 const GURL& active_url, | 111 const std::string& active_url, |
| 113 GpuChannelHost* host, | 112 GpuChannelHost* host, |
| 114 const Attributes& attributes, | 113 const Attributes& attributes, |
| 115 bool lose_context_when_out_of_memory, | 114 bool lose_context_when_out_of_memory, |
| 116 const SharedMemoryLimits& limits, | 115 const SharedMemoryLimits& limits, |
| 117 WebGraphicsContext3DCommandBufferImpl* share_context); | 116 WebGraphicsContext3DCommandBufferImpl* share_context); |
| 118 | 117 |
| 119 ~WebGraphicsContext3DCommandBufferImpl() override; | 118 ~WebGraphicsContext3DCommandBufferImpl() override; |
| 120 | 119 |
| 121 CommandBufferProxyImpl* GetCommandBufferProxy() { | 120 CommandBufferProxyImpl* GetCommandBufferProxy() { |
| 122 return command_buffer_.get(); | 121 return command_buffer_.get(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport(); | 124 CONTENT_EXPORT gpu::ContextSupport* GetContextSupport(); |
| 126 | 125 |
| 127 gpu::gles2::GLES2Implementation* GetImplementation() { | 126 gpu::gles2::GLES2Implementation* GetImplementation() { |
| 128 return real_gl_.get(); | 127 return real_gl_.get(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 // Return true if GPU process reported context lost or there was a | 130 // Return true if GPU process reported context lost or there was a |
| 132 // problem communicating with the GPU process. | 131 // problem communicating with the GPU process. |
| 133 bool IsCommandBufferContextLost(); | 132 bool IsCommandBufferContextLost(); |
| 134 | 133 |
| 135 // Create & initialize a WebGraphicsContext3DCommandBufferImpl. Return NULL | 134 // Create & initialize a WebGraphicsContext3DCommandBufferImpl. Return NULL |
| 136 // on any failure. | 135 // on any failure. |
| 137 static CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl* | 136 static CONTENT_EXPORT WebGraphicsContext3DCommandBufferImpl* |
| 138 CreateOffscreenContext( | 137 CreateOffscreenContext(GpuChannelHost* host, |
| 139 GpuChannelHost* host, | 138 const WebGraphicsContext3D::Attributes& attributes, |
| 140 const WebGraphicsContext3D::Attributes& attributes, | 139 bool lose_context_when_out_of_memory, |
| 141 bool lose_context_when_out_of_memory, | 140 const std::string& active_url, |
| 142 const GURL& active_url, | 141 const SharedMemoryLimits& limits, |
| 143 const SharedMemoryLimits& limits, | 142 WebGraphicsContext3DCommandBufferImpl* share_context); |
| 144 WebGraphicsContext3DCommandBufferImpl* share_context); | |
| 145 | 143 |
| 146 size_t GetMappedMemoryLimit() { | 144 size_t GetMappedMemoryLimit() { |
| 147 return mem_limits_.mapped_memory_reclaim_limit; | 145 return mem_limits_.mapped_memory_reclaim_limit; |
| 148 } | 146 } |
| 149 | 147 |
| 150 CONTENT_EXPORT bool InitializeOnCurrentThread(); | 148 CONTENT_EXPORT bool InitializeOnCurrentThread(); |
| 151 | 149 |
| 152 void SetContextType(CommandBufferContextType type) { | 150 void SetContextType(CommandBufferContextType type) { |
| 153 context_type_ = type; | 151 context_type_ = type; |
| 154 } | 152 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 virtual void OnContextLost(); | 187 virtual void OnContextLost(); |
| 190 | 188 |
| 191 bool lose_context_when_out_of_memory_; | 189 bool lose_context_when_out_of_memory_; |
| 192 blink::WebGraphicsContext3D::Attributes attributes_; | 190 blink::WebGraphicsContext3D::Attributes attributes_; |
| 193 | 191 |
| 194 bool visible_; | 192 bool visible_; |
| 195 | 193 |
| 196 // State needed by MaybeInitializeGL. | 194 // State needed by MaybeInitializeGL. |
| 197 scoped_refptr<GpuChannelHost> host_; | 195 scoped_refptr<GpuChannelHost> host_; |
| 198 int32_t surface_id_; | 196 int32_t surface_id_; |
| 199 GURL active_url_; | 197 std::string active_url_; |
| 200 CommandBufferContextType context_type_; | 198 CommandBufferContextType context_type_; |
| 201 | 199 |
| 202 gfx::GpuPreference gpu_preference_; | 200 gfx::GpuPreference gpu_preference_; |
| 203 | 201 |
| 204 scoped_ptr<CommandBufferProxyImpl> command_buffer_; | 202 scoped_ptr<CommandBufferProxyImpl> command_buffer_; |
| 205 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 203 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
| 206 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | 204 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
| 207 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; | 205 scoped_ptr<gpu::gles2::GLES2Implementation> real_gl_; |
| 208 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; | 206 scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_; |
| 209 SharedMemoryLimits mem_limits_; | 207 SharedMemoryLimits mem_limits_; |
| 210 scoped_refptr<ShareGroup> share_group_; | 208 scoped_refptr<ShareGroup> share_group_; |
| 211 | 209 |
| 212 // Member variables should appear before the WeakPtrFactory, to ensure | 210 // Member variables should appear before the WeakPtrFactory, to ensure |
| 213 // that any WeakPtrs to Controller are invalidated before its members | 211 // that any WeakPtrs to Controller are invalidated before its members |
| 214 // variable's destructors are executed, rendering them invalid. | 212 // variable's destructors are executed, rendering them invalid. |
| 215 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; | 213 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; |
| 216 }; | 214 }; |
| 217 | 215 |
| 218 } // namespace content | 216 } // namespace content |
| 219 | 217 |
| 220 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 218 #endif // CONTENT_COMMON_GPU_CLIENT_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
| OLD | NEW |