| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public base::SupportsWeakPtr<GLInProcessContextImpl> { | 50 public base::SupportsWeakPtr<GLInProcessContextImpl> { |
| 51 public: | 51 public: |
| 52 explicit GLInProcessContextImpl(); | 52 explicit GLInProcessContextImpl(); |
| 53 virtual ~GLInProcessContextImpl(); | 53 virtual ~GLInProcessContextImpl(); |
| 54 | 54 |
| 55 bool Initialize(scoped_refptr<gfx::GLSurface> surface, | 55 bool Initialize(scoped_refptr<gfx::GLSurface> surface, |
| 56 bool is_offscreen, | 56 bool is_offscreen, |
| 57 bool share_resources, | 57 bool share_resources, |
| 58 gfx::AcceleratedWidget window, | 58 gfx::AcceleratedWidget window, |
| 59 const gfx::Size& size, | 59 const gfx::Size& size, |
| 60 const char* allowed_extensions, | |
| 61 const GLInProcessContextAttribs& attribs, | 60 const GLInProcessContextAttribs& attribs, |
| 62 gfx::GpuPreference gpu_preference); | 61 gfx::GpuPreference gpu_preference); |
| 63 | 62 |
| 64 // GLInProcessContext implementation: | 63 // GLInProcessContext implementation: |
| 65 virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE; | 64 virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE; |
| 66 virtual void SignalSyncPoint(unsigned sync_point, | 65 virtual void SignalSyncPoint(unsigned sync_point, |
| 67 const base::Closure& callback) OVERRIDE; | 66 const base::Closure& callback) OVERRIDE; |
| 68 virtual void SignalQuery(unsigned query, const base::Closure& callback) | 67 virtual void SignalQuery(unsigned query, const base::Closure& callback) |
| 69 OVERRIDE; | 68 OVERRIDE; |
| 70 virtual gles2::GLES2Implementation* GetImplementation() OVERRIDE; | 69 virtual gles2::GLES2Implementation* GetImplementation() OVERRIDE; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 if (!context_lost_) | 145 if (!context_lost_) |
| 147 callback.Run(); | 146 callback.Run(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 bool GLInProcessContextImpl::Initialize( | 149 bool GLInProcessContextImpl::Initialize( |
| 151 scoped_refptr<gfx::GLSurface> surface, | 150 scoped_refptr<gfx::GLSurface> surface, |
| 152 bool is_offscreen, | 151 bool is_offscreen, |
| 153 bool share_resources, | 152 bool share_resources, |
| 154 gfx::AcceleratedWidget window, | 153 gfx::AcceleratedWidget window, |
| 155 const gfx::Size& size, | 154 const gfx::Size& size, |
| 156 const char* allowed_extensions, | |
| 157 const GLInProcessContextAttribs& attribs, | 155 const GLInProcessContextAttribs& attribs, |
| 158 gfx::GpuPreference gpu_preference) { | 156 gfx::GpuPreference gpu_preference) { |
| 159 DCHECK(size.width() >= 0 && size.height() >= 0); | 157 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 160 | 158 |
| 161 const int32 ALPHA_SIZE = 0x3021; | 159 const int32 ALPHA_SIZE = 0x3021; |
| 162 const int32 BLUE_SIZE = 0x3022; | 160 const int32 BLUE_SIZE = 0x3022; |
| 163 const int32 GREEN_SIZE = 0x3023; | 161 const int32 GREEN_SIZE = 0x3023; |
| 164 const int32 RED_SIZE = 0x3024; | 162 const int32 RED_SIZE = 0x3024; |
| 165 const int32 DEPTH_SIZE = 0x3025; | 163 const int32 DEPTH_SIZE = 0x3025; |
| 166 const int32 STENCIL_SIZE = 0x3026; | 164 const int32 STENCIL_SIZE = 0x3026; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 share_group_id_ = std::max(share_group_id_, context->share_group_id_); | 224 share_group_id_ = std::max(share_group_id_, context->share_group_id_); |
| 227 } | 225 } |
| 228 if (!share_group && !++share_group_id_) | 226 if (!share_group && !++share_group_id_) |
| 229 ++share_group_id_; | 227 ++share_group_id_; |
| 230 } | 228 } |
| 231 if (!command_buffer_->Initialize(surface, | 229 if (!command_buffer_->Initialize(surface, |
| 232 is_offscreen, | 230 is_offscreen, |
| 233 share_resources, | 231 share_resources, |
| 234 window, | 232 window, |
| 235 size, | 233 size, |
| 236 allowed_extensions, | |
| 237 attrib_vector, | 234 attrib_vector, |
| 238 gpu_preference, | 235 gpu_preference, |
| 239 wrapped_callback, | 236 wrapped_callback, |
| 240 share_group_id_)) { | 237 share_group_id_)) { |
| 241 LOG(INFO) << "Failed to initialize InProcessCommmandBuffer"; | 238 LOG(INFO) << "Failed to initialize InProcessCommmandBuffer"; |
| 242 return false; | 239 return false; |
| 243 } | 240 } |
| 244 | 241 |
| 245 // Create the GLES2 helper, which writes the command buffer protocol. | 242 // Create the GLES2 helper, which writes the command buffer protocol. |
| 246 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); | 243 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 stencil_size(-1), | 357 stencil_size(-1), |
| 361 samples(-1), | 358 samples(-1), |
| 362 sample_buffers(-1) {} | 359 sample_buffers(-1) {} |
| 363 | 360 |
| 364 // static | 361 // static |
| 365 GLInProcessContext* GLInProcessContext::CreateContext( | 362 GLInProcessContext* GLInProcessContext::CreateContext( |
| 366 bool is_offscreen, | 363 bool is_offscreen, |
| 367 gfx::AcceleratedWidget window, | 364 gfx::AcceleratedWidget window, |
| 368 const gfx::Size& size, | 365 const gfx::Size& size, |
| 369 bool share_resources, | 366 bool share_resources, |
| 370 const char* allowed_extensions, | |
| 371 const GLInProcessContextAttribs& attribs, | 367 const GLInProcessContextAttribs& attribs, |
| 372 gfx::GpuPreference gpu_preference) { | 368 gfx::GpuPreference gpu_preference) { |
| 373 scoped_ptr<GLInProcessContextImpl> context( | 369 scoped_ptr<GLInProcessContextImpl> context( |
| 374 new GLInProcessContextImpl()); | 370 new GLInProcessContextImpl()); |
| 375 if (!context->Initialize( | 371 if (!context->Initialize( |
| 376 NULL /* surface */, | 372 NULL /* surface */, |
| 377 is_offscreen, | 373 is_offscreen, |
| 378 share_resources, | 374 share_resources, |
| 379 window, | 375 window, |
| 380 size, | 376 size, |
| 381 allowed_extensions, | |
| 382 attribs, | 377 attribs, |
| 383 gpu_preference)) | 378 gpu_preference)) |
| 384 return NULL; | 379 return NULL; |
| 385 | 380 |
| 386 return context.release(); | 381 return context.release(); |
| 387 } | 382 } |
| 388 | 383 |
| 389 // static | 384 // static |
| 390 GLInProcessContext* GLInProcessContext::CreateWithSurface( | 385 GLInProcessContext* GLInProcessContext::CreateWithSurface( |
| 391 scoped_refptr<gfx::GLSurface> surface, | 386 scoped_refptr<gfx::GLSurface> surface, |
| 392 bool share_resources, | 387 bool share_resources, |
| 393 const char* allowed_extensions, | |
| 394 const GLInProcessContextAttribs& attribs, | 388 const GLInProcessContextAttribs& attribs, |
| 395 gfx::GpuPreference gpu_preference) { | 389 gfx::GpuPreference gpu_preference) { |
| 396 scoped_ptr<GLInProcessContextImpl> context( | 390 scoped_ptr<GLInProcessContextImpl> context( |
| 397 new GLInProcessContextImpl()); | 391 new GLInProcessContextImpl()); |
| 398 if (!context->Initialize( | 392 if (!context->Initialize( |
| 399 surface, | 393 surface, |
| 400 surface->IsOffscreen(), | 394 surface->IsOffscreen(), |
| 401 share_resources, | 395 share_resources, |
| 402 gfx::kNullAcceleratedWidget, | 396 gfx::kNullAcceleratedWidget, |
| 403 surface->GetSize(), | 397 surface->GetSize(), |
| 404 allowed_extensions, | |
| 405 attribs, | 398 attribs, |
| 406 gpu_preference)) | 399 gpu_preference)) |
| 407 return NULL; | 400 return NULL; |
| 408 | 401 |
| 409 return context.release(); | 402 return context.release(); |
| 410 } | 403 } |
| 411 | 404 |
| 412 } // namespace gpu | 405 } // namespace gpu |
| OLD | NEW |