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

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

Issue 2254033002: Encourage IOSurface reuse for CSS filter effects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from ericrk. Created 4 years, 4 months 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/trace_event/memory_dump_manager.h" 16 #include "base/trace_event/memory_dump_manager.h"
17 #include "cc/base/container_util.h" 17 #include "cc/base/container_util.h"
18 #include "cc/resources/resource_provider.h" 18 #include "cc/resources/resource_provider.h"
19 #include "cc/resources/resource_util.h" 19 #include "cc/resources/resource_util.h"
20 #include "cc/resources/scoped_resource.h" 20 #include "cc/resources/scoped_resource.h"
21 21
22 namespace cc { 22 namespace cc {
23 namespace { 23 base::TimeDelta ResourcePool::kDefaultExpirationDelay =
24 24 base::TimeDelta::FromSeconds(1);
25 // Delay before a resource is considered expired.
26 const int kResourceExpirationDelayMs = 1000;
27
28 } // namespace
29 25
30 void ResourcePool::PoolResource::OnMemoryDump( 26 void ResourcePool::PoolResource::OnMemoryDump(
31 base::trace_event::ProcessMemoryDump* pmd, 27 base::trace_event::ProcessMemoryDump* pmd,
32 const ResourceProvider* resource_provider, 28 const ResourceProvider* resource_provider,
33 bool is_free) const { 29 bool is_free) const {
34 // Resource IDs are not process-unique, so log with the ResourceProvider's 30 // Resource IDs are not process-unique, so log with the ResourceProvider's
35 // unique id. 31 // unique id.
36 std::string parent_node = 32 std::string parent_node =
37 base::StringPrintf("cc/resource_memory/provider_%d/resource_%d", 33 base::StringPrintf("cc/resource_memory/provider_%d/resource_%d",
38 resource_provider->tracing_id(), id()); 34 resource_provider->tracing_id(), id());
(...skipping 14 matching lines...) Expand all
53 49
54 if (is_free) { 50 if (is_free) {
55 dump->AddScalar("free_size", 51 dump->AddScalar("free_size",
56 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 52 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
57 total_bytes); 53 total_bytes);
58 } 54 }
59 } 55 }
60 56
61 ResourcePool::ResourcePool(ResourceProvider* resource_provider, 57 ResourcePool::ResourcePool(ResourceProvider* resource_provider,
62 base::SingleThreadTaskRunner* task_runner, 58 base::SingleThreadTaskRunner* task_runner,
63 bool use_gpu_memory_buffers) 59 bool use_gpu_memory_buffers,
60 const base::TimeDelta& expiration_delay)
64 : resource_provider_(resource_provider), 61 : resource_provider_(resource_provider),
65 use_gpu_memory_buffers_(use_gpu_memory_buffers), 62 use_gpu_memory_buffers_(use_gpu_memory_buffers),
66 max_memory_usage_bytes_(0), 63 max_memory_usage_bytes_(0),
67 max_resource_count_(0), 64 max_resource_count_(0),
68 in_use_memory_usage_bytes_(0), 65 in_use_memory_usage_bytes_(0),
69 total_memory_usage_bytes_(0), 66 total_memory_usage_bytes_(0),
70 total_resource_count_(0), 67 total_resource_count_(0),
71 task_runner_(task_runner), 68 task_runner_(task_runner),
72 evict_expired_resources_pending_(false), 69 evict_expired_resources_pending_(false),
73 resource_expiration_delay_( 70 resource_expiration_delay_(expiration_delay),
74 base::TimeDelta::FromMilliseconds(kResourceExpirationDelayMs)),
75 weak_ptr_factory_(this) { 71 weak_ptr_factory_(this) {
76 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 72 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
77 this, "cc::ResourcePool", task_runner_.get()); 73 this, "cc::ResourcePool", task_runner_.get());
78 } 74 }
79 75
80 ResourcePool::~ResourcePool() { 76 ResourcePool::~ResourcePool() {
81 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( 77 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
82 this); 78 this);
83 79
84 DCHECK_EQ(0u, in_use_resources_.size()); 80 DCHECK_EQ(0u, in_use_resources_.size());
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 for (const auto& resource : busy_resources_) { 447 for (const auto& resource : busy_resources_) {
452 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 448 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
453 } 449 }
454 for (const auto& entry : in_use_resources_) { 450 for (const auto& entry : in_use_resources_) {
455 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 451 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
456 } 452 }
457 return true; 453 return true;
458 } 454 }
459 455
460 } // namespace cc 456 } // 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