| 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 #include "gpu/command_buffer/client/gl_in_process_context.h" | 5 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const unsigned int kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; | 43 const unsigned int kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
| 44 | 44 |
| 45 class GLInProcessContextImpl | 45 class GLInProcessContextImpl |
| 46 : public GLInProcessContext, | 46 : public GLInProcessContext, |
| 47 public base::SupportsWeakPtr<GLInProcessContextImpl> { | 47 public base::SupportsWeakPtr<GLInProcessContextImpl> { |
| 48 public: | 48 public: |
| 49 explicit GLInProcessContextImpl( | 49 explicit GLInProcessContextImpl( |
| 50 const GLInProcessContextSharedMemoryLimits& mem_limits); | 50 const GLInProcessContextSharedMemoryLimits& mem_limits); |
| 51 ~GLInProcessContextImpl() override; | 51 ~GLInProcessContextImpl() override; |
| 52 | 52 |
| 53 bool Initialize( | 53 bool Initialize(scoped_refptr<gfx::GLSurface> surface, |
| 54 scoped_refptr<gfx::GLSurface> surface, | 54 bool is_offscreen, |
| 55 bool is_offscreen, | 55 bool use_global_share_group, |
| 56 bool use_global_share_group, | 56 GLInProcessContext* share_context, |
| 57 GLInProcessContext* share_context, | 57 gfx::AcceleratedWidget window, |
| 58 gfx::AcceleratedWidget window, | 58 const gfx::Size& size, |
| 59 const gfx::Size& size, | 59 const gpu::gles2::ContextCreationAttribHelper& attribs, |
| 60 const gpu::gles2::ContextCreationAttribHelper& attribs, | 60 gfx::GpuPreference gpu_preference, |
| 61 gfx::GpuPreference gpu_preference, | 61 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 62 const scoped_refptr<InProcessCommandBuffer::Service>& service); | 62 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 63 ImageFactory* image_factory); |
| 63 | 64 |
| 64 // GLInProcessContext implementation: | 65 // GLInProcessContext implementation: |
| 65 void SetContextLostCallback(const base::Closure& callback) override; | 66 void SetContextLostCallback(const base::Closure& callback) override; |
| 66 gles2::GLES2Implementation* GetImplementation() override; | 67 gles2::GLES2Implementation* GetImplementation() override; |
| 67 size_t GetMappedMemoryLimit() override; | 68 size_t GetMappedMemoryLimit() override; |
| 68 | 69 |
| 69 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
| 70 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( | 71 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( |
| 71 uint32 stream_id) override; | 72 uint32 stream_id) override; |
| 72 #endif | 73 #endif |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 bool GLInProcessContextImpl::Initialize( | 130 bool GLInProcessContextImpl::Initialize( |
| 130 scoped_refptr<gfx::GLSurface> surface, | 131 scoped_refptr<gfx::GLSurface> surface, |
| 131 bool is_offscreen, | 132 bool is_offscreen, |
| 132 bool use_global_share_group, | 133 bool use_global_share_group, |
| 133 GLInProcessContext* share_context, | 134 GLInProcessContext* share_context, |
| 134 gfx::AcceleratedWidget window, | 135 gfx::AcceleratedWidget window, |
| 135 const gfx::Size& size, | 136 const gfx::Size& size, |
| 136 const gles2::ContextCreationAttribHelper& attribs, | 137 const gles2::ContextCreationAttribHelper& attribs, |
| 137 gfx::GpuPreference gpu_preference, | 138 gfx::GpuPreference gpu_preference, |
| 138 const scoped_refptr<InProcessCommandBuffer::Service>& service) { | 139 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 140 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 141 ImageFactory* image_factory) { |
| 139 DCHECK(!use_global_share_group || !share_context); | 142 DCHECK(!use_global_share_group || !share_context); |
| 140 DCHECK(size.width() >= 0 && size.height() >= 0); | 143 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 141 | 144 |
| 142 std::vector<int32> attrib_vector; | 145 std::vector<int32> attrib_vector; |
| 143 attribs.Serialize(&attrib_vector); | 146 attribs.Serialize(&attrib_vector); |
| 144 | 147 |
| 145 base::Closure wrapped_callback = | 148 base::Closure wrapped_callback = |
| 146 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); | 149 base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); |
| 147 command_buffer_.reset(new InProcessCommandBuffer(service)); | 150 command_buffer_.reset(new InProcessCommandBuffer(service)); |
| 148 | 151 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 174 DCHECK(share_command_buffer); | 177 DCHECK(share_command_buffer); |
| 175 } | 178 } |
| 176 | 179 |
| 177 if (!command_buffer_->Initialize(surface, | 180 if (!command_buffer_->Initialize(surface, |
| 178 is_offscreen, | 181 is_offscreen, |
| 179 window, | 182 window, |
| 180 size, | 183 size, |
| 181 attrib_vector, | 184 attrib_vector, |
| 182 gpu_preference, | 185 gpu_preference, |
| 183 wrapped_callback, | 186 wrapped_callback, |
| 184 share_command_buffer)) { | 187 share_command_buffer, |
| 188 gpu_memory_buffer_manager, |
| 189 image_factory)) { |
| 185 LOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; | 190 LOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; |
| 186 return false; | 191 return false; |
| 187 } | 192 } |
| 188 | 193 |
| 189 // Create the GLES2 helper, which writes the command buffer protocol. | 194 // Create the GLES2 helper, which writes the command buffer protocol. |
| 190 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); | 195 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); |
| 191 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) { | 196 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) { |
| 192 LOG(ERROR) << "Failed to initialize GLES2CmdHelper"; | 197 LOG(ERROR) << "Failed to initialize GLES2CmdHelper"; |
| 193 Destroy(); | 198 Destroy(); |
| 194 return false; | 199 return false; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 GLInProcessContext* GLInProcessContext::Create( | 269 GLInProcessContext* GLInProcessContext::Create( |
| 265 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 270 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 266 scoped_refptr<gfx::GLSurface> surface, | 271 scoped_refptr<gfx::GLSurface> surface, |
| 267 bool is_offscreen, | 272 bool is_offscreen, |
| 268 gfx::AcceleratedWidget window, | 273 gfx::AcceleratedWidget window, |
| 269 const gfx::Size& size, | 274 const gfx::Size& size, |
| 270 GLInProcessContext* share_context, | 275 GLInProcessContext* share_context, |
| 271 bool use_global_share_group, | 276 bool use_global_share_group, |
| 272 const ::gpu::gles2::ContextCreationAttribHelper& attribs, | 277 const ::gpu::gles2::ContextCreationAttribHelper& attribs, |
| 273 gfx::GpuPreference gpu_preference, | 278 gfx::GpuPreference gpu_preference, |
| 274 const GLInProcessContextSharedMemoryLimits& memory_limits) { | 279 const GLInProcessContextSharedMemoryLimits& memory_limits, |
| 280 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 281 ImageFactory* image_factory) { |
| 275 DCHECK(!use_global_share_group || !share_context); | 282 DCHECK(!use_global_share_group || !share_context); |
| 276 if (surface.get()) { | 283 if (surface.get()) { |
| 277 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); | 284 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); |
| 278 DCHECK(surface->GetSize() == size); | 285 DCHECK(surface->GetSize() == size); |
| 279 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); | 286 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); |
| 280 } | 287 } |
| 281 | 288 |
| 282 scoped_ptr<GLInProcessContextImpl> context( | 289 scoped_ptr<GLInProcessContextImpl> context( |
| 283 new GLInProcessContextImpl(memory_limits)); | 290 new GLInProcessContextImpl(memory_limits)); |
| 284 if (!context->Initialize(surface, | 291 if (!context->Initialize(surface, |
| 285 is_offscreen, | 292 is_offscreen, |
| 286 use_global_share_group, | 293 use_global_share_group, |
| 287 share_context, | 294 share_context, |
| 288 window, | 295 window, |
| 289 size, | 296 size, |
| 290 attribs, | 297 attribs, |
| 291 gpu_preference, | 298 gpu_preference, |
| 292 service)) | 299 service, |
| 300 gpu_memory_buffer_manager, |
| 301 image_factory)) |
| 293 return NULL; | 302 return NULL; |
| 294 | 303 |
| 295 return context.release(); | 304 return context.release(); |
| 296 } | 305 } |
| 297 | 306 |
| 298 } // namespace gpu | 307 } // namespace gpu |
| OLD | NEW |