Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 public base::SupportsWeakPtr<GLInProcessContextImpl> { | 49 public base::SupportsWeakPtr<GLInProcessContextImpl> { |
| 50 public: | 50 public: |
| 51 explicit GLInProcessContextImpl(); | 51 explicit GLInProcessContextImpl(); |
| 52 virtual ~GLInProcessContextImpl(); | 52 virtual ~GLInProcessContextImpl(); |
| 53 | 53 |
| 54 bool Initialize( | 54 bool Initialize( |
| 55 scoped_refptr<gfx::GLSurface> surface, | 55 scoped_refptr<gfx::GLSurface> surface, |
| 56 bool is_offscreen, | 56 bool is_offscreen, |
| 57 bool use_global_share_group, | 57 bool use_global_share_group, |
| 58 GLInProcessContext* share_context, | 58 GLInProcessContext* share_context, |
| 59 gfx::AcceleratedWidget window, | |
| 60 const gfx::Size& size, | 59 const gfx::Size& size, |
| 61 const GLInProcessContextAttribs& attribs, | 60 const GLInProcessContextAttribs& attribs, |
| 62 gfx::GpuPreference gpu_preference, | 61 gfx::GpuPreference gpu_preference, |
| 63 const scoped_refptr<InProcessCommandBuffer::Service>& service); | 62 const scoped_refptr<InProcessCommandBuffer::Service>& service); |
| 64 | 63 |
| 65 // GLInProcessContext implementation: | 64 // GLInProcessContext implementation: |
| 66 virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE; | 65 virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE; |
| 67 virtual gles2::GLES2Implementation* GetImplementation() OVERRIDE; | 66 virtual gles2::GLES2Implementation* GetImplementation() OVERRIDE; |
| 68 | 67 |
| 69 #if defined(OS_ANDROID) | 68 #if defined(OS_ANDROID) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 if (!context_lost_callback_.is_null()) { | 116 if (!context_lost_callback_.is_null()) { |
| 118 context_lost_callback_.Run(); | 117 context_lost_callback_.Run(); |
| 119 } | 118 } |
| 120 } | 119 } |
| 121 | 120 |
| 122 bool GLInProcessContextImpl::Initialize( | 121 bool GLInProcessContextImpl::Initialize( |
| 123 scoped_refptr<gfx::GLSurface> surface, | 122 scoped_refptr<gfx::GLSurface> surface, |
| 124 bool is_offscreen, | 123 bool is_offscreen, |
| 125 bool use_global_share_group, | 124 bool use_global_share_group, |
| 126 GLInProcessContext* share_context, | 125 GLInProcessContext* share_context, |
| 127 gfx::AcceleratedWidget window, | |
|
boliu
2014/07/31 02:27:22
I don't think you compiled this for android. synch
hj.r.chung
2014/07/31 02:30:33
I removed it because synchronous_compositor_factor
| |
| 128 const gfx::Size& size, | 126 const gfx::Size& size, |
| 129 const GLInProcessContextAttribs& attribs, | 127 const GLInProcessContextAttribs& attribs, |
| 130 gfx::GpuPreference gpu_preference, | 128 gfx::GpuPreference gpu_preference, |
| 131 const scoped_refptr<InProcessCommandBuffer::Service>& service) { | 129 const scoped_refptr<InProcessCommandBuffer::Service>& service) { |
| 132 DCHECK(!use_global_share_group || !share_context); | 130 DCHECK(!use_global_share_group || !share_context); |
| 133 DCHECK(size.width() >= 0 && size.height() >= 0); | 131 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 134 | 132 |
| 135 // Changes to these values should also be copied to | 133 // Changes to these values should also be copied to |
| 136 // gpu/command_buffer/client/gl_in_process_context.cc and to | 134 // gpu/command_buffer/client/gl_in_process_context.cc and to |
| 137 // content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h | 135 // content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 GLInProcessContextImpl* impl = | 217 GLInProcessContextImpl* impl = |
| 220 static_cast<GLInProcessContextImpl*>(share_context); | 218 static_cast<GLInProcessContextImpl*>(share_context); |
| 221 share_group = impl->gles2_implementation_->share_group(); | 219 share_group = impl->gles2_implementation_->share_group(); |
| 222 share_command_buffer = impl->command_buffer_.get(); | 220 share_command_buffer = impl->command_buffer_.get(); |
| 223 DCHECK(share_group); | 221 DCHECK(share_group); |
| 224 DCHECK(share_command_buffer); | 222 DCHECK(share_command_buffer); |
| 225 } | 223 } |
| 226 | 224 |
| 227 if (!command_buffer_->Initialize(surface, | 225 if (!command_buffer_->Initialize(surface, |
| 228 is_offscreen, | 226 is_offscreen, |
| 229 window, | 227 gfx::kNullAcceleratedWidget, |
|
boliu
2014/07/31 02:35:32
You can clean up in in_process_command_buffer as w
hj.r.chung
2014/07/31 08:35:35
sorry for the confusion, window is still needed
| |
| 230 size, | 228 size, |
| 231 attrib_vector, | 229 attrib_vector, |
| 232 gpu_preference, | 230 gpu_preference, |
| 233 wrapped_callback, | 231 wrapped_callback, |
| 234 share_command_buffer)) { | 232 share_command_buffer)) { |
| 235 LOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; | 233 LOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; |
| 236 return false; | 234 return false; |
| 237 } | 235 } |
| 238 | 236 |
| 239 // Create the GLES2 helper, which writes the command buffer protocol. | 237 // Create the GLES2 helper, which writes the command buffer protocol. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 blue_size(-1), | 303 blue_size(-1), |
| 306 green_size(-1), | 304 green_size(-1), |
| 307 red_size(-1), | 305 red_size(-1), |
| 308 depth_size(-1), | 306 depth_size(-1), |
| 309 stencil_size(-1), | 307 stencil_size(-1), |
| 310 samples(-1), | 308 samples(-1), |
| 311 sample_buffers(-1), | 309 sample_buffers(-1), |
| 312 fail_if_major_perf_caveat(-1), | 310 fail_if_major_perf_caveat(-1), |
| 313 lose_context_when_out_of_memory(-1) {} | 311 lose_context_when_out_of_memory(-1) {} |
| 314 | 312 |
| 315 // static | |
| 316 GLInProcessContext* GLInProcessContext::CreateContext( | |
| 317 bool is_offscreen, | |
| 318 gfx::AcceleratedWidget window, | |
| 319 const gfx::Size& size, | |
| 320 bool share_resources, | |
| 321 const GLInProcessContextAttribs& attribs, | |
| 322 gfx::GpuPreference gpu_preference) { | |
| 323 scoped_ptr<GLInProcessContextImpl> context( | |
| 324 new GLInProcessContextImpl()); | |
| 325 if (!context->Initialize( | |
| 326 NULL /* surface */, | |
| 327 is_offscreen, | |
| 328 share_resources, | |
| 329 NULL, | |
| 330 window, | |
| 331 size, | |
| 332 attribs, | |
| 333 gpu_preference, | |
| 334 scoped_refptr<InProcessCommandBuffer::Service>())) | |
| 335 return NULL; | |
| 336 | |
| 337 return context.release(); | |
| 338 } | |
| 339 | |
| 340 GLInProcessContext* GLInProcessContext::Create( | 313 GLInProcessContext* GLInProcessContext::Create( |
| 341 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 314 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 342 scoped_refptr<gfx::GLSurface> surface, | 315 scoped_refptr<gfx::GLSurface> surface, |
| 343 bool is_offscreen, | 316 bool is_offscreen, |
| 344 gfx::AcceleratedWidget window, | |
| 345 const gfx::Size& size, | 317 const gfx::Size& size, |
| 346 GLInProcessContext* share_context, | 318 GLInProcessContext* share_context, |
| 347 bool use_global_share_group, | 319 bool use_global_share_group, |
| 348 const GLInProcessContextAttribs& attribs, | 320 const GLInProcessContextAttribs& attribs, |
| 349 gfx::GpuPreference gpu_preference) { | 321 gfx::GpuPreference gpu_preference) { |
| 350 DCHECK(!use_global_share_group || !share_context); | 322 DCHECK(!use_global_share_group || !share_context); |
| 351 if (surface.get()) { | 323 if (surface.get()) { |
| 352 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); | 324 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); |
| 353 DCHECK(surface->GetSize() == size); | 325 DCHECK(surface->GetSize() == size); |
| 354 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); | |
| 355 } | 326 } |
| 356 | 327 |
| 357 scoped_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl()); | 328 scoped_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl()); |
| 358 if (!context->Initialize(surface, | 329 if (!context->Initialize(surface, |
| 359 is_offscreen, | 330 is_offscreen, |
| 360 use_global_share_group, | 331 use_global_share_group, |
| 361 share_context, | 332 share_context, |
| 362 gfx::kNullAcceleratedWidget, | |
| 363 size, | 333 size, |
| 364 attribs, | 334 attribs, |
| 365 gpu_preference, | 335 gpu_preference, |
| 366 service)) | 336 service)) |
| 367 return NULL; | 337 return NULL; |
| 368 | 338 |
| 369 return context.release(); | 339 return context.release(); |
| 370 } | 340 } |
| 371 | 341 |
| 372 } // namespace gpu | 342 } // namespace gpu |
| OLD | NEW |