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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 IPC_END_MESSAGE_MAP() | 64 IPC_END_MESSAGE_MAP() |
65 | 65 |
66 DCHECK(handled); | 66 DCHECK(handled); |
67 return handled; | 67 return handled; |
68 } | 68 } |
69 | 69 |
70 void CommandBufferProxyImpl::OnChannelError() { | 70 void CommandBufferProxyImpl::OnChannelError() { |
71 scoped_ptr<base::AutoLock> lock; | 71 scoped_ptr<base::AutoLock> lock; |
72 if (lock_) | 72 if (lock_) |
73 lock.reset(new base::AutoLock(*lock_)); | 73 lock.reset(new base::AutoLock(*lock_)); |
74 OnDestroyed(gpu::error::kUnknown); | 74 OnDestroyed(gpu::error::kGpuChannelLost, gpu::error::kLostContext); |
75 } | 75 } |
76 | 76 |
77 void CommandBufferProxyImpl::OnDestroyed(gpu::error::ContextLostReason reason) { | 77 void CommandBufferProxyImpl::OnDestroyed(gpu::error::ContextLostReason reason, |
| 78 gpu::error::Error error) { |
78 CheckLock(); | 79 CheckLock(); |
79 // Prevent any further messages from being sent. | 80 // Prevent any further messages from being sent. |
80 channel_ = NULL; | 81 channel_ = NULL; |
81 | 82 |
82 // When the client sees that the context is lost, they should delete this | 83 // When the client sees that the context is lost, they should delete this |
83 // CommandBufferProxyImpl and create a new one. | 84 // CommandBufferProxyImpl and create a new one. |
84 last_state_.error = gpu::error::kLostContext; | 85 last_state_.error = error; |
85 last_state_.context_lost_reason = reason; | 86 last_state_.context_lost_reason = reason; |
86 | 87 |
87 if (!channel_error_callback_.is_null()) { | 88 if (!context_lost_callback_.is_null()) { |
88 channel_error_callback_.Run(); | 89 context_lost_callback_.Run(); |
89 // Avoid calling the error callback more than once. | 90 // Avoid calling the error callback more than once. |
90 channel_error_callback_.Reset(); | 91 context_lost_callback_.Reset(); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 void CommandBufferProxyImpl::OnConsoleMessage( | 95 void CommandBufferProxyImpl::OnConsoleMessage( |
95 const GPUCommandBufferConsoleMessage& message) { | 96 const GPUCommandBufferConsoleMessage& message) { |
96 if (!console_message_callback_.is_null()) { | 97 if (!console_message_callback_.is_null()) { |
97 console_message_callback_.Run(message.message, message.id); | 98 console_message_callback_.Run(message.message, message.id); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
(...skipping 26 matching lines...) Expand all Loading... |
127 } | 128 } |
128 | 129 |
129 void CommandBufferProxyImpl::OnSignalSyncPointAck(uint32 id) { | 130 void CommandBufferProxyImpl::OnSignalSyncPointAck(uint32 id) { |
130 SignalTaskMap::iterator it = signal_tasks_.find(id); | 131 SignalTaskMap::iterator it = signal_tasks_.find(id); |
131 DCHECK(it != signal_tasks_.end()); | 132 DCHECK(it != signal_tasks_.end()); |
132 base::Closure callback = it->second; | 133 base::Closure callback = it->second; |
133 signal_tasks_.erase(it); | 134 signal_tasks_.erase(it); |
134 callback.Run(); | 135 callback.Run(); |
135 } | 136 } |
136 | 137 |
137 void CommandBufferProxyImpl::SetChannelErrorCallback( | 138 void CommandBufferProxyImpl::SetContextLostCallback( |
138 const base::Closure& callback) { | 139 const base::Closure& callback) { |
139 CheckLock(); | 140 CheckLock(); |
140 channel_error_callback_ = callback; | 141 context_lost_callback_ = callback; |
141 } | 142 } |
142 | 143 |
143 bool CommandBufferProxyImpl::Initialize() { | 144 bool CommandBufferProxyImpl::Initialize() { |
144 TRACE_EVENT0("gpu", "CommandBufferProxyImpl::Initialize"); | 145 TRACE_EVENT0("gpu", "CommandBufferProxyImpl::Initialize"); |
145 shared_state_shm_.reset(channel_->factory()->AllocateSharedMemory( | 146 shared_state_shm_.reset(channel_->factory()->AllocateSharedMemory( |
146 sizeof(*shared_state())).release()); | 147 sizeof(*shared_state())).release()); |
147 if (!shared_state_shm_) | 148 if (!shared_state_shm_) |
148 return false; | 149 return false; |
149 | 150 |
150 if (!shared_state_shm_->Map(sizeof(*shared_state()))) | 151 if (!shared_state_shm_->Map(sizeof(*shared_state()))) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 } | 609 } |
609 } | 610 } |
610 | 611 |
611 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, | 612 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, |
612 base::TimeDelta interval) { | 613 base::TimeDelta interval) { |
613 if (!update_vsync_parameters_completion_callback_.is_null()) | 614 if (!update_vsync_parameters_completion_callback_.is_null()) |
614 update_vsync_parameters_completion_callback_.Run(timebase, interval); | 615 update_vsync_parameters_completion_callback_.Run(timebase, interval); |
615 } | 616 } |
616 | 617 |
617 } // namespace content | 618 } // namespace content |
OLD | NEW |