blob: 80b2e46511b0e365f74aee946e73f9dd54468573 (
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
|
// 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_CONTEXT_GROUP_H_
#define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
#include <map>
#include <string>
#include "base/basictypes.h"
#include "base/linked_ptr.h"
#include "base/scoped_ptr.h"
#include "base/ref_counted.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/feature_info.h"
namespace gpu {
class IdAllocator;
namespace gles2 {
class GLES2Decoder;
class BufferManager;
class FramebufferManager;
class RenderbufferManager;
class ProgramManager;
class ShaderManager;
class TextureManager;
struct DisallowedExtensions;
// A Context Group helps manage multiple GLES2Decoders that share
// resources.
class ContextGroup : public base::RefCounted<ContextGroup> {
public:
typedef scoped_refptr<ContextGroup> Ref;
ContextGroup();
~ContextGroup();
// This should only be called by GLES2Decoder.
bool Initialize(const DisallowedExtensions& disallowed_extensions,
const char* allowed_features);
// Sets the ContextGroup has having a lost context.
void set_have_context(bool have_context) {
have_context_ = have_context;
}
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_;
}
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();
}
IdAllocator* GetIdAllocator(unsigned namepsace_id);
private:
// Destroys all the resources.
void Destroy();
// Whether or not this context is initialized.
bool initialized_;
bool have_context_;
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_;
typedef std::map<uint32, linked_ptr<IdAllocator> > IdAllocatorMap;
IdAllocatorMap id_namespaces_;
FeatureInfo feature_info_;
DISALLOW_COPY_AND_ASSIGN(ContextGroup);
};
} // namespace gles2
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
|