| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/gpu/command_buffer_proxy.h" | 5 #include "content/renderer/gpu/command_buffer_proxy.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 gpu::CommandBuffer::State CommandBufferProxy::GetLastState() { | 176 gpu::CommandBuffer::State CommandBufferProxy::GetLastState() { |
| 177 return last_state_; | 177 return last_state_; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void CommandBufferProxy::Flush(int32 put_offset) { | 180 void CommandBufferProxy::Flush(int32 put_offset) { |
| 181 if (last_state_.error != gpu::error::kNoError) | 181 if (last_state_.error != gpu::error::kNoError) |
| 182 return; | 182 return; |
| 183 | 183 |
| 184 TRACE_EVENT1("gpu", "CommandBufferProxy::Flush", "put_offset", put_offset); |
| 185 |
| 184 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_, | 186 Send(new GpuCommandBufferMsg_AsyncFlush(route_id_, |
| 185 put_offset, | 187 put_offset, |
| 186 ++flush_count_)); | 188 ++flush_count_)); |
| 187 } | 189 } |
| 188 | 190 |
| 189 gpu::CommandBuffer::State CommandBufferProxy::FlushSync(int32 put_offset, | 191 gpu::CommandBuffer::State CommandBufferProxy::FlushSync(int32 put_offset, |
| 190 int32 last_known_get) { | 192 int32 last_known_get) { |
| 191 TRACE_EVENT0("gpu", "CommandBufferProxy::FlushSync"); | 193 TRACE_EVENT1("gpu", "CommandBufferProxy::FlushSync", "put_offset", |
| 194 put_offset); |
| 195 Flush(put_offset); |
| 192 if (last_known_get == last_state_.get_offset) { | 196 if (last_known_get == last_state_.get_offset) { |
| 193 // Send will flag state with lost context if IPC fails. | 197 // Send will flag state with lost context if IPC fails. |
| 194 if (last_state_.error == gpu::error::kNoError) { | 198 if (last_state_.error == gpu::error::kNoError) { |
| 195 gpu::CommandBuffer::State state; | 199 gpu::CommandBuffer::State state; |
| 196 if (Send(new GpuCommandBufferMsg_Flush(route_id_, | 200 if (Send(new GpuCommandBufferMsg_GetStateFast(route_id_, |
| 197 put_offset, | 201 &state))) |
| 198 last_known_get, | |
| 199 ++flush_count_, | |
| 200 &state))) | |
| 201 OnUpdateState(state); | 202 OnUpdateState(state); |
| 202 } | 203 } |
| 203 } else { | |
| 204 Flush(put_offset); | |
| 205 } | 204 } |
| 206 | 205 |
| 207 return last_state_; | 206 return last_state_; |
| 208 } | 207 } |
| 209 | 208 |
| 210 void CommandBufferProxy::SetGetOffset(int32 get_offset) { | 209 void CommandBufferProxy::SetGetOffset(int32 get_offset) { |
| 211 // Not implemented in proxy. | 210 // Not implemented in proxy. |
| 212 NOTREACHED(); | 211 NOTREACHED(); |
| 213 } | 212 } |
| 214 | 213 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 delete msg; | 441 delete msg; |
| 443 return false; | 442 return false; |
| 444 } | 443 } |
| 445 | 444 |
| 446 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { | 445 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { |
| 447 // Handle wraparound. It works as long as we don't have more than 2B state | 446 // Handle wraparound. It works as long as we don't have more than 2B state |
| 448 // updates in flight across which reordering occurs. | 447 // updates in flight across which reordering occurs. |
| 449 if (state.generation - last_state_.generation < 0x80000000U) | 448 if (state.generation - last_state_.generation < 0x80000000U) |
| 450 last_state_ = state; | 449 last_state_ = state; |
| 451 } | 450 } |
| OLD | NEW |