OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/raster/staging_buffer_pool.h" | 5 #include "cc/raster/staging_buffer_pool.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 }); | 298 }); |
299 if (it != free_buffers_.end()) { | 299 if (it != free_buffers_.end()) { |
300 staging_buffer = std::move(*it); | 300 staging_buffer = std::move(*it); |
301 free_buffers_.erase(it); | 301 free_buffers_.erase(it); |
302 MarkStagingBufferAsBusy(staging_buffer.get()); | 302 MarkStagingBufferAsBusy(staging_buffer.get()); |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 // Create new staging buffer if necessary. | 306 // Create new staging buffer if necessary. |
307 if (!staging_buffer) { | 307 if (!staging_buffer) { |
308 staging_buffer = base::WrapUnique( | 308 staging_buffer = |
309 new StagingBuffer(resource->size(), resource->format())); | 309 base::MakeUnique<StagingBuffer>(resource->size(), resource->format()); |
310 AddStagingBuffer(staging_buffer.get(), resource->format()); | 310 AddStagingBuffer(staging_buffer.get(), resource->format()); |
311 } | 311 } |
312 | 312 |
313 // Release enough free buffers to stay within the limit. | 313 // Release enough free buffers to stay within the limit. |
314 while (staging_buffer_usage_in_bytes_ > max_staging_buffer_usage_in_bytes_) { | 314 while (staging_buffer_usage_in_bytes_ > max_staging_buffer_usage_in_bytes_) { |
315 if (free_buffers_.empty()) | 315 if (free_buffers_.empty()) |
316 break; | 316 break; |
317 | 317 |
318 free_buffers_.front()->DestroyGLResources(gl); | 318 free_buffers_.front()->DestroyGLResources(gl); |
319 MarkStagingBufferAsBusy(free_buffers_.front().get()); | 319 MarkStagingBufferAsBusy(free_buffers_.front().get()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return; | 403 return; |
404 | 404 |
405 busy_buffers_.front()->DestroyGLResources(gl); | 405 busy_buffers_.front()->DestroyGLResources(gl); |
406 RemoveStagingBuffer(busy_buffers_.front().get()); | 406 RemoveStagingBuffer(busy_buffers_.front().get()); |
407 busy_buffers_.pop_front(); | 407 busy_buffers_.pop_front(); |
408 } | 408 } |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 } // namespace cc | 412 } // namespace cc |
OLD | NEW |