OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // This file contains the implementation of the FencedAllocator class. | 33 // This file contains the implementation of the FencedAllocator class. |
34 | 34 |
35 #include "gpu/command_buffer/client/fenced_allocator.h" | 35 #include "gpu/command_buffer/client/fenced_allocator.h" |
36 #include <algorithm> | 36 #include <algorithm> |
37 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 37 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
38 | 38 |
39 namespace command_buffer { | 39 namespace gpu { |
40 | 40 |
41 #ifndef COMPILER_MSVC | 41 #ifndef COMPILER_MSVC |
42 const FencedAllocator::Offset FencedAllocator::kInvalidOffset; | 42 const FencedAllocator::Offset FencedAllocator::kInvalidOffset; |
43 #endif | 43 #endif |
44 | 44 |
45 FencedAllocator::~FencedAllocator() { | 45 FencedAllocator::~FencedAllocator() { |
46 // Free blocks pending tokens. | 46 // Free blocks pending tokens. |
47 for (unsigned int i = 0; i < blocks_.size(); ++i) { | 47 for (unsigned int i = 0; i < blocks_.size(); ++i) { |
48 if (blocks_[i].state == FREE_PENDING_TOKEN) { | 48 if (blocks_[i].state == FREE_PENDING_TOKEN) { |
49 i = WaitForTokenAndFreeBlock(i); | 49 i = WaitForTokenAndFreeBlock(i); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 // The blocks are in offset order, so we can do a binary search. | 205 // The blocks are in offset order, so we can do a binary search. |
206 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { | 206 FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { |
207 Block templ = { IN_USE, offset, 0, kUnusedToken }; | 207 Block templ = { IN_USE, offset, 0, kUnusedToken }; |
208 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), | 208 Container::iterator it = std::lower_bound(blocks_.begin(), blocks_.end(), |
209 templ, OffsetCmp()); | 209 templ, OffsetCmp()); |
210 DCHECK(it != blocks_.end() && it->offset == offset); | 210 DCHECK(it != blocks_.end() && it->offset == offset); |
211 return it-blocks_.begin(); | 211 return it-blocks_.begin(); |
212 } | 212 } |
213 | 213 |
214 } // namespace command_buffer | 214 } // namespace gpu |
OLD | NEW |