| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "content/common/child_process_messages.h" | 15 #include "content/common/child_process_messages.h" |
| 16 #include "content/common/gpu/client/gpu_channel_host.h" | 16 #include "content/common/gpu/client/gpu_channel_host.h" |
| 17 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" | 17 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
| 18 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" | 18 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 20 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
| 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 22 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 22 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 23 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 23 #include "gpu/command_buffer/common/command_buffer_shared.h" | 24 #include "gpu/command_buffer/common/command_buffer_shared.h" |
| 24 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 25 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 25 #include "gpu/command_buffer/common/sync_token.h" | 26 #include "gpu/command_buffer/common/sync_token.h" |
| 26 #include "gpu/command_buffer/service/image_factory.h" | 27 #include "gpu/command_buffer/service/image_factory.h" |
| 27 #include "ui/gfx/geometry/size.h" | 28 #include "ui/gfx/geometry/size.h" |
| 28 #include "ui/gl/gl_bindings.h" | 29 #include "ui/gl/gl_bindings.h" |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 uint64_t CommandBufferProxyID(int channel_id, int32_t route_id) { | 35 gpu::CommandBufferId CommandBufferProxyID(int channel_id, int32_t route_id) { |
| 35 return (static_cast<uint64_t>(channel_id) << 32) | route_id; | 36 return gpu::CommandBufferId::FromUnsafeValue( |
| 37 (static_cast<uint64_t>(channel_id) << 32) | route_id); |
| 36 } | 38 } |
| 37 | 39 |
| 38 } // namespace | 40 } // namespace |
| 39 | 41 |
| 40 CommandBufferProxyImpl::CommandBufferProxyImpl(GpuChannelHost* channel, | 42 CommandBufferProxyImpl::CommandBufferProxyImpl(GpuChannelHost* channel, |
| 41 int32_t route_id, | 43 int32_t route_id, |
| 42 int32_t stream_id) | 44 int32_t stream_id) |
| 43 : lock_(nullptr), | 45 : lock_(nullptr), |
| 44 channel_(channel), | 46 channel_(channel), |
| 45 command_buffer_id_(CommandBufferProxyID(channel->channel_id(), route_id)), | 47 command_buffer_id_(CommandBufferProxyID(channel->channel_id(), route_id)), |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 533 |
| 532 void CommandBufferProxyImpl::EnsureWorkVisible() { | 534 void CommandBufferProxyImpl::EnsureWorkVisible() { |
| 533 if (channel_) | 535 if (channel_) |
| 534 channel_->ValidateFlushIDReachedServer(stream_id_, true); | 536 channel_->ValidateFlushIDReachedServer(stream_id_, true); |
| 535 } | 537 } |
| 536 | 538 |
| 537 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { | 539 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { |
| 538 return gpu::CommandBufferNamespace::GPU_IO; | 540 return gpu::CommandBufferNamespace::GPU_IO; |
| 539 } | 541 } |
| 540 | 542 |
| 541 uint64_t CommandBufferProxyImpl::GetCommandBufferID() const { | 543 gpu::CommandBufferId CommandBufferProxyImpl::GetCommandBufferID() const { |
| 542 return command_buffer_id_; | 544 return command_buffer_id_; |
| 543 } | 545 } |
| 544 | 546 |
| 545 int32_t CommandBufferProxyImpl::GetExtraCommandBufferData() const { | 547 int32_t CommandBufferProxyImpl::GetExtraCommandBufferData() const { |
| 546 return stream_id_; | 548 return stream_id_; |
| 547 } | 549 } |
| 548 | 550 |
| 549 uint64_t CommandBufferProxyImpl::GenerateFenceSyncRelease() { | 551 uint64_t CommandBufferProxyImpl::GenerateFenceSyncRelease() { |
| 550 return next_fence_sync_release_++; | 552 return next_fence_sync_release_++; |
| 551 } | 553 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 signal_id))) { | 597 signal_id))) { |
| 596 return; | 598 return; |
| 597 } | 599 } |
| 598 | 600 |
| 599 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 601 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
| 600 } | 602 } |
| 601 | 603 |
| 602 bool CommandBufferProxyImpl::CanWaitUnverifiedSyncToken( | 604 bool CommandBufferProxyImpl::CanWaitUnverifiedSyncToken( |
| 603 const gpu::SyncToken* sync_token) { | 605 const gpu::SyncToken* sync_token) { |
| 604 // Can only wait on an unverified sync token if it is from the same channel. | 606 // Can only wait on an unverified sync token if it is from the same channel. |
| 605 const uint64_t token_channel = sync_token->command_buffer_id() >> 32; | 607 const uint64_t token_channel = |
| 606 const uint64_t channel = command_buffer_id_ >> 32; | 608 sync_token->command_buffer_id().GetUnsafeValue() >> 32; |
| 609 const uint64_t channel = command_buffer_id_.GetUnsafeValue() >> 32; |
| 607 if (sync_token->namespace_id() != gpu::CommandBufferNamespace::GPU_IO || | 610 if (sync_token->namespace_id() != gpu::CommandBufferNamespace::GPU_IO || |
| 608 token_channel != channel) { | 611 token_channel != channel) { |
| 609 return false; | 612 return false; |
| 610 } | 613 } |
| 611 | 614 |
| 612 // If waiting on a different stream, flush pending commands on that stream. | 615 // If waiting on a different stream, flush pending commands on that stream. |
| 613 const int32_t release_stream_id = sync_token->extra_data_field(); | 616 const int32_t release_stream_id = sync_token->extra_data_field(); |
| 614 if (release_stream_id == 0) | 617 if (release_stream_id == 0) |
| 615 return false; | 618 return false; |
| 616 | 619 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 } | 770 } |
| 768 | 771 |
| 769 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { | 772 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { |
| 770 scoped_ptr<base::AutoLock> lock; | 773 scoped_ptr<base::AutoLock> lock; |
| 771 if (lock_) | 774 if (lock_) |
| 772 lock.reset(new base::AutoLock(*lock_)); | 775 lock.reset(new base::AutoLock(*lock_)); |
| 773 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); | 776 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); |
| 774 } | 777 } |
| 775 | 778 |
| 776 } // namespace content | 779 } // namespace content |
| OLD | NEW |