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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/service/gl_utils.h" 12 #include "gpu/command_buffer/common/value_state.h"
13 #include "gpu/gpu_export.h" 13 #include "gpu/gpu_export.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 namespace gles2 { 16 namespace gles2 {
17 17
18 class ValuebufferManager; 18 class ValuebufferManager;
19 19
20 union ValueState {
21 float float_value[4];
22 int int_value[4];
23 };
24
25 class GPU_EXPORT Valuebuffer : public base::RefCounted<Valuebuffer> { 20 class GPU_EXPORT Valuebuffer : public base::RefCounted<Valuebuffer> {
26 public: 21 public:
27 Valuebuffer(ValuebufferManager* manager, GLuint client_id); 22 Valuebuffer(ValuebufferManager* manager, unsigned int client_id);
28 23
29 GLuint client_id() const { return client_id_; } 24 unsigned int client_id() const { return client_id_; }
30 25
31 bool IsDeleted() const { return client_id_ == 0; } 26 bool IsDeleted() const { return client_id_ == 0; }
32 27
33 void MarkAsValid() { has_been_bound_ = true; } 28 void MarkAsValid() { has_been_bound_ = true; }
34 29
35 bool IsValid() const { return has_been_bound_ && !IsDeleted(); } 30 bool IsValid() const { return has_been_bound_ && !IsDeleted(); }
36 31
37 void AddSubscription(GLenum subscription); 32 void AddSubscription(unsigned int subscription);
38 void RemoveSubscription(GLenum subscription); 33 void RemoveSubscription(unsigned int subscription);
39 34
40 // Returns true if this Valuebuffer is subscribed to subscription 35 // Returns true if this Valuebuffer is subscribed to subscription
41 bool IsSubscribed(GLenum subscription); 36 bool IsSubscribed(unsigned int subscription);
42 37
43 // Returns the active state for a given target in this Valuebuffer 38 // Returns the active state for a given target in this Valuebuffer
44 // returns NULL if target state doesn't exist 39 // returns NULL if target state doesn't exist
45 const ValueState* GetState(GLenum target) const; 40 const ValueState* GetState(unsigned int target) const;
46 41
47 private: 42 private:
48 friend class ValuebufferManager; 43 friend class ValuebufferManager;
49 friend class base::RefCounted<Valuebuffer>; 44 friend class base::RefCounted<Valuebuffer>;
50 45
51 typedef base::hash_map<GLenum, ValueState> StateMap; 46 typedef base::hash_set<unsigned int> SubscriptionSet;
52 typedef base::hash_set<GLenum> SubscriptionSet;
53 47
54 ~Valuebuffer(); 48 ~Valuebuffer();
55 49
56 void UpdateState(const StateMap& pending_state); 50 void UpdateState(const ValueStateMap* pending_state);
57 51
58 void MarkAsDeleted() { client_id_ = 0; } 52 void MarkAsDeleted() { client_id_ = 0; }
59 53
60 // ValuebufferManager that owns this Valuebuffer. 54 // ValuebufferManager that owns this Valuebuffer.
61 ValuebufferManager* manager_; 55 ValuebufferManager* manager_;
62 56
63 // Client side Valuebuffer id. 57 // Client side Valuebuffer id.
64 GLuint client_id_; 58 unsigned int client_id_;
65 59
66 // Whether this Valuebuffer has ever been bound. 60 // Whether this Valuebuffer has ever been bound.
67 bool has_been_bound_; 61 bool has_been_bound_;
68 62
69 SubscriptionSet subscriptions_; 63 SubscriptionSet subscriptions_;
70 64
71 StateMap active_state_map_; 65 scoped_refptr<ValueStateMap> active_state_map_;
72 }; 66 };
73 67
74 class GPU_EXPORT ValuebufferManager { 68 class GPU_EXPORT ValuebufferManager {
75 public: 69 public:
76 ValuebufferManager(); 70 ValuebufferManager(ValueStateMap* state_map);
77 ~ValuebufferManager(); 71 ~ValuebufferManager();
78 72
79 // Must call before destruction. 73 // Must call before destruction.
80 void Destroy(); 74 void Destroy();
81 75
82 // Creates a Valuebuffer for the given Valuebuffer ids. 76 // Creates a Valuebuffer for the given Valuebuffer ids.
83 void CreateValuebuffer(GLuint client_id); 77 void CreateValuebuffer(unsigned int client_id);
84 78
85 // Gets the Valuebuffer for the given Valuebuffer id. 79 // Gets the Valuebuffer for the given Valuebuffer id.
86 Valuebuffer* GetValuebuffer(GLuint client_id); 80 Valuebuffer* GetValuebuffer(unsigned int client_id);
87 81
88 // Removes a Valuebuffer for the given Valuebuffer id. 82 // Removes a Valuebuffer for the given Valuebuffer id.
89 void RemoveValuebuffer(GLuint client_id); 83 void RemoveValuebuffer(unsigned int client_id);
90 84
91 // Updates the value state for the given Valuebuffer 85 // Updates the value state for the given Valuebuffer
92 void UpdateValuebufferState(Valuebuffer* valuebuffer); 86 void UpdateValuebufferState(Valuebuffer* valuebuffer);
93 87
94 // Gets the state for the given subscription target 88 static uint32 ApiTypeForSubscriptionTarget(unsigned int target);
95 void UpdateValueState(GLenum target, const ValueState& state);
96
97 static uint32 ApiTypeForSubscriptionTarget(GLenum target);
98 89
99 private: 90 private:
100 friend class Valuebuffer; 91 friend class Valuebuffer;
101 92
102 typedef base::hash_map<GLuint, scoped_refptr<Valuebuffer>> ValuebufferMap; 93 typedef base::hash_map<unsigned int, scoped_refptr<Valuebuffer>>
94 ValuebufferMap;
103 95
104 void StartTracking(Valuebuffer* valuebuffer); 96 void StartTracking(Valuebuffer* valuebuffer);
105 void StopTracking(Valuebuffer* valuebuffer); 97 void StopTracking(Valuebuffer* valuebuffer);
106 98
107 // Counts the number of Valuebuffer allocated with 'this' as its manager. 99 // Counts the number of Valuebuffer allocated with 'this' as its manager.
108 // Allows to check no Valuebuffer will outlive this. 100 // Allows to check no Valuebuffer will outlive this.
109 unsigned valuebuffer_count_; 101 unsigned int valuebuffer_count_;
110 102
111 // Info for each Valuebuffer in the system. 103 // Info for each Valuebuffer in the system.
112 ValuebufferMap valuebuffer_map_; 104 ValuebufferMap valuebuffer_map_;
113 105
114 // Current value state in the system 106 // Current value state in the system
115 Valuebuffer::StateMap pending_state_map_; 107 // Updated by GpuChannel
108 scoped_refptr<ValueStateMap> pending_state_map_;
116 109
117 DISALLOW_COPY_AND_ASSIGN(ValuebufferManager); 110 DISALLOW_COPY_AND_ASSIGN(ValuebufferManager);
118 }; 111 };
119 112
120 } // namespace gles2 113 } // namespace gles2
121 } // namespace gpu 114 } // namespace gpu
122 115
123 #endif // GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_ 116 #endif // GPU_COMMAND_BUFFER_SERVICE_VALUEBUFFER_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/test_helper.cc ('k') | gpu/command_buffer/service/valuebuffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698