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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 state.num_entries = num_entries_; | 96 state.num_entries = num_entries_; |
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.generation = ++generation_; | 101 state.generation = ++generation_; |
102 | 102 |
103 return state; | 103 return state; |
104 } | 104 } |
105 | 105 |
| 106 CommandBufferService::State CommandBufferService::GetLastState() { |
| 107 return GetState(); |
| 108 } |
| 109 |
106 CommandBufferService::State CommandBufferService::FlushSync( | 110 CommandBufferService::State CommandBufferService::FlushSync( |
107 int32 put_offset, int32 last_known_get) { | 111 int32 put_offset, int32 last_known_get) { |
108 if (put_offset < 0 || put_offset > num_entries_) { | 112 if (put_offset < 0 || put_offset > num_entries_) { |
109 error_ = gpu::error::kOutOfBounds; | 113 error_ = gpu::error::kOutOfBounds; |
110 return GetState(); | 114 return GetState(); |
111 } | 115 } |
112 | 116 |
113 put_offset_ = put_offset; | 117 put_offset_ = put_offset; |
114 | 118 |
115 if (put_offset_change_callback_.get()) { | 119 if (put_offset_change_callback_.get()) { |
116 put_offset_change_callback_->Run(last_known_get == get_offset_); | 120 put_offset_change_callback_->Run(); |
117 } | 121 } |
118 | 122 |
119 return GetState(); | 123 return GetState(); |
120 } | 124 } |
121 | 125 |
122 void CommandBufferService::Flush(int32 put_offset) { | 126 void CommandBufferService::Flush(int32 put_offset) { |
123 if (put_offset < 0 || put_offset > num_entries_) { | 127 if (put_offset < 0 || put_offset > num_entries_) { |
124 error_ = gpu::error::kOutOfBounds; | 128 error_ = gpu::error::kOutOfBounds; |
125 return; | 129 return; |
126 } | 130 } |
127 | 131 |
128 put_offset_ = put_offset; | 132 put_offset_ = put_offset; |
129 | 133 |
130 if (put_offset_change_callback_.get()) { | 134 if (put_offset_change_callback_.get()) { |
131 put_offset_change_callback_->Run(false); | 135 put_offset_change_callback_->Run(); |
132 } | 136 } |
133 } | 137 } |
134 | 138 |
135 void CommandBufferService::SetGetOffset(int32 get_offset) { | 139 void CommandBufferService::SetGetOffset(int32 get_offset) { |
136 DCHECK(get_offset >= 0 && get_offset < num_entries_); | 140 DCHECK(get_offset >= 0 && get_offset < num_entries_); |
137 get_offset_ = get_offset; | 141 get_offset_ = get_offset; |
138 } | 142 } |
139 | 143 |
140 int32 CommandBufferService::CreateTransferBuffer(size_t size, | 144 int32 CommandBufferService::CreateTransferBuffer(size_t size, |
141 int32 id_request) { | 145 int32 id_request) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 252 |
249 void CommandBufferService::SetParseError(error::Error error) { | 253 void CommandBufferService::SetParseError(error::Error error) { |
250 if (error_ == error::kNoError) { | 254 if (error_ == error::kNoError) { |
251 error_ = error; | 255 error_ = error; |
252 if (parse_error_callback_.get()) | 256 if (parse_error_callback_.get()) |
253 parse_error_callback_->Run(); | 257 parse_error_callback_->Run(); |
254 } | 258 } |
255 } | 259 } |
256 | 260 |
257 void CommandBufferService::SetPutOffsetChangeCallback( | 261 void CommandBufferService::SetPutOffsetChangeCallback( |
258 Callback1<bool>::Type* callback) { | 262 Callback0::Type* callback) { |
259 put_offset_change_callback_.reset(callback); | 263 put_offset_change_callback_.reset(callback); |
260 } | 264 } |
261 | 265 |
262 void CommandBufferService::SetParseErrorCallback( | 266 void CommandBufferService::SetParseErrorCallback( |
263 Callback0::Type* callback) { | 267 Callback0::Type* callback) { |
264 parse_error_callback_.reset(callback); | 268 parse_error_callback_.reset(callback); |
265 } | 269 } |
266 | 270 |
267 } // namespace gpu | 271 } // namespace gpu |
OLD | NEW |