OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 *requires_sync_point = true; | 233 *requires_sync_point = true; |
234 return source_handle; | 234 return source_handle; |
235 default: | 235 default: |
236 NOTREACHED(); | 236 NOTREACHED(); |
237 return gfx::GpuMemoryBufferHandle(); | 237 return gfx::GpuMemoryBufferHandle(); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 } // anonyous namespace | 241 } // anonyous namespace |
242 | 242 |
| 243 |
| 244 InProcessCommandBuffer:: |
| 245 InitializeOnGpuThreadParams::InitializeOnGpuThreadParams( |
| 246 bool is_offscreen, |
| 247 gfx::AcceleratedWidget window, |
| 248 const gfx::Size& size, |
| 249 const std::vector<int32>& attribs, |
| 250 gfx::GpuPreference gpu_preference, |
| 251 gpu::Capabilities* capabilities, |
| 252 InProcessCommandBuffer* share_group, |
| 253 ImageFactory* image_factory, |
| 254 const gfx::SurfaceConfiguration& requested_configuration) |
| 255 : is_offscreen(is_offscreen), |
| 256 window(window), |
| 257 size(size), |
| 258 attribs(attribs), |
| 259 gpu_preference(gpu_preference), |
| 260 capabilities(capabilities), |
| 261 context_group(share_group), |
| 262 image_factory(image_factory), |
| 263 requested_configuration(requested_configuration) { |
| 264 } |
| 265 |
| 266 |
243 InProcessCommandBuffer::Service::Service() {} | 267 InProcessCommandBuffer::Service::Service() {} |
244 | 268 |
245 InProcessCommandBuffer::Service::~Service() {} | 269 InProcessCommandBuffer::Service::~Service() {} |
246 | 270 |
247 scoped_refptr<gfx::GLShareGroup> | 271 scoped_refptr<gfx::GLShareGroup> |
248 InProcessCommandBuffer::Service::share_group() { | 272 InProcessCommandBuffer::Service::share_group() { |
249 if (!share_group_.get()) | 273 if (!share_group_.get()) |
250 share_group_ = new gfx::GLShareGroup; | 274 share_group_ = new gfx::GLShareGroup; |
251 return share_group_; | 275 return share_group_; |
252 } | 276 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 bool InProcessCommandBuffer::Initialize( | 360 bool InProcessCommandBuffer::Initialize( |
337 scoped_refptr<gfx::GLSurface> surface, | 361 scoped_refptr<gfx::GLSurface> surface, |
338 bool is_offscreen, | 362 bool is_offscreen, |
339 gfx::AcceleratedWidget window, | 363 gfx::AcceleratedWidget window, |
340 const gfx::Size& size, | 364 const gfx::Size& size, |
341 const std::vector<int32>& attribs, | 365 const std::vector<int32>& attribs, |
342 gfx::GpuPreference gpu_preference, | 366 gfx::GpuPreference gpu_preference, |
343 const base::Closure& context_lost_callback, | 367 const base::Closure& context_lost_callback, |
344 InProcessCommandBuffer* share_group, | 368 InProcessCommandBuffer* share_group, |
345 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 369 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
346 ImageFactory* image_factory) { | 370 ImageFactory* image_factory, |
| 371 const gfx::SurfaceConfiguration& requested_configuration) { |
347 DCHECK(!share_group || service_.get() == share_group->service_.get()); | 372 DCHECK(!share_group || service_.get() == share_group->service_.get()); |
348 context_lost_callback_ = WrapCallback(context_lost_callback); | 373 context_lost_callback_ = WrapCallback(context_lost_callback); |
349 | 374 |
350 if (surface.get()) { | 375 if (surface.get()) { |
351 // GPU thread must be the same as client thread due to GLSurface not being | 376 // GPU thread must be the same as client thread due to GLSurface not being |
352 // thread safe. | 377 // thread safe. |
353 sequence_checker_.reset(new base::SequenceChecker); | 378 sequence_checker_.reset(new base::SequenceChecker); |
354 surface_ = surface; | 379 surface_ = surface; |
355 } | 380 } |
356 | 381 |
357 gpu::Capabilities capabilities; | 382 gpu::Capabilities capabilities; |
358 InitializeOnGpuThreadParams params(is_offscreen, | 383 InitializeOnGpuThreadParams params(is_offscreen, |
359 window, | 384 window, |
360 size, | 385 size, |
361 attribs, | 386 attribs, |
362 gpu_preference, | 387 gpu_preference, |
363 &capabilities, | 388 &capabilities, |
364 share_group, | 389 share_group, |
365 image_factory); | 390 image_factory, |
| 391 requested_configuration); |
366 | 392 |
367 base::Callback<bool(void)> init_task = | 393 base::Callback<bool(void)> init_task = |
368 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread, | 394 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread, |
369 base::Unretained(this), | 395 base::Unretained(this), |
370 params); | 396 params); |
371 | 397 |
372 base::WaitableEvent completion(true, false); | 398 base::WaitableEvent completion(true, false); |
373 bool result = false; | 399 bool result = false; |
374 QueueTask( | 400 QueueTask( |
375 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion)); | 401 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 gpu_scheduler_.reset( | 458 gpu_scheduler_.reset( |
433 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get())); | 459 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get())); |
434 command_buffer->SetGetBufferChangeCallback(base::Bind( | 460 command_buffer->SetGetBufferChangeCallback(base::Bind( |
435 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); | 461 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); |
436 command_buffer_ = command_buffer.Pass(); | 462 command_buffer_ = command_buffer.Pass(); |
437 | 463 |
438 decoder_->set_engine(gpu_scheduler_.get()); | 464 decoder_->set_engine(gpu_scheduler_.get()); |
439 | 465 |
440 if (!surface_.get()) { | 466 if (!surface_.get()) { |
441 if (params.is_offscreen) | 467 if (params.is_offscreen) |
442 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(params.size); | 468 surface_ = gfx::GLSurface::CreateOffscreenGLSurface( |
| 469 params.size, params.requested_configuration); |
443 else | 470 else |
444 surface_ = gfx::GLSurface::CreateViewGLSurface(params.window); | 471 surface_ = gfx::GLSurface::CreateViewGLSurface( |
| 472 params.window, params.requested_configuration); |
445 } | 473 } |
446 | 474 |
447 if (!surface_.get()) { | 475 if (!surface_.get()) { |
448 LOG(ERROR) << "Could not create GLSurface."; | 476 LOG(ERROR) << "Could not create GLSurface."; |
449 DestroyOnGpuThread(); | 477 DestroyOnGpuThread(); |
450 return false; | 478 return false; |
451 } | 479 } |
452 | 480 |
453 if (service_->UseVirtualizedGLContexts() || | 481 if (service_->UseVirtualizedGLContexts() || |
454 decoder_->GetContextGroup() | 482 decoder_->GetContextGroup() |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 | 989 |
962 #if defined(OS_ANDROID) | 990 #if defined(OS_ANDROID) |
963 scoped_refptr<gfx::SurfaceTexture> | 991 scoped_refptr<gfx::SurfaceTexture> |
964 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 992 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
965 DCHECK(stream_texture_manager_); | 993 DCHECK(stream_texture_manager_); |
966 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 994 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
967 } | 995 } |
968 #endif | 996 #endif |
969 | 997 |
970 } // namespace gpu | 998 } // namespace gpu |
OLD | NEW |