OLD | NEW |
---|---|
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 Loading... | |
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 | |
80 GLuint GetBufferId(const Buffer* buffer) { | 90 GLuint GetBufferId(const Buffer* buffer) { |
81 if (buffer) | 91 if (buffer) |
82 return buffer->service_id(); | 92 return buffer->service_id(); |
83 return 0; | 93 return 0; |
84 } | 94 } |
85 | 95 |
86 } // anonymous namespace. | 96 } // anonymous namespace. |
87 | 97 |
88 TextureUnit::TextureUnit() | 98 TextureUnit::TextureUnit() |
89 : bind_target(GL_TEXTURE_2D) { | 99 : bind_target(GL_TEXTURE_2D) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); | 309 glPixelStorei(GL_UNPACK_ROW_LENGTH, unpack_row_length); |
300 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); | 310 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack_image_height); |
301 } | 311 } |
302 } | 312 } |
303 | 313 |
304 void ContextState::DoLineWidth(GLfloat width) const { | 314 void ContextState::DoLineWidth(GLfloat width) const { |
305 glLineWidth( | 315 glLineWidth( |
306 std::min(std::max(width, line_width_min_), line_width_max_)); | 316 std::min(std::max(width, line_width_min_), line_width_max_)); |
307 } | 317 } |
308 | 318 |
319 void ContextState::RestoreBufferBinding(unsigned int target) const { | |
320 if (BufferTargetIsSupported(target)) | |
piman
2017/03/30 18:31:43
Why this logic? Other targets *are* supported at t
Chandan
2017/03/30 19:22:39
I added this logic to keep it consistent with !sta
| |
321 glBindBuffer(target, GetBufferId(bound_array_buffer.get())); | |
322 } | |
323 | |
309 void ContextState::RestoreBufferBindings() const { | 324 void ContextState::RestoreBufferBindings() const { |
310 if (vertex_attrib_manager.get()) { | 325 if (vertex_attrib_manager.get()) { |
311 Buffer* element_array_buffer = | 326 Buffer* element_array_buffer = |
312 vertex_attrib_manager->element_array_buffer(); | 327 vertex_attrib_manager->element_array_buffer(); |
313 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); | 328 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); |
314 } | 329 } |
315 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); | 330 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); |
316 if (feature_info_->IsES3Capable()) { | 331 if (feature_info_->IsES3Capable()) { |
317 glBindBuffer(GL_COPY_READ_BUFFER, | 332 glBindBuffer(GL_COPY_READ_BUFFER, |
318 GetBufferId(bound_copy_read_buffer.get())); | 333 GetBufferId(bound_copy_read_buffer.get())); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 UpdateUnpackParameters(); | 728 UpdateUnpackParameters(); |
714 } | 729 } |
715 | 730 |
716 // Include the auto-generated part of this file. We split this because it means | 731 // Include the auto-generated part of this file. We split this because it means |
717 // we can easily edit the non-auto generated parts right here in this file | 732 // we can easily edit the non-auto generated parts right here in this file |
718 // instead of having to edit some template or the code generator. | 733 // instead of having to edit some template or the code generator. |
719 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 734 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
720 | 735 |
721 } // namespace gles2 | 736 } // namespace gles2 |
722 } // namespace gpu | 737 } // namespace gpu |
OLD | NEW |