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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 } | 55 } |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 StagingBuffer::StagingBuffer(const gfx::Size& size, ResourceFormat format) | 59 StagingBuffer::StagingBuffer(const gfx::Size& size, ResourceFormat format) |
60 : size(size), | 60 : size(size), |
61 format(format), | 61 format(format), |
62 texture_id(0), | 62 texture_id(0), |
63 image_id(0), | 63 image_id(0), |
64 query_id(0), | 64 query_id(0), |
65 content_id(0) {} | 65 content_id(0) {} |
tasak
2016/08/26 10:08:04
Need to register this with ChildMemoryCoordinator
| |
66 | 66 |
67 StagingBuffer::~StagingBuffer() { | 67 StagingBuffer::~StagingBuffer() { |
68 DCHECK_EQ(texture_id, 0u); | 68 DCHECK_EQ(texture_id, 0u); |
69 DCHECK_EQ(image_id, 0u); | 69 DCHECK_EQ(image_id, 0u); |
70 DCHECK_EQ(query_id, 0u); | 70 DCHECK_EQ(query_id, 0u); |
tasak
2016/08/26 10:08:04
Need to unregister this with ChildMemoryCoordinato
| |
71 } | 71 } |
72 | 72 |
73 void StagingBuffer::DestroyGLResources(gpu::gles2::GLES2Interface* gl) { | 73 void StagingBuffer::DestroyGLResources(gpu::gles2::GLES2Interface* gl) { |
74 if (query_id) { | 74 if (query_id) { |
75 gl->DeleteQueriesEXT(1, &query_id); | 75 gl->DeleteQueriesEXT(1, &query_id); |
76 query_id = 0; | 76 query_id = 0; |
77 } | 77 } |
78 if (image_id) { | 78 if (image_id) { |
79 gl->DestroyImageCHROMIUM(image_id); | 79 gl->DestroyImageCHROMIUM(image_id); |
80 image_id = 0; | 80 image_id = 0; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 if (busy_buffers_.front()->last_usage > time) | 402 if (busy_buffers_.front()->last_usage > time) |
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 void StagingBufferPool::OnMemoryStateChange( | |
413 memory_coordinator::mojom::MemoryState state) { | |
414 if (state == memory_coordinator::mojom::MemoryState::SUSPENDED) { | |
415 base::AutoLock lock(lock_); | |
416 if (buffers_.empty()) | |
417 return; | |
418 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); | |
419 } | |
420 } | |
421 | |
412 } // namespace cc | 422 } // namespace cc |
OLD | NEW |