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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
6 6
7 #include <stdint.h>
8
7 #include <list> 9 #include <list>
8 10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 #define GLES2_GPU_SERVICE 1 15 #define GLES2_GPU_SERVICE 1
14 #include "gpu/command_buffer/common/gles2_cmd_format.h" 16 #include "gpu/command_buffer/common/gles2_cmd_format.h"
15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 17 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
16 #include "gpu/command_buffer/service/buffer_manager.h" 18 #include "gpu/command_buffer/service/buffer_manager.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (!buffer_.get() || buffer_->IsDeleted()) { 79 if (!buffer_.get() || buffer_->IsDeleted()) {
78 return false; 80 return false;
79 } 81 }
80 82
81 // The number of elements that can be accessed. 83 // The number of elements that can be accessed.
82 GLsizeiptr buffer_size = buffer_->size(); 84 GLsizeiptr buffer_size = buffer_->size();
83 if (offset_ > buffer_size || real_stride_ == 0) { 85 if (offset_ > buffer_size || real_stride_ == 0) {
84 return false; 86 return false;
85 } 87 }
86 88
87 uint32 usable_size = buffer_size - offset_; 89 uint32_t usable_size = buffer_size - offset_;
88 GLuint num_elements = usable_size / real_stride_ + 90 GLuint num_elements = usable_size / real_stride_ +
89 ((usable_size % real_stride_) >= 91 ((usable_size % real_stride_) >=
90 (GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type_) * size_) ? 1 : 0); 92 (GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type_) * size_) ? 1 : 0);
91 return index < num_elements; 93 return index < num_elements;
92 } 94 }
93 95
94 VertexAttribManager::VertexAttribManager() 96 VertexAttribManager::VertexAttribManager()
95 : num_fixed_attribs_(0), 97 : num_fixed_attribs_(0),
96 element_array_buffer_(NULL), 98 element_array_buffer_(NULL),
97 manager_(NULL), 99 manager_(NULL),
98 deleted_(false), 100 deleted_(false),
99 service_id_(0) { 101 service_id_(0) {
100 } 102 }
101 103
102 VertexAttribManager::VertexAttribManager( 104 VertexAttribManager::VertexAttribManager(VertexArrayManager* manager,
103 VertexArrayManager* manager, GLuint service_id, uint32 num_vertex_attribs) 105 GLuint service_id,
106 uint32_t num_vertex_attribs)
104 : num_fixed_attribs_(0), 107 : num_fixed_attribs_(0),
105 element_array_buffer_(NULL), 108 element_array_buffer_(NULL),
106 manager_(manager), 109 manager_(manager),
107 deleted_(false), 110 deleted_(false),
108 service_id_(service_id) { 111 service_id_(service_id) {
109 manager_->StartTracking(this); 112 manager_->StartTracking(this);
110 Initialize(num_vertex_attribs, false); 113 Initialize(num_vertex_attribs, false);
111 } 114 }
112 115
113 VertexAttribManager::~VertexAttribManager() { 116 VertexAttribManager::~VertexAttribManager() {
114 if (manager_) { 117 if (manager_) {
115 if (manager_->have_context_) { 118 if (manager_->have_context_) {
116 if (service_id_ != 0) // 0 indicates an emulated VAO 119 if (service_id_ != 0) // 0 indicates an emulated VAO
117 glDeleteVertexArraysOES(1, &service_id_); 120 glDeleteVertexArraysOES(1, &service_id_);
118 } 121 }
119 manager_->StopTracking(this); 122 manager_->StopTracking(this);
120 manager_ = NULL; 123 manager_ = NULL;
121 } 124 }
122 } 125 }
123 126
124 void VertexAttribManager::Initialize( 127 void VertexAttribManager::Initialize(uint32_t max_vertex_attribs,
125 uint32 max_vertex_attribs, bool init_attribs) { 128 bool init_attribs) {
126 vertex_attribs_.resize(max_vertex_attribs); 129 vertex_attribs_.resize(max_vertex_attribs);
127 130
128 for (uint32 vv = 0; vv < vertex_attribs_.size(); ++vv) { 131 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) {
129 vertex_attribs_[vv].set_index(vv); 132 vertex_attribs_[vv].set_index(vv);
130 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_); 133 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_);
131 134
132 if (init_attribs) { 135 if (init_attribs) {
133 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); 136 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f);
134 } 137 }
135 } 138 }
136 } 139 }
137 140
138 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) { 141 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) {
139 element_array_buffer_ = buffer; 142 element_array_buffer_ = buffer;
140 } 143 }
141 144
142 bool VertexAttribManager::Enable(GLuint index, bool enable) { 145 bool VertexAttribManager::Enable(GLuint index, bool enable) {
143 if (index >= vertex_attribs_.size()) { 146 if (index >= vertex_attribs_.size()) {
144 return false; 147 return false;
145 } 148 }
146 VertexAttrib& info = vertex_attribs_[index]; 149 VertexAttrib& info = vertex_attribs_[index];
147 if (info.enabled() != enable) { 150 if (info.enabled() != enable) {
148 info.set_enabled(enable); 151 info.set_enabled(enable);
149 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); 152 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_);
150 } 153 }
151 return true; 154 return true;
152 } 155 }
153 156
154 void VertexAttribManager::Unbind(Buffer* buffer) { 157 void VertexAttribManager::Unbind(Buffer* buffer) {
155 if (element_array_buffer_.get() == buffer) { 158 if (element_array_buffer_.get() == buffer) {
156 element_array_buffer_ = NULL; 159 element_array_buffer_ = NULL;
157 } 160 }
158 for (uint32 vv = 0; vv < vertex_attribs_.size(); ++vv) { 161 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) {
159 vertex_attribs_[vv].Unbind(buffer); 162 vertex_attribs_[vv].Unbind(buffer);
160 } 163 }
161 } 164 }
162 165
163 bool VertexAttribManager::ValidateBindings( 166 bool VertexAttribManager::ValidateBindings(
164 const char* function_name, 167 const char* function_name,
165 GLES2Decoder* decoder, 168 GLES2Decoder* decoder,
166 FeatureInfo* feature_info, 169 FeatureInfo* feature_info,
167 Program* current_program, 170 Program* current_program,
168 GLuint max_vertex_accessed, 171 GLuint max_vertex_accessed,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (current_buffer_id != kInitialBufferId) { 275 if (current_buffer_id != kInitialBufferId) {
273 // Restore the buffer binding. 276 // Restore the buffer binding.
274 decoder->RestoreBufferBindings(); 277 decoder->RestoreBufferBindings();
275 } 278 }
276 279
277 return true; 280 return true;
278 } 281 }
279 282
280 } // namespace gles2 283 } // namespace gles2
281 } // namespace gpu 284 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/vertex_attrib_manager.h ('k') | gpu/command_buffer/service/vertex_attrib_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698