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 // This file contains the implementation of the FencedAllocator class. | 5 // This file contains the implementation of the FencedAllocator class. |
6 | 6 |
7 #include "../client/fenced_allocator.h" | 7 #include "gpu/command_buffer/client/fenced_allocator.h" |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include "../client/cmd_buffer_helper.h" | 9 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
10 | 10 |
11 namespace gpu { | 11 namespace gpu { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Allocation alignment, must be a power of two. | 15 // Allocation alignment, must be a power of two. |
16 const unsigned int kAllocAlignment = 16; | 16 const unsigned int kAllocAlignment = 16; |
17 | 17 |
18 // Round down to the largest multiple of kAllocAlignment no greater than |size|. | 18 // Round down to the largest multiple of kAllocAlignment no greater than |size|. |
19 unsigned int RoundDown(unsigned int size) { | 19 unsigned int RoundDown(unsigned int size) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // The blocks are in offset order, so we can do a binary search. | 226 // The blocks are in offset order, so we can do a binary search. |
227 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { | 227 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { |
228 Block templ = { IN_USE, offset, 0, kUnusedToken }; | 228 Block templ = { IN_USE, offset, 0, kUnusedToken }; |
229 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), | 229 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), |
230 templ, OffsetCmp()); | 230 templ, OffsetCmp()); |
231 GPU_DCHECK(it != blocks_.end() && it->offset == offset); | 231 GPU_DCHECK(it != blocks_.end() && it->offset == offset); |
232 return it-blocks_.begin(); | 232 return it-blocks_.begin(); |
233 } | 233 } |
234 | 234 |
235 } // namespace gpu | 235 } // namespace gpu |
OLD | NEW |