OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/resource_pool.h" | 5 #include "cc/resources/resource_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 DidFinishUsingResource(busy_resources_.take_front()); | 82 DidFinishUsingResource(busy_resources_.take_front()); |
83 } | 83 } |
84 | 84 |
85 SetResourceUsageLimits(0, 0); | 85 SetResourceUsageLimits(0, 0); |
86 DCHECK_EQ(0u, unused_resources_.size()); | 86 DCHECK_EQ(0u, unused_resources_.size()); |
87 DCHECK_EQ(0u, in_use_memory_usage_bytes_); | 87 DCHECK_EQ(0u, in_use_memory_usage_bytes_); |
88 DCHECK_EQ(0u, total_memory_usage_bytes_); | 88 DCHECK_EQ(0u, total_memory_usage_bytes_); |
89 DCHECK_EQ(0u, total_resource_count_); | 89 DCHECK_EQ(0u, total_resource_count_); |
90 } | 90 } |
91 | 91 |
92 Resource* ResourcePool::AcquireResource(const gfx::Size& size, | 92 Resource* ResourcePool::AcquireResource(const gfx::Size& desired_size, |
reveman
2015/09/30 09:55:15
Can we instead just make sure resource dimensions
christiank
2015/11/26 15:35:35
I guess that makes sense. I am not sure if there a
reveman
2015/11/27 16:46:49
https://code.google.com/p/chromium/codesearch#chro
christiank
2015/11/30 15:41:08
Perfect, thanks! Will look at this tomorrow.
christiank
2015/12/01 15:01:07
Should now be fixed.
| |
93 ResourceFormat format) { | 93 ResourceFormat format) { |
94 gfx::Size size = desired_size; | |
95 if (IsResourceFormatCompressed(format) && | |
96 (size.width() % 4 != 0 || size.height() % 4 != 0)) { | |
97 // Round the size up to the nearest multiple of four. | |
98 size.SetSize(4 * std::ceil(static_cast<float>(size.width()) / 4), | |
99 4 * std::ceil(static_cast<float>(size.height()) / 4)); | |
100 } | |
101 | |
94 for (ResourceDeque::iterator it = unused_resources_.begin(); | 102 for (ResourceDeque::iterator it = unused_resources_.begin(); |
95 it != unused_resources_.end(); ++it) { | 103 it != unused_resources_.end(); ++it) { |
96 ScopedResource* resource = *it; | 104 ScopedResource* resource = *it; |
97 DCHECK(resource_provider_->CanLockForWrite(resource->id())); | 105 DCHECK(resource_provider_->CanLockForWrite(resource->id())); |
98 | 106 |
99 if (resource->format() != format) | 107 if (resource->format() != format) |
100 continue; | 108 continue; |
101 if (resource->size() != size) | 109 if (resource->size() != size) |
102 continue; | 110 continue; |
103 | 111 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 for (const auto& resource : busy_resources_) { | 304 for (const auto& resource : busy_resources_) { |
297 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 305 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
298 } | 306 } |
299 for (const auto& entry : in_use_resources_) { | 307 for (const auto& entry : in_use_resources_) { |
300 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 308 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
301 } | 309 } |
302 return true; | 310 return true; |
303 } | 311 } |
304 | 312 |
305 } // namespace cc | 313 } // namespace cc |
OLD | NEW |