OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/base/contiguous_container.h" | 5 #include "cc/base/contiguous_container.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 DCHECK_LE(begin(), object); | 37 DCHECK_LE(begin(), object); |
38 DCHECK_LT(object, end_); | 38 DCHECK_LT(object, end_); |
39 end_ = static_cast<char*>(object); | 39 end_ = static_cast<char*>(object); |
40 } | 40 } |
41 | 41 |
42 private: | 42 private: |
43 char* begin() { return &data_[0]; } | 43 char* begin() { return &data_[0]; } |
44 const char* begin() const { return &data_[0]; } | 44 const char* begin() const { return &data_[0]; } |
45 | 45 |
46 // begin() <= end_ <= begin() + capacity_ | 46 // begin() <= end_ <= begin() + capacity_ |
47 scoped_ptr<char[]> data_; | 47 std::unique_ptr<char[]> data_; |
48 char* end_; | 48 char* end_; |
49 size_t capacity_; | 49 size_t capacity_; |
50 }; | 50 }; |
51 | 51 |
52 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size) | 52 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size) |
53 : end_index_(0), max_object_size_(max_object_size) {} | 53 : end_index_(0), max_object_size_(max_object_size) {} |
54 | 54 |
55 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size, | 55 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size, |
56 size_t initial_size_bytes) | 56 size_t initial_size_bytes) |
57 : ContiguousContainerBase(max_object_size) { | 57 : ContiguousContainerBase(max_object_size) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 elements_.swap(other.elements_); | 129 elements_.swap(other.elements_); |
130 buffers_.swap(other.buffers_); | 130 buffers_.swap(other.buffers_); |
131 std::swap(end_index_, other.end_index_); | 131 std::swap(end_index_, other.end_index_); |
132 std::swap(max_object_size_, other.max_object_size_); | 132 std::swap(max_object_size_, other.max_object_size_); |
133 } | 133 } |
134 | 134 |
135 ContiguousContainerBase::Buffer* | 135 ContiguousContainerBase::Buffer* |
136 ContiguousContainerBase::AllocateNewBufferForNextAllocation( | 136 ContiguousContainerBase::AllocateNewBufferForNextAllocation( |
137 size_t buffer_size) { | 137 size_t buffer_size) { |
138 DCHECK(buffers_.empty() || end_index_ == buffers_.size() - 1); | 138 DCHECK(buffers_.empty() || end_index_ == buffers_.size() - 1); |
139 scoped_ptr<Buffer> new_buffer(new Buffer(buffer_size)); | 139 std::unique_ptr<Buffer> new_buffer(new Buffer(buffer_size)); |
140 Buffer* buffer_to_return = new_buffer.get(); | 140 Buffer* buffer_to_return = new_buffer.get(); |
141 buffers_.push_back(std::move(new_buffer)); | 141 buffers_.push_back(std::move(new_buffer)); |
142 end_index_ = buffers_.size() - 1; | 142 end_index_ = buffers_.size() - 1; |
143 return buffer_to_return; | 143 return buffer_to_return; |
144 } | 144 } |
145 | 145 |
146 } // namespace cc | 146 } // namespace cc |
OLD | NEW |