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/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" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 gpu_host_id_ = pending_request_->gpu_host_id(); | 369 gpu_host_id_ = pending_request_->gpu_host_id(); |
370 pending_request_ = NULL; | 370 pending_request_ = NULL; |
371 | 371 |
372 for (size_t n = 0; n < established_callbacks_.size(); n++) | 372 for (size_t n = 0; n < established_callbacks_.size(); n++) |
373 established_callbacks_[n].Run(); | 373 established_callbacks_[n].Run(); |
374 | 374 |
375 established_callbacks_.clear(); | 375 established_callbacks_.clear(); |
376 } | 376 } |
377 | 377 |
378 scoped_ptr<gfx::GpuMemoryBuffer> | 378 scoped_ptr<gfx::GpuMemoryBuffer> |
379 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer( | 379 BrowserGpuChannelHostFactory::AllocateGpuMemoryBuffer(size_t width, |
380 size_t width, | 380 size_t height, |
381 size_t height, | 381 unsigned internalformat, |
382 unsigned internalformat) { | 382 unsigned usage) { |
383 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) | 383 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) |
reveman
2014/05/01 15:15:55
Please add a IsUsageValid check here too.
| |
384 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 384 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
385 | 385 |
386 size_t size = width * height * | 386 size_t size = width * height * |
387 GpuMemoryBufferImpl::BytesPerPixel(internalformat); | 387 GpuMemoryBufferImpl::BytesPerPixel(internalformat); |
388 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 388 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
389 if (!shm->CreateAnonymous(size)) | 389 if (!shm->CreateAnonymous(size)) |
390 return scoped_ptr<gfx::GpuMemoryBuffer>(); | 390 return scoped_ptr<gfx::GpuMemoryBuffer>(); |
391 | 391 |
392 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 392 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
393 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); | 393 new GpuMemoryBufferImplShm(gfx::Size(width, height), internalformat)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 425 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
426 | 426 |
427 GetIOLoopProxy()->PostTask( | 427 GetIOLoopProxy()->PostTask( |
428 FROM_HERE, | 428 FROM_HERE, |
429 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 429 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
430 gpu_host_id_, | 430 gpu_host_id_, |
431 filter)); | 431 filter)); |
432 } | 432 } |
433 | 433 |
434 } // namespace content | 434 } // namespace content |
OLD | NEW |