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

Unified Diff: cc/resources/resource_pool.h

Issue 1531403002: Revert "Delete CC." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_format.cc ('k') | cc/resources/resource_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool.h
diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h
new file mode 100644
index 0000000000000000000000000000000000000000..30b28f775f296ef080c1209173c8de9d93fcefba
--- /dev/null
+++ b/cc/resources/resource_pool.h
@@ -0,0 +1,77 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_RESOURCES_RESOURCE_POOL_H_
+#define CC_RESOURCES_RESOURCE_POOL_H_
+
+#include <list>
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/output/renderer.h"
+#include "cc/resources/resource.h"
+#include "cc/resources/resource_format.h"
+
+namespace cc {
+class ScopedResource;
+
+class ResourcePool {
+ public:
+ static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider,
+ GLenum target) {
+ return make_scoped_ptr(new ResourcePool(resource_provider, target));
+ }
+
+ virtual ~ResourcePool();
+
+ scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size,
+ ResourceFormat format);
+ void ReleaseResource(scoped_ptr<ScopedResource>);
+
+ void SetResourceUsageLimits(size_t max_memory_usage_bytes,
+ size_t max_unused_memory_usage_bytes,
+ size_t max_resource_count);
+
+ void ReduceResourceUsage();
+ // This might block if |wait_if_needed| is true and one of the currently
+ // busy resources has a read lock fence that needs to be waited upon before
+ // it can be locked for write again.
+ void CheckBusyResources(bool wait_if_needed);
+
+ size_t total_memory_usage_bytes() const { return memory_usage_bytes_; }
+ size_t acquired_memory_usage_bytes() const {
+ return memory_usage_bytes_ - unused_memory_usage_bytes_;
+ }
+ size_t total_resource_count() const { return resource_count_; }
+ size_t acquired_resource_count() const {
+ return resource_count_ - unused_resources_.size();
+ }
+ size_t busy_resource_count() const { return busy_resources_.size(); }
+
+ protected:
+ ResourcePool(ResourceProvider* resource_provider, GLenum target);
+
+ bool ResourceUsageTooHigh();
+
+ private:
+ void DidFinishUsingResource(ScopedResource* resource);
+
+ ResourceProvider* resource_provider_;
+ const GLenum target_;
+ size_t max_memory_usage_bytes_;
+ size_t max_unused_memory_usage_bytes_;
+ size_t max_resource_count_;
+ size_t memory_usage_bytes_;
+ size_t unused_memory_usage_bytes_;
+ size_t resource_count_;
+
+ typedef std::list<ScopedResource*> ResourceList;
+ ResourceList unused_resources_;
+ ResourceList busy_resources_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourcePool);
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_RESOURCE_POOL_H_
« no previous file with comments | « cc/resources/resource_format.cc ('k') | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698