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

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

Issue 659903002: Add subscribeUniform extension pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed unitialized variable 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 #include "gpu/command_buffer/service/valuebuffer_manager.h"
6
7 #include "gpu/command_buffer/service/program_manager.h"
8
9 namespace gpu {
10 namespace gles2 {
11
12 Valuebuffer::Valuebuffer(ValuebufferManager* manager, GLuint client_id)
13 : manager_(manager), client_id_(client_id), has_been_bound_(false) {
14 manager_->StartTracking(this);
15 }
16
17 Valuebuffer::~Valuebuffer() {
18 if (manager_) {
19 manager_->StopTracking(this);
20 manager_ = NULL;
21 }
22 }
23
24 void Valuebuffer::AddSubscription(GLenum subscription) {
25 subscriptions_.insert(subscription);
26 }
27
28 void Valuebuffer::RemoveSubscription(GLenum subscription) {
29 subscriptions_.erase(subscription);
30 }
31
32 bool Valuebuffer::IsSubscribed(GLenum subscription) {
33 return subscriptions_.find(subscription) != subscriptions_.end();
34 }
35
36 const ValueState *Valuebuffer::GetState(GLenum target) const {
37 StateMap::const_iterator it = active_state_map_.find(target);
38 return it != active_state_map_.end() ? &it->second : NULL;
39 }
40
41 void Valuebuffer::UpdateState(const StateMap& pending_state) {
42 for (SubscriptionSet::const_iterator it = subscriptions_.begin();
43 it != subscriptions_.end(); ++it) {
44 StateMap::const_iterator pending_state_it = pending_state.find((*it));
45 if (pending_state_it != pending_state.end()) {
46 active_state_map_[pending_state_it->first] = pending_state_it->second;
47 }
48 }
49 }
50
51 ValuebufferManager::ValuebufferManager()
52 : valuebuffer_count_(0) {
53 }
54
55 ValuebufferManager::~ValuebufferManager() {
56 DCHECK(valuebuffer_map_.empty());
57 DCHECK(pending_state_map_.empty());
58 // If this triggers, that means something is keeping a reference to
59 // a Valuebuffer belonging to this.
60 CHECK_EQ(valuebuffer_count_, 0u);
61 }
62
63 void ValuebufferManager::Destroy() {
64 valuebuffer_map_.clear();
65 pending_state_map_.clear();
66 }
67
68 void ValuebufferManager::StartTracking(Valuebuffer* /* valuebuffer */) {
69 ++valuebuffer_count_;
70 }
71
72 void ValuebufferManager::StopTracking(Valuebuffer* /* valuebuffer */) {
73 --valuebuffer_count_;
74 }
75
76 void ValuebufferManager::CreateValuebuffer(GLuint client_id) {
77 scoped_refptr<Valuebuffer> valuebuffer(new Valuebuffer(this, client_id));
78 std::pair<ValuebufferMap::iterator, bool> result =
79 valuebuffer_map_.insert(std::make_pair(client_id, valuebuffer));
80 DCHECK(result.second);
81 }
82
83 Valuebuffer* ValuebufferManager::GetValuebuffer(GLuint client_id) {
84 ValuebufferMap::iterator it = valuebuffer_map_.find(client_id);
85 return it != valuebuffer_map_.end() ? it->second.get() : NULL;
86 }
87
88 void ValuebufferManager::RemoveValuebuffer(GLuint client_id) {
89 ValuebufferMap::iterator it = valuebuffer_map_.find(client_id);
90 if (it != valuebuffer_map_.end()) {
91 Valuebuffer* valuebuffer = it->second.get();
92 valuebuffer->MarkAsDeleted();
93 valuebuffer_map_.erase(it);
94 }
95 }
96
97 void ValuebufferManager::UpdateValuebufferState(Valuebuffer* valuebuffer) {
98 DCHECK(valuebuffer);
99 valuebuffer->UpdateState(pending_state_map_);
100 }
101
102 void ValuebufferManager::UpdateValueState(
103 GLenum target, const ValueState& state) {
104 pending_state_map_[target] = state;
105 }
106
107 uint32 ValuebufferManager::ApiTypeForSubscriptionTarget(GLenum target) {
108 switch (target) {
109 case GL_MOUSE_POSITION_CHROMIUM:
110 return Program::kUniform2i;
111 }
112 NOTREACHED() << "Unhandled uniform subscription target " << target;
113 return Program::kUniformNone;
114 }
115
116 } // namespace gles2
117 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/valuebuffer_manager.h ('k') | gpu/command_buffer/service/valuebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698