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