Index: gpu/command_buffer/client/fenced_allocator.cc |
diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc |
index 0e90bf385b4d0f8a9dded299cfb5a04b1aef2137..4e405e94e7ad5626094fe9fb91ec365f00189835 100644 |
--- a/gpu/command_buffer/client/fenced_allocator.cc |
+++ b/gpu/command_buffer/client/fenced_allocator.cc |
@@ -34,8 +34,10 @@ const FencedAllocator::Offset FencedAllocator::kInvalidOffset; |
#endif |
FencedAllocator::FencedAllocator(unsigned int size, |
- CommandBufferHelper *helper) |
+ CommandBufferHelper* helper, |
+ const base::Closure& poll_callback) |
: helper_(helper), |
+ poll_callback_(poll_callback), |
bytes_in_use_(0) { |
Block block = { FREE, 0, RoundDown(size), kUnusedToken }; |
blocks_.push_back(block); |
@@ -203,10 +205,13 @@ FencedAllocator::BlockIndex FencedAllocator::WaitForTokenAndFreeBlock( |
// Frees any blocks pending a token for which the token has been read. |
void FencedAllocator::FreeUnused() { |
- int32 last_token_read = helper_->last_token_read(); |
+ // Free any potential blocks that has its lifetime handled outside. |
+ poll_callback_.Run(); |
+ |
for (unsigned int i = 0; i < blocks_.size();) { |
Block& block = blocks_[i]; |
- if (block.state == FREE_PENDING_TOKEN && block.token <= last_token_read) { |
+ if (block.state == FREE_PENDING_TOKEN && |
+ helper_->HasTokenPassed(block.token)) { |
block.state = FREE; |
i = CollapseFreeBlock(i); |
} else { |