blob: 8e2f70b082cd22eca8c3a0e0a92c71f7e50a27a3 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright (c) 2010 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 GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
#define GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
#include <map>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
namespace gles2 {
// This class keeps track of the renderbuffers and whether or not they have
// been cleared.
class RenderbufferManager {
public:
// Info about Renderbuffers currently in the system.
class RenderbufferInfo : public base::RefCounted<RenderbufferInfo> {
public:
typedef scoped_refptr<RenderbufferInfo> Ref;
explicit RenderbufferInfo(GLuint service_id)
: service_id_(service_id),
cleared_(false) {
}
GLuint service_id() const {
return service_id_;
}
bool cleared() const {
return cleared_;
}
void set_cleared() {
cleared_ = true;
}
bool IsDeleted() {
return service_id_ == 0;
}
private:
friend class RenderbufferManager;
friend class base::RefCounted<RenderbufferInfo>;
~RenderbufferInfo() { }
void MarkAsDeleted() {
service_id_ = 0;
}
// Service side renderbuffer id.
GLuint service_id_;
// Whether this renderbuffer has been cleared
bool cleared_;
};
RenderbufferManager() { }
// Creates a RenderbufferInfo for the given renderbuffer.
void CreateRenderbufferInfo(GLuint client_id, GLuint service_id);
// Gets the renderbuffer info for the given renderbuffer.
RenderbufferInfo* GetRenderbufferInfo(GLuint client_id);
// Removes a renderbuffer info for the given renderbuffer.
void RemoveRenderbufferInfo(GLuint client_id);
private:
// Info for each renderbuffer in the system.
// TODO(gman): Choose a faster container.
typedef std::map<GLuint, RenderbufferInfo::Ref> RenderbufferInfoMap;
RenderbufferInfoMap renderbuffer_infos_;
DISALLOW_COPY_AND_ASSIGN(RenderbufferManager);
};
} // namespace gles2
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
|