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 "ppapi/proxy/ppapi_command_buffer_proxy.h" | 5 #include "ppapi/proxy/ppapi_command_buffer_proxy.h" |
6 | 6 |
7 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" |
8 #include "ppapi/proxy/proxy_channel.h" | 8 #include "ppapi/proxy/proxy_channel.h" |
9 #include "ppapi/shared_impl/api_id.h" | 9 #include "ppapi/shared_impl/api_id.h" |
10 #include "ppapi/shared_impl/host_resource.h" | 10 #include "ppapi/shared_impl/host_resource.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 bool PpapiCommandBufferProxy::Initialize() { | 93 bool PpapiCommandBufferProxy::Initialize() { |
94 return Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer( | 94 return Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer( |
95 ppapi::API_ID_PPB_GRAPHICS_3D, resource_)); | 95 ppapi::API_ID_PPB_GRAPHICS_3D, resource_)); |
96 } | 96 } |
97 | 97 |
98 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetState() { | 98 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetState() { |
99 // Send will flag state with lost context if IPC fails. | 99 // Send will flag state with lost context if IPC fails. |
100 if (last_state_.error == gpu::error::kNoError) { | 100 if (last_state_.error == gpu::error::kNoError) { |
101 gpu::CommandBuffer::State state; | 101 gpu::CommandBuffer::State state; |
| 102 bool success = false; |
102 if (Send(new PpapiHostMsg_PPBGraphics3D_GetState( | 103 if (Send(new PpapiHostMsg_PPBGraphics3D_GetState( |
103 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &state))) { | 104 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, &state, &success))) { |
104 UpdateState(state); | 105 UpdateState(state, success); |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 return last_state_; | 109 return last_state_; |
109 } | 110 } |
110 | 111 |
111 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() { | 112 gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() { |
112 return last_state_; | 113 return last_state_; |
113 } | 114 } |
114 | 115 |
(...skipping 10 matching lines...) Expand all Loading... |
125 message->set_unblock(true); | 126 message->set_unblock(true); |
126 Send(message); | 127 Send(message); |
127 } | 128 } |
128 | 129 |
129 gpu::CommandBuffer::State PpapiCommandBufferProxy::FlushSync(int32 put_offset, | 130 gpu::CommandBuffer::State PpapiCommandBufferProxy::FlushSync(int32 put_offset, |
130 int32 last_known_get) { | 131 int32 last_known_get) { |
131 if (last_known_get == last_state_.get_offset) { | 132 if (last_known_get == last_state_.get_offset) { |
132 // Send will flag state with lost context if IPC fails. | 133 // Send will flag state with lost context if IPC fails. |
133 if (last_state_.error == gpu::error::kNoError) { | 134 if (last_state_.error == gpu::error::kNoError) { |
134 gpu::CommandBuffer::State state; | 135 gpu::CommandBuffer::State state; |
| 136 bool success = false; |
135 if (Send(new PpapiHostMsg_PPBGraphics3D_Flush( | 137 if (Send(new PpapiHostMsg_PPBGraphics3D_Flush( |
136 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, put_offset, | 138 ppapi::API_ID_PPB_GRAPHICS_3D, resource_, put_offset, |
137 last_known_get, &state))) { | 139 last_known_get, &state, &success))) { |
138 UpdateState(state); | 140 UpdateState(state, success); |
139 } | 141 } |
140 } | 142 } |
141 } else { | 143 } else { |
142 Flush(put_offset); | 144 Flush(put_offset); |
143 } | 145 } |
144 return last_state_; | 146 return last_state_; |
145 } | 147 } |
146 | 148 |
147 void PpapiCommandBufferProxy::SetGetBuffer(int32 transfer_buffer_id) { | 149 void PpapiCommandBufferProxy::SetGetBuffer(int32 transfer_buffer_id) { |
148 if (last_state_.error == gpu::error::kNoError) { | 150 if (last_state_.error == gpu::error::kNoError) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 DCHECK(last_state_.error == gpu::error::kNoError); | 254 DCHECK(last_state_.error == gpu::error::kNoError); |
253 | 255 |
254 if (channel_->Send(msg)) | 256 if (channel_->Send(msg)) |
255 return true; | 257 return true; |
256 | 258 |
257 last_state_.error = gpu::error::kLostContext; | 259 last_state_.error = gpu::error::kLostContext; |
258 return false; | 260 return false; |
259 } | 261 } |
260 | 262 |
261 void PpapiCommandBufferProxy::UpdateState( | 263 void PpapiCommandBufferProxy::UpdateState( |
262 const gpu::CommandBuffer::State& state) { | 264 const gpu::CommandBuffer::State& state, |
| 265 bool success) { |
263 // Handle wraparound. It works as long as we don't have more than 2B state | 266 // Handle wraparound. It works as long as we don't have more than 2B state |
264 // updates in flight across which reordering occurs. | 267 // updates in flight across which reordering occurs. |
265 if (state.generation - last_state_.generation < 0x80000000U) | 268 if (success) { |
266 last_state_ = state; | 269 if (state.generation - last_state_.generation < 0x80000000U) { |
| 270 last_state_ = state; |
| 271 } else |
| 272 last_state_.error = gpu::error::kLostContext; |
| 273 ++last_state_.generation; |
| 274 } |
267 } | 275 } |
268 | 276 |
269 } // namespace proxy | 277 } // namespace proxy |
270 } // namespace ppapi | 278 } // namespace ppapi |
271 | 279 |
OLD | NEW |