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

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

Issue 2788793003: gpu: Support other buffer targets for ScopedBufferBinder (Closed)
Patch Set: Update{Pack,Unpack}Parameters() made public Created 3 years, 8 months 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/context_state.h" 5 #include "gpu/command_buffer/service/context_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return feature_info->feature_flags().arb_texture_rectangle; 70 return feature_info->feature_flags().arb_texture_rectangle;
71 case GL_TEXTURE_EXTERNAL_OES: 71 case GL_TEXTURE_EXTERNAL_OES:
72 return feature_info->feature_flags().oes_egl_image_external || 72 return feature_info->feature_flags().oes_egl_image_external ||
73 feature_info->feature_flags().nv_egl_stream_consumer_external; 73 feature_info->feature_flags().nv_egl_stream_consumer_external;
74 default: 74 default:
75 NOTREACHED(); 75 NOTREACHED();
76 return false; 76 return false;
77 } 77 }
78 } 78 }
79 79
80 bool BufferTargetIsSupported(GLuint target) {
81 switch (target) {
82 case GL_ARRAY_BUFFER:
83 return true;
84 default:
85 NOTREACHED();
86 return false;
87 }
88 }
89
90 GLuint GetBufferId(const Buffer* buffer) { 80 GLuint GetBufferId(const Buffer* buffer) {
91 if (buffer) 81 if (buffer)
92 return buffer->service_id(); 82 return buffer->service_id();
93 return 0; 83 return 0;
94 } 84 }
95 85
96 } // anonymous namespace. 86 } // anonymous namespace.
97 87
98 TextureUnit::TextureUnit() 88 TextureUnit::TextureUnit()
99 : bind_target(GL_TEXTURE_2D) { 89 : bind_target(GL_TEXTURE_2D) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); 299 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length);
310 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); 300 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height);
311 } 301 }
312 } 302 }
313 303
314 void ContextState::DoLineWidth(GLfloat width) const { 304 void ContextState::DoLineWidth(GLfloat width) const {
315 glLineWidth( 305 glLineWidth(
316 std::min(std::max(width, line_width_min_), line_width_max_)); 306 std::min(std::max(width, line_width_min_), line_width_max_));
317 } 307 }
318 308
319 void ContextState::RestoreBufferBinding(unsigned int target) const {
320 if (BufferTargetIsSupported(target))
321 glBindBuffer(target, GetBufferId(bound_array_buffer.get()));
322 }
323
324 void ContextState::RestoreBufferBindings() const { 309 void ContextState::RestoreBufferBindings() const {
325 if (vertex_attrib_manager.get()) { 310 if (vertex_attrib_manager.get()) {
326 Buffer* element_array_buffer = 311 Buffer* element_array_buffer =
327 vertex_attrib_manager->element_array_buffer(); 312 vertex_attrib_manager->element_array_buffer();
328 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); 313 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer));
329 } 314 }
330 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); 315 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get()));
331 if (feature_info_->IsES3Capable()) { 316 if (feature_info_->IsES3Capable()) {
332 glBindBuffer(GL_COPY_READ_BUFFER, 317 glBindBuffer(GL_COPY_READ_BUFFER,
333 GetBufferId(bound_copy_read_buffer.get())); 318 GetBufferId(bound_copy_read_buffer.get()));
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 UpdateUnpackParameters(); 713 UpdateUnpackParameters();
729 } 714 }
730 715
731 // Include the auto-generated part of this file. We split this because it means 716 // Include the auto-generated part of this file. We split this because it means
732 // we can easily edit the non-auto generated parts right here in this file 717 // we can easily edit the non-auto generated parts right here in this file
733 // instead of having to edit some template or the code generator. 718 // instead of having to edit some template or the code generator.
734 #include "gpu/command_buffer/service/context_state_impl_autogen.h" 719 #include "gpu/command_buffer/service/context_state_impl_autogen.h"
735 720
736 } // namespace gles2 721 } // namespace gles2
737 } // namespace gpu 722 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698