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 "cc/resources/resource_provider.h" | 7 #include "cc/resources/resource_provider.h" |
8 #include "cc/resources/scoped_resource.h" | 8 #include "cc/resources/scoped_resource.h" |
| 9 #include "ui/gfx/gpu_memory_buffer.h" |
9 | 10 |
10 namespace cc { | 11 namespace cc { |
11 | 12 |
12 ResourcePool::ResourcePool(ResourceProvider* resource_provider, GLenum target) | 13 ResourcePool::ResourcePool(ResourceProvider* resource_provider, |
| 14 std::vector<uint> targets) |
13 : resource_provider_(resource_provider), | 15 : resource_provider_(resource_provider), |
14 target_(target), | 16 targets_(targets), |
15 max_memory_usage_bytes_(0), | 17 max_memory_usage_bytes_(0), |
16 max_unused_memory_usage_bytes_(0), | 18 max_unused_memory_usage_bytes_(0), |
17 max_resource_count_(0), | 19 max_resource_count_(0), |
18 memory_usage_bytes_(0), | 20 memory_usage_bytes_(0), |
19 unused_memory_usage_bytes_(0), | 21 unused_memory_usage_bytes_(0), |
20 resource_count_(0) {} | 22 resource_count_(0) {} |
21 | 23 |
22 ResourcePool::~ResourcePool() { | 24 ResourcePool::~ResourcePool() { |
23 while (!busy_resources_.empty()) { | 25 while (!busy_resources_.empty()) { |
24 auto const& front = busy_resources_.front(); | 26 auto const& front = busy_resources_.front(); |
(...skipping 22 matching lines...) Expand all Loading... |
47 continue; | 49 continue; |
48 | 50 |
49 unused_resources_.erase(it); | 51 unused_resources_.erase(it); |
50 unused_memory_usage_bytes_ -= | 52 unused_memory_usage_bytes_ -= |
51 Resource::UncheckedMemorySizeBytes(size, format); | 53 Resource::UncheckedMemorySizeBytes(size, format); |
52 return make_scoped_ptr(resource); | 54 return make_scoped_ptr(resource); |
53 } | 55 } |
54 | 56 |
55 scoped_ptr<ScopedResource> resource = | 57 scoped_ptr<ScopedResource> resource = |
56 ScopedResource::Create(resource_provider_); | 58 ScopedResource::Create(resource_provider_); |
57 resource->AllocateManaged(size, target_, format); | 59 resource->AllocateManaged( |
| 60 size, targets_[resource_provider_->ToGpuMemoryBufferFormat(format)], |
| 61 format); |
58 | 62 |
59 DCHECK(Resource::VerifySizeInBytes(resource->size(), resource->format())); | 63 DCHECK(Resource::VerifySizeInBytes(resource->size(), resource->format())); |
60 memory_usage_bytes_ += | 64 memory_usage_bytes_ += |
61 Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); | 65 Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); |
62 ++resource_count_; | 66 ++resource_count_; |
63 return resource.Pass(); | 67 return resource.Pass(); |
64 } | 68 } |
65 | 69 |
66 scoped_ptr<ScopedResource> ResourcePool::TryAcquireResourceWithContentId( | 70 scoped_ptr<ScopedResource> ResourcePool::TryAcquireResourceWithContentId( |
67 uint64_t content_id) { | 71 uint64_t content_id) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 154 } |
151 | 155 |
152 void ResourcePool::DidFinishUsingResource(ScopedResource* resource, | 156 void ResourcePool::DidFinishUsingResource(ScopedResource* resource, |
153 uint64_t content_id) { | 157 uint64_t content_id) { |
154 unused_memory_usage_bytes_ += | 158 unused_memory_usage_bytes_ += |
155 Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); | 159 Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); |
156 unused_resources_.push_back(PoolResource(resource, content_id)); | 160 unused_resources_.push_back(PoolResource(resource, content_id)); |
157 } | 161 } |
158 | 162 |
159 } // namespace cc | 163 } // namespace cc |
OLD | NEW |