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

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

Issue 263553009: content: Cleanup GpuMemoryBuffer allocation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac build fix Created 6 years, 7 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_message_filter.cc » ('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_shm.h" 14 #include "content/common/gpu/client/gpu_memory_buffer_impl.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/browser/gpu_data_manager.h" 17 #include "content/public/browser/gpu_data_manager.h"
18 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
19 #include "ipc/ipc_forwarding_message_filter.h" 19 #include "ipc/ipc_forwarding_message_filter.h"
20 #include "ipc/message_filter.h" 20 #include "ipc/message_filter.h"
21 21
22 namespace content { 22 namespace content {
23 23
24 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; 24 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 scoped_ptr<gfx::GpuMemoryBuffer> 378 scoped_ptr<gfx::GpuMemoryBuffer>
379 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width, 379 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width,
380 size_t height, 380 size_t height,
381 unsigned internalformat, 381 unsigned internalformat,
382 unsigned usage) { 382 unsigned usage) {
383 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || 383 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) ||
384 !GpuMemoryBufferImpl::IsUsageValid(usage)) 384 !GpuMemoryBufferImpl::IsUsageValid(usage))
385 return scoped_ptr<gfx::GpuMemoryBuffer>(); 385 return scoped_ptr<gfx::GpuMemoryBuffer>();
386 386
387 size_t size = width * height * 387 return GpuMemoryBufferImpl::Create(gfx::Size(width, height),
388 GpuMemoryBufferImpl::BytesPerPixel(internalformat); 388 internalformat,
389 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); 389 usage).PassAs<gfx::GpuMemoryBuffer>();
390 if (!shm->CreateAnonymous(size))
391 return scoped_ptr<gfx::GpuMemoryBuffer>();
392
393 scoped_ptr<GpuMemoryBufferImplShm> buffer(
394 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat));
395 if (!buffer->InitializeFromSharedMemory(shm.Pass()))
396 return scoped_ptr<gfx::GpuMemoryBuffer>();
397
398 return buffer.PassAs<gfx::GpuMemoryBuffer>();
399 } 390 }
400 391
401 // static 392 // static
402 void BrowserGpuChannelHostFactory::AddFilterOnIO( 393 void BrowserGpuChannelHostFactory::AddFilterOnIO(
403 int host_id, 394 int host_id,
404 scoped_refptr<IPC::MessageFilter> filter) { 395 scoped_refptr<IPC::MessageFilter> filter) {
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
406 397
407 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 398 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
408 if (host) 399 if (host)
(...skipping 17 matching lines...) Expand all
426 filter->AddRoute(MSG_ROUTING_CONTROL, handler); 417 filter->AddRoute(MSG_ROUTING_CONTROL, handler);
427 418
428 GetIOLoopProxy()->PostTask( 419 GetIOLoopProxy()->PostTask(
429 FROM_HERE, 420 FROM_HERE,
430 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, 421 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO,
431 gpu_host_id_, 422 gpu_host_id_,
432 filter)); 423 filter));
433 } 424 }
434 425
435 } // namespace content 426 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698