Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 19762004: Add multi-process GpuMemoryBuffer framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "content/browser/gpu/gpu_data_manager_impl.h" 9 #include "content/browser/gpu/gpu_data_manager_impl.h"
10 #include "content/browser/gpu/gpu_process_host.h" 10 #include "content/browser/gpu/gpu_process_host.h"
11 #include "content/browser/gpu/gpu_surface_tracker.h" 11 #include "content/browser/gpu/gpu_surface_tracker.h"
12 #include "content/common/child_process_host_impl.h"
13 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
12 #include "content/common/gpu/gpu_messages.h" 14 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/child_process_host_impl.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
16 #include "ipc/ipc_forwarding_message_filter.h" 17 #include "ipc/ipc_forwarding_message_filter.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; 21 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
21 22
22 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() 23 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest()
23 : event(false, false), 24 : event(false, false),
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (request.channel_handle.name.empty()) 278 if (request.channel_handle.name.empty())
278 return NULL; 279 return NULL;
279 280
280 GetContentClient()->SetGpuInfo(request.gpu_info); 281 GetContentClient()->SetGpuInfo(request.gpu_info);
281 gpu_channel_ = GpuChannelHost::Create( 282 gpu_channel_ = GpuChannelHost::Create(
282 this, request.gpu_host_id, gpu_client_id_, 283 this, request.gpu_host_id, gpu_client_id_,
283 request.gpu_info, request.channel_handle); 284 request.gpu_info, request.channel_handle);
284 return gpu_channel_.get(); 285 return gpu_channel_.get();
285 } 286 }
286 287
288 scoped_ptr<gfx::GpuMemoryBuffer>
289 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(
290 size_t width,
291 size_t height,
292 unsigned internalformat) {
293 DCHECK(GpuMemoryBufferImpl::IsFormatValid(internalformat));
294 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
295 return scoped_ptr<gfx::GpuMemoryBuffer>();
piman 2013/10/21 21:57:00 nit: either DCHECK or test, but not both. If the c
reveman 2013/10/22 16:26:11 Removed the DCHECK.
296
297 size_t size = width * height *
298 GpuMemoryBufferImpl::BytesPerPixel(internalformat);
299 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory());
300 if (!shm->CreateAnonymous(size))
301 return scoped_ptr<gfx::GpuMemoryBuffer>();
302
303 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
304 new GpuMemoryBufferImpl(shm.Pass(),
305 width,
306 height,
307 internalformat));
308 }
309
287 // static 310 // static
288 void BrowserGpuChannelHostFactory::AddFilterOnIO( 311 void BrowserGpuChannelHostFactory::AddFilterOnIO(
289 int host_id, 312 int host_id,
290 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { 313 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) {
291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
292 315
293 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 316 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
294 if (host) 317 if (host)
295 host->AddFilter(filter.get()); 318 host->AddFilter(filter.get());
296 } 319 }
(...skipping 15 matching lines...) Expand all
312 filter->AddRoute(MSG_ROUTING_CONTROL, handler); 335 filter->AddRoute(MSG_ROUTING_CONTROL, handler);
313 336
314 GetIOLoopProxy()->PostTask( 337 GetIOLoopProxy()->PostTask(
315 FROM_HERE, 338 FROM_HERE,
316 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, 339 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO,
317 gpu_host_id_, 340 gpu_host_id_,
318 filter)); 341 filter));
319 } 342 }
320 343
321 } // namespace content 344 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698