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 "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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 put_offset_change_callback_.Run(); | 81 put_offset_change_callback_.Run(); |
82 } | 82 } |
83 | 83 |
84 void CommandBufferService::SetGetBuffer(int32 transfer_buffer_id) { | 84 void CommandBufferService::SetGetBuffer(int32 transfer_buffer_id) { |
85 DCHECK_EQ(-1, ring_buffer_id_); | 85 DCHECK_EQ(-1, ring_buffer_id_); |
86 DCHECK_EQ(put_offset_, get_offset_); // Only if it's empty. | 86 DCHECK_EQ(put_offset_, get_offset_); // Only if it's empty. |
87 // If the buffer is invalid we handle it gracefully. | 87 // If the buffer is invalid we handle it gracefully. |
88 // This means ring_buffer_ can be NULL. | 88 // This means ring_buffer_ can be NULL. |
89 ring_buffer_ = GetTransferBuffer(transfer_buffer_id); | 89 ring_buffer_ = GetTransferBuffer(transfer_buffer_id); |
90 ring_buffer_id_ = transfer_buffer_id; | 90 ring_buffer_id_ = transfer_buffer_id; |
91 int32 size = ring_buffer_ ? ring_buffer_->size() : 0; | 91 int32 size = ring_buffer_.get() ? ring_buffer_->size() : 0; |
92 num_entries_ = size / sizeof(CommandBufferEntry); | 92 num_entries_ = size / sizeof(CommandBufferEntry); |
93 put_offset_ = 0; | 93 put_offset_ = 0; |
94 SetGetOffset(0); | 94 SetGetOffset(0); |
95 if (!get_buffer_change_callback_.is_null()) { | 95 if (!get_buffer_change_callback_.is_null()) { |
96 get_buffer_change_callback_.Run(ring_buffer_id_); | 96 get_buffer_change_callback_.Run(ring_buffer_id_); |
97 } | 97 } |
98 | 98 |
99 UpdateState(); | 99 UpdateState(); |
100 } | 100 } |
101 | 101 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 const GetBufferChangedCallback& callback) { | 183 const GetBufferChangedCallback& callback) { |
184 get_buffer_change_callback_ = callback; | 184 get_buffer_change_callback_ = callback; |
185 } | 185 } |
186 | 186 |
187 void CommandBufferService::SetParseErrorCallback( | 187 void CommandBufferService::SetParseErrorCallback( |
188 const base::Closure& callback) { | 188 const base::Closure& callback) { |
189 parse_error_callback_ = callback; | 189 parse_error_callback_ = callback; |
190 } | 190 } |
191 | 191 |
192 } // namespace gpu | 192 } // namespace gpu |
OLD | NEW |