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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 CommandBufferProxyImpl::~CommandBufferProxyImpl() { | 63 CommandBufferProxyImpl::~CommandBufferProxyImpl() { |
64 FOR_EACH_OBSERVER(DeletionObserver, deletion_observers_, OnWillDeleteImpl()); | 64 FOR_EACH_OBSERVER(DeletionObserver, deletion_observers_, OnWillDeleteImpl()); |
65 if (channel_) { | 65 if (channel_) { |
66 channel_->DestroyCommandBuffer(this); | 66 channel_->DestroyCommandBuffer(this); |
67 channel_ = nullptr; | 67 channel_ = nullptr; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { | 71 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { |
72 scoped_ptr<base::AutoLock> lock; | 72 std::unique_ptr<base::AutoLock> lock; |
73 if (lock_) | 73 if (lock_) |
74 lock.reset(new base::AutoLock(*lock_)); | 74 lock.reset(new base::AutoLock(*lock_)); |
75 bool handled = true; | 75 bool handled = true; |
76 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message) | 76 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message) |
77 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); | 77 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); |
78 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); | 78 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); |
79 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalAck, OnSignalAck); | 79 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalAck, OnSignalAck); |
80 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffersCompleted, | 80 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffersCompleted, |
81 OnSwapBuffersCompleted); | 81 OnSwapBuffersCompleted); |
82 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateVSyncParameters, | 82 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateVSyncParameters, |
83 OnUpdateVSyncParameters); | 83 OnUpdateVSyncParameters); |
84 IPC_MESSAGE_UNHANDLED(handled = false) | 84 IPC_MESSAGE_UNHANDLED(handled = false) |
85 IPC_END_MESSAGE_MAP() | 85 IPC_END_MESSAGE_MAP() |
86 | 86 |
87 if (!handled) { | 87 if (!handled) { |
88 DLOG(ERROR) << "Gpu process sent invalid message."; | 88 DLOG(ERROR) << "Gpu process sent invalid message."; |
89 InvalidGpuMessage(); | 89 InvalidGpuMessage(); |
90 } | 90 } |
91 return handled; | 91 return handled; |
92 } | 92 } |
93 | 93 |
94 void CommandBufferProxyImpl::OnChannelError() { | 94 void CommandBufferProxyImpl::OnChannelError() { |
95 scoped_ptr<base::AutoLock> lock; | 95 std::unique_ptr<base::AutoLock> lock; |
96 if (lock_) | 96 if (lock_) |
97 lock.reset(new base::AutoLock(*lock_)); | 97 lock.reset(new base::AutoLock(*lock_)); |
98 | 98 |
99 gpu::error::ContextLostReason context_lost_reason = | 99 gpu::error::ContextLostReason context_lost_reason = |
100 gpu::error::kGpuChannelLost; | 100 gpu::error::kGpuChannelLost; |
101 if (shared_state_shm_ && shared_state_shm_->memory()) { | 101 if (shared_state_shm_ && shared_state_shm_->memory()) { |
102 TryUpdateState(); | 102 TryUpdateState(); |
103 // The GPU process might have intentionally been crashed | 103 // The GPU process might have intentionally been crashed |
104 // (exit_on_context_lost), so try to find out the original reason. | 104 // (exit_on_context_lost), so try to find out the original reason. |
105 if (last_state_.error == gpu::error::kLostContext) | 105 if (last_state_.error == gpu::error::kLostContext) |
(...skipping 22 matching lines...) Expand all Loading... |
128 } | 128 } |
129 | 129 |
130 void CommandBufferProxyImpl::OnConsoleMessage( | 130 void CommandBufferProxyImpl::OnConsoleMessage( |
131 const GPUCommandBufferConsoleMessage& message) { | 131 const GPUCommandBufferConsoleMessage& message) { |
132 if (gpu_control_client_) | 132 if (gpu_control_client_) |
133 gpu_control_client_->OnGpuControlErrorMessage(message.message.c_str(), | 133 gpu_control_client_->OnGpuControlErrorMessage(message.message.c_str(), |
134 message.id); | 134 message.id); |
135 } | 135 } |
136 | 136 |
137 void CommandBufferProxyImpl::AddDeletionObserver(DeletionObserver* observer) { | 137 void CommandBufferProxyImpl::AddDeletionObserver(DeletionObserver* observer) { |
138 scoped_ptr<base::AutoLock> lock; | 138 std::unique_ptr<base::AutoLock> lock; |
139 if (lock_) | 139 if (lock_) |
140 lock.reset(new base::AutoLock(*lock_)); | 140 lock.reset(new base::AutoLock(*lock_)); |
141 deletion_observers_.AddObserver(observer); | 141 deletion_observers_.AddObserver(observer); |
142 } | 142 } |
143 | 143 |
144 void CommandBufferProxyImpl::RemoveDeletionObserver( | 144 void CommandBufferProxyImpl::RemoveDeletionObserver( |
145 DeletionObserver* observer) { | 145 DeletionObserver* observer) { |
146 scoped_ptr<base::AutoLock> lock; | 146 std::unique_ptr<base::AutoLock> lock; |
147 if (lock_) | 147 if (lock_) |
148 lock.reset(new base::AutoLock(*lock_)); | 148 lock.reset(new base::AutoLock(*lock_)); |
149 deletion_observers_.RemoveObserver(observer); | 149 deletion_observers_.RemoveObserver(observer); |
150 } | 150 } |
151 | 151 |
152 void CommandBufferProxyImpl::OnSignalAck(uint32_t id) { | 152 void CommandBufferProxyImpl::OnSignalAck(uint32_t id) { |
153 SignalTaskMap::iterator it = signal_tasks_.find(id); | 153 SignalTaskMap::iterator it = signal_tasks_.find(id); |
154 if (it == signal_tasks_.end()) { | 154 if (it == signal_tasks_.end()) { |
155 DLOG(ERROR) << "Gpu process sent invalid SignalAck."; | 155 DLOG(ERROR) << "Gpu process sent invalid SignalAck."; |
156 InvalidGpuMessage(); | 156 InvalidGpuMessage(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 size_t size, | 339 size_t size, |
340 int32_t* id) { | 340 int32_t* id) { |
341 CheckLock(); | 341 CheckLock(); |
342 *id = -1; | 342 *id = -1; |
343 | 343 |
344 if (last_state_.error != gpu::error::kNoError) | 344 if (last_state_.error != gpu::error::kNoError) |
345 return NULL; | 345 return NULL; |
346 | 346 |
347 int32_t new_id = channel_->ReserveTransferBufferId(); | 347 int32_t new_id = channel_->ReserveTransferBufferId(); |
348 | 348 |
349 scoped_ptr<base::SharedMemory> shared_memory( | 349 std::unique_ptr<base::SharedMemory> shared_memory( |
350 channel_->factory()->AllocateSharedMemory(size)); | 350 channel_->factory()->AllocateSharedMemory(size)); |
351 if (!shared_memory) { | 351 if (!shared_memory) { |
352 if (last_state_.error == gpu::error::kNoError) | 352 if (last_state_.error == gpu::error::kNoError) |
353 last_state_.error = gpu::error::kOutOfBounds; | 353 last_state_.error = gpu::error::kOutOfBounds; |
354 return NULL; | 354 return NULL; |
355 } | 355 } |
356 | 356 |
357 DCHECK(!shared_memory->memory()); | 357 DCHECK(!shared_memory->memory()); |
358 if (!shared_memory->Map(size)) { | 358 if (!shared_memory->Map(size)) { |
359 if (last_state_.error == gpu::error::kNoError) | 359 if (last_state_.error == gpu::error::kNoError) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 468 |
469 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); | 469 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); |
470 } | 470 } |
471 | 471 |
472 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( | 472 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( |
473 size_t width, | 473 size_t width, |
474 size_t height, | 474 size_t height, |
475 unsigned internal_format, | 475 unsigned internal_format, |
476 unsigned usage) { | 476 unsigned usage) { |
477 CheckLock(); | 477 CheckLock(); |
478 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 478 std::unique_ptr<gfx::GpuMemoryBuffer> buffer( |
479 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( | 479 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
480 gfx::Size(width, height), | 480 gfx::Size(width, height), |
481 gpu::DefaultBufferFormatForImageFormat(internal_format), | 481 gpu::DefaultBufferFormatForImageFormat(internal_format), |
482 gfx::BufferUsage::SCANOUT, 0 /* surface_id */)); | 482 gfx::BufferUsage::SCANOUT, 0 /* surface_id */)); |
483 if (!buffer) | 483 if (!buffer) |
484 return -1; | 484 return -1; |
485 | 485 |
486 return CreateImage(buffer->AsClientBuffer(), width, height, internal_format); | 486 return CreateImage(buffer->AsClientBuffer(), width, height, internal_format); |
487 } | 487 } |
488 | 488 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 LOG(ERROR) << "Received invalid reply from the GPU process."; | 712 LOG(ERROR) << "Received invalid reply from the GPU process."; |
713 last_state_.error = gpu::error::kLostContext; | 713 last_state_.error = gpu::error::kLostContext; |
714 last_state_.context_lost_reason = gpu::error::kInvalidGpuMessage; | 714 last_state_.context_lost_reason = gpu::error::kInvalidGpuMessage; |
715 callback_thread_->PostTask( | 715 callback_thread_->PostTask( |
716 FROM_HERE, | 716 FROM_HERE, |
717 base::Bind(&CommandBufferProxyImpl::InvalidGpuReplyOnClientThread, | 717 base::Bind(&CommandBufferProxyImpl::InvalidGpuReplyOnClientThread, |
718 weak_this_)); | 718 weak_this_)); |
719 } | 719 } |
720 | 720 |
721 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { | 721 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { |
722 scoped_ptr<base::AutoLock> lock; | 722 std::unique_ptr<base::AutoLock> lock; |
723 if (lock_) | 723 if (lock_) |
724 lock.reset(new base::AutoLock(*lock_)); | 724 lock.reset(new base::AutoLock(*lock_)); |
725 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); | 725 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); |
726 } | 726 } |
727 | 727 |
728 } // namespace gpu | 728 } // namespace gpu |
OLD | NEW |