Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: cc/resources/resource_pool.cc

Issue 1422103003: cc: Remove the ability to specify a GL texture target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_pool.h ('k') | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 if (is_free) { 49 if (is_free) {
50 dump->AddScalar("free_size", 50 dump->AddScalar("free_size",
51 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 51 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
52 total_bytes); 52 total_bytes);
53 } 53 }
54 } 54 }
55 55
56 ResourcePool::ResourcePool(ResourceProvider* resource_provider, 56 ResourcePool::ResourcePool(ResourceProvider* resource_provider,
57 base::SingleThreadTaskRunner* task_runner, 57 base::SingleThreadTaskRunner* task_runner,
58 GLenum target) 58 bool use_image_texture_target)
59 : resource_provider_(resource_provider), 59 : resource_provider_(resource_provider),
60 target_(target), 60 use_image_texture_target_(use_image_texture_target),
61 max_memory_usage_bytes_(0), 61 max_memory_usage_bytes_(0),
62 max_resource_count_(0), 62 max_resource_count_(0),
63 in_use_memory_usage_bytes_(0), 63 in_use_memory_usage_bytes_(0),
64 total_memory_usage_bytes_(0), 64 total_memory_usage_bytes_(0),
65 total_resource_count_(0), 65 total_resource_count_(0),
66 task_runner_(task_runner), 66 task_runner_(task_runner),
67 evict_expired_resources_pending_(false), 67 evict_expired_resources_pending_(false),
68 resource_expiration_delay_( 68 resource_expiration_delay_(
69 base::TimeDelta::FromMilliseconds(kResourceExpirationDelayMs)), 69 base::TimeDelta::FromMilliseconds(kResourceExpirationDelayMs)),
70 weak_ptr_factory_(this) { 70 weak_ptr_factory_(this) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Transfer resource to |in_use_resources_|. 104 // Transfer resource to |in_use_resources_|.
105 in_use_resources_.set(resource->id(), unused_resources_.take(it)); 105 in_use_resources_.set(resource->id(), unused_resources_.take(it));
106 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( 106 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>(
107 resource->size(), resource->format()); 107 resource->size(), resource->format());
108 return resource; 108 return resource;
109 } 109 }
110 110
111 scoped_ptr<PoolResource> pool_resource = 111 scoped_ptr<PoolResource> pool_resource =
112 PoolResource::Create(resource_provider_); 112 PoolResource::Create(resource_provider_);
113 GLenum target = 113
114 target_ ? target_ : resource_provider_->GetImageTextureTarget(format); 114 if (use_image_texture_target_) {
115 pool_resource->AllocateWithTextureTarget(size, target, format); 115 pool_resource->AllocateWithImageTextureTarget(size, format);
116 } else {
117 pool_resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
118 format);
119 }
116 120
117 DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(pool_resource->size(), 121 DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(pool_resource->size(),
118 pool_resource->format())); 122 pool_resource->format()));
119 total_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( 123 total_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>(
120 pool_resource->size(), pool_resource->format()); 124 pool_resource->size(), pool_resource->format());
121 ++total_resource_count_; 125 ++total_resource_count_;
122 126
123 Resource* resource = pool_resource.get(); 127 Resource* resource = pool_resource.get();
124 in_use_resources_.set(resource->id(), pool_resource.Pass()); 128 in_use_resources_.set(resource->id(), pool_resource.Pass());
125 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( 129 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>(
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 for (const auto& resource : busy_resources_) { 300 for (const auto& resource : busy_resources_) {
297 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 301 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
298 } 302 }
299 for (const auto& entry : in_use_resources_) { 303 for (const auto& entry : in_use_resources_) {
300 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 304 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
301 } 305 }
302 return true; 306 return true;
303 } 307 }
304 308
305 } // namespace cc 309 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_pool.h ('k') | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698