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/common/gpu/client/command_buffer_proxy_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | |
8 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
12 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
13 #include "content/common/gpu/client/gpu_channel_host.h" | 14 #include "content/common/gpu/client/gpu_channel_host.h" |
14 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 15 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
15 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
16 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
18 #include "content/public/common/content_switches.h" | |
17 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 19 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
18 #include "gpu/command_buffer/common/command_buffer_shared.h" | 20 #include "gpu/command_buffer/common/command_buffer_shared.h" |
19 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 21 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
20 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 | 25 |
24 CommandBufferProxyImpl::CommandBufferProxyImpl( | 26 CommandBufferProxyImpl::CommandBufferProxyImpl( |
25 GpuChannelHost* channel, | 27 GpuChannelHost* channel, |
26 int route_id) | 28 int route_id) |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 | 376 |
375 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( | 377 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( |
376 size_t width, | 378 size_t width, |
377 size_t height, | 379 size_t height, |
378 unsigned internalformat, | 380 unsigned internalformat, |
379 int32* id) { | 381 int32* id) { |
380 *id = -1; | 382 *id = -1; |
381 | 383 |
382 if (last_state_.error != gpu::error::kNoError) | 384 if (last_state_.error != gpu::error::kNoError) |
383 return NULL; | 385 return NULL; |
384 | |
385 int32 new_id = channel_->ReserveGpuMemoryBufferId(); | 386 int32 new_id = channel_->ReserveGpuMemoryBufferId(); |
386 DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); | 387 DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); |
387 | |
388 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( | 388 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( |
389 channel_->factory()->AllocateGpuMemoryBuffer(width, | 389 channel_->factory()->AllocateGpuMemoryBuffer(width, |
390 height, | 390 height, |
391 internalformat)); | 391 internalformat)); |
392 if (!gpu_memory_buffer) | 392 if (!gpu_memory_buffer) |
393 return NULL; | 393 return NULL; |
394 | 394 |
395 DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer( | 395 DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer( |
396 gpu_memory_buffer->GetHandle())); | 396 gpu_memory_buffer->GetHandle())); |
397 | 397 |
398 // This handle is owned by the GPU process and must be passed to it or it | 398 // This handle is owned by the GPU process and must be passed to it or it |
399 // will leak. In otherwords, do not early out on error between here and the | 399 // will leak. In otherwords, do not early out on error between here and the |
400 // sending of the RegisterGpuMemoryBuffer IPC below. | 400 // sending of the RegisterGpuMemoryBuffer IPC below. |
401 | |
401 gfx::GpuMemoryBufferHandle handle = | 402 gfx::GpuMemoryBufferHandle handle = |
402 channel_->ShareGpuMemoryBufferToGpuProcess( | 403 channel_->ShareGpuMemoryBufferToGpuProcess( |
403 gpu_memory_buffer->GetHandle()); | 404 gpu_memory_buffer->GetHandle()); |
404 | 405 |
406 #if defined(OS_ANDROID) | |
407 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
408 switches::KEnableSurfaceTextureBuffer)) { | |
409 uint32 surface_texture_handle = 0; | |
410 uint32 texture_id = 0; | |
411 Send(new GpuCommandBufferMsg_CreateSurfaceTexture( | |
412 route_id_, | |
413 reinterpret_cast<uint32>(gpu_memory_buffer.get()), | |
414 &surface_texture_handle, | |
415 &texture_id)); | |
416 | |
417 handle.surface_texture_handle = | |
418 reinterpret_cast<void*>(surface_texture_handle); | |
419 handle.texture_id = texture_id; | |
420 } | |
421 #endif | |
reveman
2014/02/26 08:02:34
I haven't looked at what this code does in detail
| |
422 | |
405 if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer( | 423 if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer( |
406 route_id_, | 424 route_id_, |
407 new_id, | 425 new_id, |
408 handle, | 426 handle, |
409 width, | 427 width, |
410 height, | 428 height, |
411 internalformat))) { | 429 internalformat))) { |
412 return NULL; | 430 return NULL; |
413 } | 431 } |
414 | 432 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 const GpuConsoleMessageCallback& callback) { | 608 const GpuConsoleMessageCallback& callback) { |
591 console_message_callback_ = callback; | 609 console_message_callback_ = callback; |
592 } | 610 } |
593 | 611 |
594 void CommandBufferProxyImpl::TryUpdateState() { | 612 void CommandBufferProxyImpl::TryUpdateState() { |
595 if (last_state_.error == gpu::error::kNoError) | 613 if (last_state_.error == gpu::error::kNoError) |
596 shared_state()->Read(&last_state_); | 614 shared_state()->Read(&last_state_); |
597 } | 615 } |
598 | 616 |
599 } // namespace content | 617 } // namespace content |
OLD | NEW |