blob: 48cc52600852870637c5fd2059468d1ea4c25fbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// 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_RESOURCE_POOL_H_
#define CC_RESOURCE_POOL_H_
#include <list>
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/renderer.h"
#include "cc/resource.h"
namespace cc {
class ResourceProvider;
class CC_EXPORT ResourcePool {
public:
class CC_EXPORT Resource : public cc::Resource {
public:
Resource(ResourceProvider* resource_provider,
const gfx::Size& size,
GLenum format);
~Resource();
private:
ResourceProvider* resource_provider_;
DISALLOW_COPY_AND_ASSIGN(Resource);
};
static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider) {
return make_scoped_ptr(new ResourcePool(resource_provider));
}
virtual ~ResourcePool();
ResourceProvider* resource_provider() { return resource_provider_; };
scoped_ptr<ResourcePool::Resource> AcquireResource(
const gfx::Size&, GLenum format);
void ReleaseResource(scoped_ptr<ResourcePool::Resource>);
void SetMaxMemoryUsageBytes(size_t max_memory_usage_bytes);
protected:
ResourcePool(ResourceProvider* resource_provider);
private:
ResourceProvider* resource_provider_;
size_t max_memory_usage_bytes_;
size_t memory_usage_bytes_;
typedef std::list<Resource*> ResourceList;
ResourceList resources_;
DISALLOW_COPY_AND_ASSIGN(ResourcePool);
};
} // namespace cc
#endif // CC_RESOURCE_POOL_H_
|