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

Side by Side Diff: gpu/command_buffer/service/valuebuffer_manager.h

Issue 659903002: Add subscribeUniform extension pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: V3 API Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
7
8 #include <set>
9
10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "gpu/command_buffer/service/gl_utils.h"
15 #include "gpu/gpu_export.h"
16
17 namespace gpu {
18 namespace gles2 {
19
20 class ValuebufferManager;
21
22 class ValueState : public base::RefCounted<ValueState> {
23 public:
24 ValueState(GLenum target);
25
26 GLenum target() const { return target_; }
27
28 protected:
29 virtual ~ValueState() = 0;
30
31 private:
32 friend class base::RefCounted<ValueState>;
33
34 GLenum target_;
piman 2014/11/04 02:38:22 You only use target_ for ValuebufferManager::Updat
orglofch 2014/11/04 19:53:28 Done.
35 };
36
37 class IntValueState : public ValueState {
orglofch 2014/11/04 01:30:06 It would be nice to simply store a void* data memb
piman 2014/11/04 02:38:22 My suggestion: given that the number of elements i
orglofch 2014/11/04 19:53:29 Nice, I didn't know about unions! Done.
38 public:
39 IntValueState(GLenum target, GLint* data);
40
41 const GLint* data() const { return data_.get(); }
42
43 private:
44 ~IntValueState();
45
46 scoped_ptr<GLint[]> data_;
47 };
48
49 class FloatValueState : public ValueState {
50 public:
51 FloatValueState(GLenum target, GLfloat* data);
52
53 const GLfloat* data() const { return data_.get(); }
54
55 private:
56 ~FloatValueState();
57
58 scoped_ptr<GLfloat[]> data_;
59 };
60
61 class GPU_EXPORT Valuebuffer : public base::RefCounted<Valuebuffer> {
62 public:
63 typedef base::hash_map<GLenum, scoped_refptr<ValueState>> StateMap;
64
65 Valuebuffer(ValuebufferManager* manager, GLuint client_id);
66
67 GLuint client_id() const { return client_id_; }
68
69 bool IsDeleted() const { return client_id_ == 0; }
70
71 void MarkAsValid() { has_been_bound_ = true; }
72
73 bool IsValid() const { return has_been_bound_ && !IsDeleted(); }
74
75 void AddSubscription(GLenum subscription);
76 void RemoveSubscription(GLenum subscription);
77
78 // Returns true if this Valuebuffer is subscribed to subscription
79 bool IsSubscribed(GLenum subscription);
80
81 // Returns the active state for a given target in this Valuebuffer
82 // returns NULL if target state doesn't exist
83 const ValueState* GetState(GLenum target) const;
84
85 private:
86 friend class ValuebufferManager;
87 friend class base::RefCounted<Valuebuffer>;
88
89 typedef std::set<GLenum> SubscriptionSet;
piman 2014/11/04 02:38:22 nit: make this a hash_set, since you don't care ab
orglofch 2014/11/04 19:53:29 Done. I'll leave it as a hash_set to it's more ext
90
91 ~Valuebuffer();
92
93 void UpdateState(const StateMap& pending_state);
94
95 void MarkAsDeleted() { client_id_ = 0; }
96
97 // ValuebufferManager that owns this Valuebuffer.
98 ValuebufferManager* manager_;
99
100 // Client side Valuebuffer id.
101 GLuint client_id_;
102
103 // Whether this Valuebuffer has ever been bound.
104 bool has_been_bound_;
105
106 SubscriptionSet subscriptions_;
107
108 StateMap active_state_map_;
109 };
110
111 class GPU_EXPORT ValuebufferManager {
112 public:
113 ValuebufferManager();
114 ~ValuebufferManager();
115
116 // Must call before destruction.
117 void Destroy(bool have_context);
118
119 // Creates a Valuebuffer for the given Valuebuffer ids.
120 void CreateValuebuffer(GLuint client_id);
121
122 // Gets the Valuebuffer for the given Valuebuffer id.
123 Valuebuffer* GetValuebuffer(GLuint client_id);
124
125 // Removes a Valuebuffer for the given Valuebuffer id.
126 void RemoveValuebuffer(GLuint client_id);
127
128 // Updates the value state for the given Valuebuffer
129 void UpdateValuebufferState(GLuint client_id);
130
131 // Gets the state for the given subscription target
132 void UpdateValueState(ValueState* state);
133
134 static uint32 ApiTypeForSubscriptionTarget(GLenum target);
135
136 private:
137 friend class Valuebuffer;
138
139 typedef base::hash_map<GLuint, scoped_refptr<Valuebuffer>> ValuebufferMap;
140
141 void StartTracking(Valuebuffer* valuebuffer);
142 void StopTracking(Valuebuffer* valuebuffer);
143
144 // Counts the number of Valuebuffer allocated with 'this' as its manager.
145 // Allows to check no Valuebuffer will outlive this.
146 unsigned valuebuffer_count_;
147
148 bool have_context_;
149
150 // Info for each Valuebuffer in the system.
151 ValuebufferMap valuebuffer_map_;
152
153 // Current value state in the system
154 Valuebuffer::StateMap pending_state_map_;
155
156 DISALLOW_COPY_AND_ASSIGN(ValuebufferManager);
157 };
158
159 } // namespace gles2
160 } // namespace gpu
161
162 #endif // GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698