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

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

Issue 77023002: gpu: Add IOSurface backed GpuMemoryBuffer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix overflow check Created 7 years 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
11 #include "content/browser/gpu/gpu_process_host.h" 11 #include "content/browser/gpu/gpu_process_host.h"
12 #include "content/browser/gpu/gpu_surface_tracker.h" 12 #include "content/browser/gpu/gpu_surface_tracker.h"
13 #include "content/common/child_process_host_impl.h" 13 #include "content/common/child_process_host_impl.h"
14 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 14 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h"
15 #include "content/common/gpu/gpu_messages.h" 15 #include "content/common/gpu/gpu_messages.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
18 #include "ipc/ipc_forwarding_message_filter.h" 18 #include "ipc/ipc_forwarding_message_filter.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; 22 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
23 23
24 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() 24 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest()
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 unsigned internalformat) { 373 unsigned internalformat) {
374 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) 374 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
375 return scoped_ptr<gfx::GpuMemoryBuffer>(); 375 return scoped_ptr<gfx::GpuMemoryBuffer>();
376 376
377 size_t size = width * height * 377 size_t size = width * height *
378 GpuMemoryBufferImpl::BytesPerPixel(internalformat); 378 GpuMemoryBufferImpl::BytesPerPixel(internalformat);
379 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); 379 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory());
380 if (!shm->CreateAnonymous(size)) 380 if (!shm->CreateAnonymous(size))
381 return scoped_ptr<gfx::GpuMemoryBuffer>(); 381 return scoped_ptr<gfx::GpuMemoryBuffer>();
382 382
383 return make_scoped_ptr<gfx::GpuMemoryBuffer>( 383 scoped_ptr<GpuMemoryBufferImplShm> buffer(
384 new GpuMemoryBufferImpl(shm.Pass(), 384 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat));
385 width, 385 if (!buffer->InitializeFromSharedMemory(shm.Pass()))
386 height, 386 return scoped_ptr<gfx::GpuMemoryBuffer>();
387 internalformat)); 387
388 return buffer.PassAs<gfx::GpuMemoryBuffer>();
388 } 389 }
389 390
390 // static 391 // static
391 void BrowserGpuChannelHostFactory::AddFilterOnIO( 392 void BrowserGpuChannelHostFactory::AddFilterOnIO(
392 int host_id, 393 int host_id,
393 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { 394 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) {
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
395 396
396 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 397 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
397 if (host) 398 if (host)
(...skipping 17 matching lines...) Expand all
415 filter->AddRoute(MSG_ROUTING_CONTROL, handler); 416 filter->AddRoute(MSG_ROUTING_CONTROL, handler);
416 417
417 GetIOLoopProxy()->PostTask( 418 GetIOLoopProxy()->PostTask(
418 FROM_HERE, 419 FROM_HERE,
419 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, 420 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO,
420 gpu_host_id_, 421 gpu_host_id_,
421 filter)); 422 filter));
422 } 423 }
423 424
424 } // namespace content 425 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698