| 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 "gpu/ipc/client/command_buffer_proxy_impl.h" | 5 #include "gpu/ipc/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" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 command_buffer_id_(CommandBufferProxyID(channel_id, route_id)), | 54 command_buffer_id_(CommandBufferProxyID(channel_id, route_id)), |
| 55 route_id_(route_id), | 55 route_id_(route_id), |
| 56 stream_id_(stream_id), | 56 stream_id_(stream_id), |
| 57 flush_count_(0), | 57 flush_count_(0), |
| 58 last_put_offset_(-1), | 58 last_put_offset_(-1), |
| 59 last_barrier_put_offset_(-1), | 59 last_barrier_put_offset_(-1), |
| 60 next_fence_sync_release_(1), | 60 next_fence_sync_release_(1), |
| 61 flushed_fence_sync_release_(0), | 61 flushed_fence_sync_release_(0), |
| 62 verified_fence_sync_release_(0), | 62 verified_fence_sync_release_(0), |
| 63 next_signal_id_(0), | 63 next_signal_id_(0), |
| 64 weak_this_(AsWeakPtr()), | 64 weak_this_(AsWeakPtr()) { |
| 65 callback_thread_(base::ThreadTaskRunnerHandle::Get()) { | |
| 66 DCHECK(route_id); | 65 DCHECK(route_id); |
| 67 DCHECK_NE(stream_id, GPU_STREAM_INVALID); | 66 DCHECK_NE(stream_id, GPU_STREAM_INVALID); |
| 68 } | 67 } |
| 69 | 68 |
| 70 // static | 69 // static |
| 71 std::unique_ptr<CommandBufferProxyImpl> CommandBufferProxyImpl::Create( | 70 std::unique_ptr<CommandBufferProxyImpl> CommandBufferProxyImpl::Create( |
| 72 scoped_refptr<GpuChannelHost> host, | 71 scoped_refptr<GpuChannelHost> host, |
| 73 gpu::SurfaceHandle surface_handle, | 72 gpu::SurfaceHandle surface_handle, |
| 74 CommandBufferProxyImpl* share_group, | 73 CommandBufferProxyImpl* share_group, |
| 75 int32_t stream_id, | 74 int32_t stream_id, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return false; | 210 return false; |
| 212 | 211 |
| 213 | 212 |
| 214 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. | 213 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. |
| 215 tracked_objects::ScopedTracker tracking_profile( | 214 tracked_objects::ScopedTracker tracking_profile( |
| 216 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 215 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 217 "125248 CommandBufferProxyImpl::Initialize")); | 216 "125248 CommandBufferProxyImpl::Initialize")); |
| 218 | 217 |
| 219 // Route must be added before sending the message, otherwise messages sent | 218 // Route must be added before sending the message, otherwise messages sent |
| 220 // from the GPU process could race against adding ourselves to the filter. | 219 // from the GPU process could race against adding ourselves to the filter. |
| 221 channel->AddRouteWithTaskRunner(route_id_, AsWeakPtr(), | 220 channel->AddRouteWithTaskRunner(route_id_, AsWeakPtr(), task_runner); |
| 222 std::move(task_runner)); | |
| 223 | 221 |
| 224 // We're blocking the UI thread, which is generally undesirable. | 222 // We're blocking the UI thread, which is generally undesirable. |
| 225 // In this case we need to wait for this before we can show any UI /anyway/, | 223 // In this case we need to wait for this before we can show any UI /anyway/, |
| 226 // so it won't cause additional jank. | 224 // so it won't cause additional jank. |
| 227 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 225 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
| 228 bool result = false; | 226 bool result = false; |
| 229 bool sent = channel->Send(new GpuChannelMsg_CreateCommandBuffer( | 227 bool sent = channel->Send(new GpuChannelMsg_CreateCommandBuffer( |
| 230 config, route_id_, handle, &result, &capabilities_)); | 228 config, route_id_, handle, &result, &capabilities_)); |
| 231 if (!sent || !result) { | 229 if (!sent || !result) { |
| 232 DLOG(ERROR) << "Failed to send GpuChannelMsg_CreateCommandBuffer."; | 230 DLOG(ERROR) << "Failed to send GpuChannelMsg_CreateCommandBuffer."; |
| 233 channel->RemoveRoute(route_id_); | 231 channel->RemoveRoute(route_id_); |
| 234 return false; | 232 return false; |
| 235 } | 233 } |
| 236 | 234 |
| 237 channel_ = std::move(channel); | 235 channel_ = std::move(channel); |
| 238 capabilities_.image = true; | 236 capabilities_.image = true; |
| 239 | 237 |
| 238 callback_thread_ = std::move(task_runner); |
| 239 |
| 240 return true; | 240 return true; |
| 241 } | 241 } |
| 242 | 242 |
| 243 gpu::CommandBuffer::State CommandBufferProxyImpl::GetLastState() { | 243 gpu::CommandBuffer::State CommandBufferProxyImpl::GetLastState() { |
| 244 return last_state_; | 244 return last_state_; |
| 245 } | 245 } |
| 246 | 246 |
| 247 int32_t CommandBufferProxyImpl::GetLastToken() { | 247 int32_t CommandBufferProxyImpl::GetLastToken() { |
| 248 TryUpdateState(); | 248 TryUpdateState(); |
| 249 return last_state_.token; | 249 return last_state_.token; |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 return; | 856 return; |
| 857 channel_->FlushPendingStream(stream_id_); | 857 channel_->FlushPendingStream(stream_id_); |
| 858 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); | 858 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); |
| 859 channel_->RemoveRoute(route_id_); | 859 channel_->RemoveRoute(route_id_); |
| 860 channel_ = nullptr; | 860 channel_ = nullptr; |
| 861 if (gpu_control_client_) | 861 if (gpu_control_client_) |
| 862 gpu_control_client_->OnGpuControlLostContext(); | 862 gpu_control_client_->OnGpuControlLostContext(); |
| 863 } | 863 } |
| 864 | 864 |
| 865 } // namespace gpu | 865 } // namespace gpu |
| OLD | NEW |