diff options
author | alexst <alexst@chromium.org> | 2014-12-08 12:19:08 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-08 20:19:46 +0000 |
commit | 6934562f7d5890a16186810dd1d89712fe88b135 (patch) | |
tree | c0aa724a94c757baf8a4a0dd8107fae5a064184b /content/browser/gpu | |
parent | f271a6c0399df3f40c761c3481f9887257a46dea (diff) | |
download | chromium_src-6934562f7d5890a16186810dd1d89712fe88b135.zip chromium_src-6934562f7d5890a16186810dd1d89712fe88b135.tar.gz chromium_src-6934562f7d5890a16186810dd1d89712fe88b135.tar.bz2 |
Plumb surface id to GpuMemoryBuffer allocation.
We need to know which display controller to use for allocation of scanout buffers in situations where an external USB monitor is connected.
BUG=432550
Review URL: https://codereview.chromium.org/725723002
Cr-Commit-Position: refs/heads/master@{#307317}
Diffstat (limited to 'content/browser/gpu')
-rw-r--r-- | content/browser/gpu/browser_gpu_channel_host_factory.cc | 10 | ||||
-rw-r--r-- | content/browser/gpu/browser_gpu_channel_host_factory.h | 1 | ||||
-rw-r--r-- | content/browser/gpu/browser_gpu_memory_buffer_manager.cc | 49 | ||||
-rw-r--r-- | content/browser/gpu/browser_gpu_memory_buffer_manager.h | 10 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 25 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.h | 4 |
6 files changed, 72 insertions, 27 deletions
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 99f9948..851e9e5 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -486,6 +486,7 @@ void BrowserGpuChannelHostFactory::CreateGpuMemoryBuffer( gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage, int client_id, + int32 surface_id, const CreateGpuMemoryBufferCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -499,14 +500,9 @@ void BrowserGpuChannelHostFactory::CreateGpuMemoryBuffer( create_gpu_memory_buffer_requests_[request_id] = callback; host->CreateGpuMemoryBuffer( - id, - size, - format, - usage, - client_id, + id, size, format, usage, client_id, surface_id, base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, - base::Unretained(this), - request_id)); + base::Unretained(this), request_id)); } void BrowserGpuChannelHostFactory::DestroyGpuMemoryBuffer( diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h index 84ad1ff..b482b35 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.h +++ b/content/browser/gpu/browser_gpu_channel_host_factory.h @@ -50,6 +50,7 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage, int client_id, + int32 surface_id, const CreateGpuMemoryBufferCallback& callback) override; void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index 11af884..2cfb9c8 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc @@ -29,18 +29,21 @@ struct BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferRequest { AllocateGpuMemoryBufferRequest(const gfx::Size& size, gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage, - int client_id) + int client_id, + int surface_id) : event(true, false), size(size), format(format), usage(usage), - client_id(client_id) {} + client_id(client_id), + surface_id(surface_id) {} ~AllocateGpuMemoryBufferRequest() {} base::WaitableEvent event; gfx::Size size; gfx::GpuMemoryBuffer::Format format; gfx::GpuMemoryBuffer::Usage usage; int client_id; + int surface_id; scoped_ptr<gfx::GpuMemoryBuffer> result; }; @@ -68,6 +71,25 @@ BrowserGpuMemoryBufferManager::AllocateGpuMemoryBuffer( const gfx::Size& size, gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage) { + return AllocateGpuMemoryBufferCommon(size, format, usage, 0); +} + +scoped_ptr<gfx::GpuMemoryBuffer> +BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout( + const gfx::Size& size, + gfx::GpuMemoryBuffer::Format format, + int32 surface_id) { + DCHECK_GT(surface_id, 0); + return AllocateGpuMemoryBufferCommon( + size, format, gfx::GpuMemoryBuffer::SCANOUT, surface_id); +} + +scoped_ptr<gfx::GpuMemoryBuffer> +BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferCommon( + const gfx::Size& size, + gfx::GpuMemoryBuffer::Format format, + gfx::GpuMemoryBuffer::Usage usage, + int32 surface_id) { DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); // Fallback to shared memory buffer if |format| and |usage| are not supported @@ -80,7 +102,8 @@ BrowserGpuMemoryBufferManager::AllocateGpuMemoryBuffer( g_next_gpu_memory_buffer_id.GetNext(), size, format); } - AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_); + AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, + surface_id); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, @@ -134,16 +157,10 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess( buffers[new_id] = gfx::EMPTY_BUFFER; gpu_memory_buffer_factory_host_->CreateGpuMemoryBuffer( - new_id, - size, - format, - usage, - child_client_id, + new_id, size, format, usage, child_client_id, 0, base::Bind(&BrowserGpuMemoryBufferManager:: GpuMemoryBufferAllocatedForChildProcess, - weak_ptr_factory_.GetWeakPtr(), - child_client_id, - callback)); + weak_ptr_factory_.GetWeakPtr(), child_client_id, callback)); } gfx::GpuMemoryBuffer* @@ -226,14 +243,10 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO( // Note: Unretained is safe as this is only used for synchronous allocation // from a non-IO thread. gpu_memory_buffer_factory_host_->CreateGpuMemoryBuffer( - g_next_gpu_memory_buffer_id.GetNext(), - request->size, - request->format, - request->usage, - request->client_id, + g_next_gpu_memory_buffer_id.GetNext(), request->size, request->format, + request->usage, request->client_id, request->surface_id, base::Bind(&BrowserGpuMemoryBufferManager::GpuMemoryBufferAllocatedOnIO, - base::Unretained(this), - base::Unretained(request))); + base::Unretained(this), base::Unretained(request))); } void BrowserGpuMemoryBufferManager::GpuMemoryBufferAllocatedOnIO( diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.h b/content/browser/gpu/browser_gpu_memory_buffer_manager.h index 08ab881..60815de 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.h +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.h @@ -37,6 +37,11 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, uint32 sync_point) override; + // Virtual for testing. + virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( + const gfx::Size& size, + gfx::GpuMemoryBuffer::Format format, + int32 surface_id); void AllocateGpuMemoryBufferForChildProcess( const gfx::Size& size, gfx::GpuMemoryBuffer::Format format, @@ -54,6 +59,11 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager private: struct AllocateGpuMemoryBufferRequest; + scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferCommon( + const gfx::Size& size, + gfx::GpuMemoryBuffer::Format format, + gfx::GpuMemoryBuffer::Usage usage, + int32 surface_id); void AllocateGpuMemoryBufferOnIO(AllocateGpuMemoryBufferRequest* request); void GpuMemoryBufferAllocatedOnIO(AllocateGpuMemoryBufferRequest* request, const gfx::GpuMemoryBufferHandle& handle); diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 2d04cb9..2f90e67 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -657,14 +657,28 @@ void GpuProcessHost::CreateGpuMemoryBuffer( gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage, int client_id, + int32 surface_id, const CreateGpuMemoryBufferCallback& callback) { TRACE_EVENT0("gpu", "GpuProcessHost::CreateGpuMemoryBuffer"); DCHECK(CalledOnValidThread()); - if (Send(new GpuMsg_CreateGpuMemoryBuffer( - id, size, format, usage, client_id))) { + GpuMsg_CreateGpuMemoryBuffer_Params params; + params.id = id; + params.size = size; + params.format = format; + params.usage = usage; + params.client_id = client_id; + params.surface_handle = + GpuSurfaceTracker::GetInstance()->GetSurfaceHandle(surface_id).handle; + if (Send(new GpuMsg_CreateGpuMemoryBuffer(params))) { create_gpu_memory_buffer_requests_.push(callback); + create_gpu_memory_buffer_surface_refs_.push(surface_id); + if (surface_id) { + surface_refs_.insert(std::make_pair( + surface_id, GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface( + surface_id))); + } } else { callback.Run(gfx::GpuMemoryBufferHandle()); } @@ -753,6 +767,13 @@ void GpuProcessHost::OnGpuMemoryBufferCreated( create_gpu_memory_buffer_requests_.front(); create_gpu_memory_buffer_requests_.pop(); callback.Run(handle); + + int32 surface_id = create_gpu_memory_buffer_surface_refs_.front(); + create_gpu_memory_buffer_surface_refs_.pop(); + SurfaceRefMap::iterator it = surface_refs_.find(surface_id); + if (it != surface_refs_.end()) { + surface_refs_.erase(it); + } } void GpuProcessHost::OnDidCreateOffscreenContext(const GURL& url) { diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 145cdcc..1a79b0b 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -124,6 +124,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, gfx::GpuMemoryBuffer::Format format, gfx::GpuMemoryBuffer::Usage usage, int client_id, + int32 surface_id, const CreateGpuMemoryBufferCallback& callback); // Tells the GPU process to destroy GPU memory buffer. @@ -204,6 +205,9 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, // The pending create gpu memory buffer requests we need to reply to. std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; + // Surface ids for pending gpu memory buffer request refs. + std::queue<int32> create_gpu_memory_buffer_surface_refs_; + // Qeueud messages to send when the process launches. std::queue<IPC::Message*> queued_messages_; |