| 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 "platform/graphics/ContiguousContainer.h" | 5 #include "platform/graphics/ContiguousContainer.h" |
| 6 | 6 |
| 7 #include "wtf/Allocator.h" | 7 #include "wtf/Allocator.h" |
| 8 #include "wtf/ContainerAnnotations.h" | 8 #include "wtf/ContainerAnnotations.h" |
| 9 #include "wtf/PtrUtil.h" | 9 #include "wtf/PtrUtil.h" |
| 10 #include "wtf/allocator/PartitionAlloc.h" | 10 #include "wtf/allocator/PartitionAlloc.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ContiguousContainerBase::swap(ContiguousContainerBase& other) | 166 void ContiguousContainerBase::swap(ContiguousContainerBase& other) |
| 167 { | 167 { |
| 168 m_elements.swap(other.m_elements); | 168 m_elements.swap(other.m_elements); |
| 169 m_buffers.swap(other.m_buffers); | 169 m_buffers.swap(other.m_buffers); |
| 170 std::swap(m_endIndex, other.m_endIndex); | 170 std::swap(m_endIndex, other.m_endIndex); |
| 171 std::swap(m_maxObjectSize, other.m_maxObjectSize); | 171 std::swap(m_maxObjectSize, other.m_maxObjectSize); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ContiguousContainerBase::removeEmptyBuffers() |
| 175 { |
| 176 while (m_endIndex < m_buffers.size() - 1) |
| 177 m_buffers.removeLast(); |
| 178 } |
| 179 |
| 174 ContiguousContainerBase::Buffer* | 180 ContiguousContainerBase::Buffer* |
| 175 ContiguousContainerBase::allocateNewBufferForNextAllocation(size_t bufferSize, c
onst char* typeName) | 181 ContiguousContainerBase::allocateNewBufferForNextAllocation(size_t bufferSize, c
onst char* typeName) |
| 176 { | 182 { |
| 177 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1); | 183 ASSERT(m_buffers.isEmpty() || m_endIndex == m_buffers.size() - 1); |
| 178 std::unique_ptr<Buffer> newBuffer = wrapUnique(new Buffer(bufferSize, typeNa
me)); | 184 std::unique_ptr<Buffer> newBuffer = wrapUnique(new Buffer(bufferSize, typeNa
me)); |
| 179 Buffer* bufferToReturn = newBuffer.get(); | 185 Buffer* bufferToReturn = newBuffer.get(); |
| 180 m_buffers.append(std::move(newBuffer)); | 186 m_buffers.append(std::move(newBuffer)); |
| 181 m_endIndex = m_buffers.size() - 1; | 187 m_endIndex = m_buffers.size() - 1; |
| 182 return bufferToReturn; | 188 return bufferToReturn; |
| 183 } | 189 } |
| 184 | 190 |
| 185 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |