blob: 8c5477eaf81008fb4b169f2cb34e2ac956b710eb (
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
// Copyright (c) 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 GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
#define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
#include <string>
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/gpu_export.h"
namespace gpu {
class IdAllocatorInterface;
namespace gles2 {
class BufferManager;
class GLES2Decoder;
class FramebufferManager;
class MailboxManager;
class RenderbufferManager;
class ProgramManager;
class ShaderManager;
class TextureManager;
struct DisallowedFeatures;
// A Context Group helps manage multiple GLES2Decoders that share
// resources.
class GPU_EXPORT ContextGroup : public base::RefCounted<ContextGroup> {
public:
typedef scoped_refptr<ContextGroup> Ref;
explicit ContextGroup(MailboxManager* mailbox_manager,
bool bind_generates_resource);
~ContextGroup();
// This should only be called by GLES2Decoder. This must be paired with a
// call to destroy if it succeeds.
bool Initialize(const DisallowedFeatures& disallowed_features,
const char* allowed_features);
// Destroys all the resources when called for the last context in the group.
// It should only be called by GLES2Decoder.
void Destroy(bool have_context);
MailboxManager* mailbox_manager() const {
return mailbox_manager_.get();
}
bool bind_generates_resource() {
return bind_generates_resource_;
}
uint32 max_vertex_attribs() const {
return max_vertex_attribs_;
}
uint32 max_texture_units() const {
return max_texture_units_;
}
uint32 max_texture_image_units() const {
return max_texture_image_units_;
}
uint32 max_vertex_texture_image_units() const {
return max_vertex_texture_image_units_;
}
uint32 max_fragment_uniform_vectors() const {
return max_fragment_uniform_vectors_;
}
uint32 max_varying_vectors() const {
return max_varying_vectors_;
}
uint32 max_vertex_uniform_vectors() const {
return max_vertex_uniform_vectors_;
}
FeatureInfo* feature_info() {
return feature_info_.get();
}
BufferManager* buffer_manager() const {
return buffer_manager_.get();
}
FramebufferManager* framebuffer_manager() const {
return framebuffer_manager_.get();
}
RenderbufferManager* renderbuffer_manager() const {
return renderbuffer_manager_.get();
}
TextureManager* texture_manager() const {
return texture_manager_.get();
}
ProgramManager* program_manager() const {
return program_manager_.get();
}
ShaderManager* shader_manager() const {
return shader_manager_.get();
}
IdAllocatorInterface* GetIdAllocator(unsigned namespace_id);
private:
bool CheckGLFeature(GLint min_required, GLint* v);
bool CheckGLFeatureU(GLint min_required, uint32* v);
bool QueryGLFeature(GLenum pname, GLint min_required, GLint* v);
bool QueryGLFeatureU(GLenum pname, GLint min_required, uint32* v);
scoped_refptr<MailboxManager> mailbox_manager_;
// Whether or not this context is initialized.
int num_contexts_;
bool enforce_gl_minimums_;
bool bind_generates_resource_;
uint32 max_vertex_attribs_;
uint32 max_texture_units_;
uint32 max_texture_image_units_;
uint32 max_vertex_texture_image_units_;
uint32 max_fragment_uniform_vectors_;
uint32 max_varying_vectors_;
uint32 max_vertex_uniform_vectors_;
scoped_ptr<BufferManager> buffer_manager_;
scoped_ptr<FramebufferManager> framebuffer_manager_;
scoped_ptr<RenderbufferManager> renderbuffer_manager_;
scoped_ptr<TextureManager> texture_manager_;
scoped_ptr<ProgramManager> program_manager_;
scoped_ptr<ShaderManager> shader_manager_;
linked_ptr<IdAllocatorInterface>
id_namespaces_[id_namespaces::kNumIdNamespaces];
FeatureInfo::Ref feature_info_;
DISALLOW_COPY_AND_ASSIGN(ContextGroup);
};
} // namespace gles2
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
|