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 "content/browser/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 base::WaitableEvent event; | 36 base::WaitableEvent event; |
| 37 int gpu_host_id; | 37 int gpu_host_id; |
| 38 int32 route_id; | 38 int32 route_id; |
| 39 CreateCommandBufferResult result; | 39 CreateCommandBufferResult result; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 struct BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferRequest { | 42 struct BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferRequest { |
| 43 AllocateGpuMemoryBufferRequest(size_t width, | 43 AllocateGpuMemoryBufferRequest(size_t width, |
| 44 size_t height, | 44 size_t height, |
| 45 unsigned internalformat, | 45 unsigned internalformat, |
| 46 unsigned usage) | 46 unsigned usage, |
| 47 int gpu_client_id) | |
| 47 : event(true, false), | 48 : event(true, false), |
| 48 width(width), | 49 width(width), |
| 49 height(height), | 50 height(height), |
| 50 internalformat(internalformat), | 51 internalformat(internalformat), |
| 51 usage(usage) {} | 52 usage(usage), |
| 53 gpu_client_id(gpu_client_id) {} | |
| 52 ~AllocateGpuMemoryBufferRequest() {} | 54 ~AllocateGpuMemoryBufferRequest() {} |
| 53 base::WaitableEvent event; | 55 base::WaitableEvent event; |
| 54 size_t width; | 56 size_t width; |
| 55 size_t height; | 57 size_t height; |
| 56 unsigned internalformat; | 58 unsigned internalformat; |
| 57 unsigned usage; | 59 unsigned usage; |
| 60 int gpu_client_id; | |
|
reveman
2014/09/10 16:10:13
nit: s/gpu_client_id/client_id/
| |
| 58 scoped_ptr<gfx::GpuMemoryBuffer> result; | 61 scoped_ptr<gfx::GpuMemoryBuffer> result; |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 class BrowserGpuChannelHostFactory::EstablishRequest | 64 class BrowserGpuChannelHostFactory::EstablishRequest |
| 62 : public base::RefCountedThreadSafe<EstablishRequest> { | 65 : public base::RefCountedThreadSafe<EstablishRequest> { |
| 63 public: | 66 public: |
| 64 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause, | 67 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause, |
| 65 int gpu_client_id, | 68 int gpu_client_id, |
| 66 int gpu_host_id); | 69 int gpu_host_id); |
| 67 void Wait(); | 70 void Wait(); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 established_callbacks_.clear(); | 383 established_callbacks_.clear(); |
| 381 } | 384 } |
| 382 | 385 |
| 383 scoped_ptr<gfx::GpuMemoryBuffer> | 386 scoped_ptr<gfx::GpuMemoryBuffer> |
| 384 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width, | 387 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width, |
| 385 size_t height, | 388 size_t height, |
| 386 unsigned internalformat, | 389 unsigned internalformat, |
| 387 unsigned usage) { | 390 unsigned usage) { |
| 388 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 391 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 389 | 392 |
| 390 AllocateGpuMemoryBufferRequest request(width, height, internalformat, usage); | 393 AllocateGpuMemoryBufferRequest request( |
| 394 width, height, internalformat, usage, gpu_client_id_); | |
| 391 GetIOLoopProxy()->PostTask( | 395 GetIOLoopProxy()->PostTask( |
| 392 FROM_HERE, | 396 FROM_HERE, |
| 393 base::Bind(&BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO, | 397 base::Bind(&BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO, |
| 394 base::Unretained(&request))); | 398 base::Unretained(&request))); |
| 395 | 399 |
| 396 // We're blocking the UI thread, which is generally undesirable. | 400 // We're blocking the UI thread, which is generally undesirable. |
| 397 TRACE_EVENT0("browser", | 401 TRACE_EVENT0("browser", |
| 398 "BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer"); | 402 "BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer"); |
| 399 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 403 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 400 request.event.Wait(); | 404 request.event.Wait(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 !GpuMemoryBufferImpl::IsUsageValid(request->usage)) { | 456 !GpuMemoryBufferImpl::IsUsageValid(request->usage)) { |
| 453 request->result = scoped_ptr<gfx::GpuMemoryBuffer>(); | 457 request->result = scoped_ptr<gfx::GpuMemoryBuffer>(); |
| 454 request->event.Signal(); | 458 request->event.Signal(); |
| 455 return; | 459 return; |
| 456 } | 460 } |
| 457 | 461 |
| 458 GpuMemoryBufferImpl::Create( | 462 GpuMemoryBufferImpl::Create( |
| 459 gfx::Size(request->width, request->height), | 463 gfx::Size(request->width, request->height), |
| 460 request->internalformat, | 464 request->internalformat, |
| 461 request->usage, | 465 request->usage, |
| 466 request->gpu_client_id, | |
| 462 base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, | 467 base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, |
| 463 base::Unretained(request))); | 468 base::Unretained(request))); |
| 464 } | 469 } |
| 465 | 470 |
| 466 // static | 471 // static |
| 467 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO( | 472 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO( |
| 468 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { | 473 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { |
| 469 } | 474 } |
| 470 | 475 |
| 471 // static | 476 // static |
| 472 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( | 477 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( |
| 473 AllocateGpuMemoryBufferRequest* request, | 478 AllocateGpuMemoryBufferRequest* request, |
| 474 scoped_ptr<GpuMemoryBufferImpl> buffer) { | 479 scoped_ptr<GpuMemoryBufferImpl> buffer) { |
| 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 476 | 481 |
| 477 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); | 482 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); |
| 478 request->event.Signal(); | 483 request->event.Signal(); |
| 479 } | 484 } |
| 480 | 485 |
| 481 } // namespace content | 486 } // namespace content |
| OLD | NEW |