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

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

Issue 1251693003: cc: Fix the format of GpuMemoryBuffer for SurfaceTexture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the targets to ResourceProvider and fix the nits Created 5 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 | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_provider.h » ('J')
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 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ 5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_
6 #define CC_RESOURCES_RESOURCE_POOL_H_ 6 #define CC_RESOURCES_RESOURCE_POOL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/output/renderer.h" 12 #include "cc/output/renderer.h"
13 #include "cc/resources/resource.h" 13 #include "cc/resources/resource.h"
14 #include "cc/resources/resource_format.h" 14 #include "cc/resources/resource_format.h"
15 15
16 namespace cc { 16 namespace cc {
17 class ScopedResource; 17 class ScopedResource;
18 18
19 class CC_EXPORT ResourcePool { 19 class CC_EXPORT ResourcePool {
20 public: 20 public:
21 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider) {
22 return make_scoped_ptr(new ResourcePool(resource_provider));
23 }
24
21 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider, 25 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider,
22 GLenum target) { 26 GLenum target) {
23 return make_scoped_ptr(new ResourcePool(resource_provider, target)); 27 return make_scoped_ptr(new ResourcePool(resource_provider, target));
24 } 28 }
25 29
26 virtual ~ResourcePool(); 30 virtual ~ResourcePool();
27 31
28 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size, 32 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size,
29 ResourceFormat format); 33 ResourceFormat format);
30 scoped_ptr<ScopedResource> TryAcquireResourceWithContentId(uint64 content_id); 34 scoped_ptr<ScopedResource> TryAcquireResourceWithContentId(uint64 content_id);
(...skipping 14 matching lines...) Expand all
45 size_t acquired_memory_usage_bytes() const { 49 size_t acquired_memory_usage_bytes() const {
46 return memory_usage_bytes_ - unused_memory_usage_bytes_; 50 return memory_usage_bytes_ - unused_memory_usage_bytes_;
47 } 51 }
48 size_t total_resource_count() const { return resource_count_; } 52 size_t total_resource_count() const { return resource_count_; }
49 size_t acquired_resource_count() const { 53 size_t acquired_resource_count() const {
50 return resource_count_ - unused_resources_.size(); 54 return resource_count_ - unused_resources_.size();
51 } 55 }
52 size_t busy_resource_count() const { return busy_resources_.size(); } 56 size_t busy_resource_count() const { return busy_resources_.size(); }
53 57
54 protected: 58 protected:
59 ResourcePool(ResourceProvider* resource_provider);
reveman 2015/07/28 08:58:25 nit: explicit ResourcePool(ResourceProv...
55 ResourcePool(ResourceProvider* resource_provider, GLenum target); 60 ResourcePool(ResourceProvider* resource_provider, GLenum target);
reveman 2015/07/28 08:58:25 Can we remove this ctor with "target" and and alwa
jchen10 2015/07/29 04:33:47 I'm afraid we can't. The image texture is only use
reveman 2015/07/30 02:41:43 Ok. No need to do anything in this patch but I thi
56 61
57 bool ResourceUsageTooHigh(); 62 bool ResourceUsageTooHigh();
58 63
59 private: 64 private:
60 void DidFinishUsingResource(ScopedResource* resource, uint64_t content_id); 65 void DidFinishUsingResource(ScopedResource* resource, uint64_t content_id);
61 66
62 ResourceProvider* resource_provider_; 67 ResourceProvider* resource_provider_;
63 const GLenum target_; 68 const GLenum target_;
64 size_t max_memory_usage_bytes_; 69 size_t max_memory_usage_bytes_;
65 size_t max_unused_memory_usage_bytes_; 70 size_t max_unused_memory_usage_bytes_;
(...skipping 11 matching lines...) Expand all
77 typedef std::deque<PoolResource> ResourceList; 82 typedef std::deque<PoolResource> ResourceList;
78 ResourceList unused_resources_; 83 ResourceList unused_resources_;
79 ResourceList busy_resources_; 84 ResourceList busy_resources_;
80 85
81 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 86 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
82 }; 87 };
83 88
84 } // namespace cc 89 } // namespace cc
85 90
86 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 91 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698