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 "gpu/command_buffer/service/command_buffer_service.h" | 5 #include "gpu/command_buffer/service/command_buffer_service.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 state.get_offset = get_offset_; | 97 state.get_offset = get_offset_; |
98 state.put_offset = put_offset_; | 98 state.put_offset = put_offset_; |
99 state.token = token_; | 99 state.token = token_; |
100 state.error = error_; | 100 state.error = error_; |
101 state.context_lost_reason = context_lost_reason_; | 101 state.context_lost_reason = context_lost_reason_; |
102 state.generation = ++generation_; | 102 state.generation = ++generation_; |
103 | 103 |
104 return state; | 104 return state; |
105 } | 105 } |
106 | 106 |
107 CommandBufferService::State CommandBufferService::GetLastState() { | |
108 return GetState(); | |
109 } | |
110 | |
111 CommandBufferService::State CommandBufferService::FlushSync( | 107 CommandBufferService::State CommandBufferService::FlushSync( |
112 int32 put_offset, int32 last_known_get) { | 108 int32 put_offset, int32 last_known_get) { |
113 if (put_offset < 0 || put_offset > num_entries_) { | 109 if (put_offset < 0 || put_offset > num_entries_) { |
114 error_ = gpu::error::kOutOfBounds; | 110 error_ = gpu::error::kOutOfBounds; |
115 return GetState(); | 111 return GetState(); |
116 } | 112 } |
117 | 113 |
118 put_offset_ = put_offset; | 114 put_offset_ = put_offset; |
119 | 115 |
120 if (put_offset_change_callback_.get()) { | 116 if (put_offset_change_callback_.get()) { |
121 put_offset_change_callback_->Run(); | 117 put_offset_change_callback_->Run(last_known_get == get_offset_); |
122 } | 118 } |
123 | 119 |
124 return GetState(); | 120 return GetState(); |
125 } | 121 } |
126 | 122 |
127 void CommandBufferService::Flush(int32 put_offset) { | 123 void CommandBufferService::Flush(int32 put_offset) { |
128 if (put_offset < 0 || put_offset > num_entries_) { | 124 if (put_offset < 0 || put_offset > num_entries_) { |
129 error_ = gpu::error::kOutOfBounds; | 125 error_ = gpu::error::kOutOfBounds; |
130 return; | 126 return; |
131 } | 127 } |
132 | 128 |
133 put_offset_ = put_offset; | 129 put_offset_ = put_offset; |
134 | 130 |
135 if (put_offset_change_callback_.get()) { | 131 if (put_offset_change_callback_.get()) { |
136 put_offset_change_callback_->Run(); | 132 put_offset_change_callback_->Run(false); |
137 } | 133 } |
138 } | 134 } |
139 | 135 |
140 void CommandBufferService::SetGetOffset(int32 get_offset) { | 136 void CommandBufferService::SetGetOffset(int32 get_offset) { |
141 DCHECK(get_offset >= 0 && get_offset < num_entries_); | 137 DCHECK(get_offset >= 0 && get_offset < num_entries_); |
142 get_offset_ = get_offset; | 138 get_offset_ = get_offset; |
143 } | 139 } |
144 | 140 |
145 int32 CommandBufferService::CreateTransferBuffer(size_t size, | 141 int32 CommandBufferService::CreateTransferBuffer(size_t size, |
146 int32 id_request) { | 142 int32 id_request) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 parse_error_callback_->Run(); | 254 parse_error_callback_->Run(); |
259 } | 255 } |
260 } | 256 } |
261 | 257 |
262 void CommandBufferService::SetContextLostReason( | 258 void CommandBufferService::SetContextLostReason( |
263 error::ContextLostReason reason) { | 259 error::ContextLostReason reason) { |
264 context_lost_reason_ = reason; | 260 context_lost_reason_ = reason; |
265 } | 261 } |
266 | 262 |
267 void CommandBufferService::SetPutOffsetChangeCallback( | 263 void CommandBufferService::SetPutOffsetChangeCallback( |
268 Callback0::Type* callback) { | 264 Callback1<bool>::Type* callback) { |
269 put_offset_change_callback_.reset(callback); | 265 put_offset_change_callback_.reset(callback); |
270 } | 266 } |
271 | 267 |
272 void CommandBufferService::SetParseErrorCallback( | 268 void CommandBufferService::SetParseErrorCallback( |
273 Callback0::Type* callback) { | 269 Callback0::Type* callback) { |
274 parse_error_callback_.reset(callback); | 270 parse_error_callback_.reset(callback); |
275 } | 271 } |
276 | 272 |
277 } // namespace gpu | 273 } // namespace gpu |
OLD | NEW |