Chromium Code Reviews| 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 | |
| 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 Loading... | |
| 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 { | 309 void ContextState::RestoreBufferBinding(unsigned int target) const { |
|
piman
2017/04/04 00:27:25
If we are not going to implement the other targets
Chandan
2017/04/04 12:14:00
I did not add other targets in BufferTargetIsSuppo
| |
| 320 if (BufferTargetIsSupported(target)) | 310 glBindBuffer(target, GetBufferId(bound_array_buffer.get())); |
| 321 glBindBuffer(target, GetBufferId(bound_array_buffer.get())); | |
| 322 } | 311 } |
| 323 | 312 |
| 324 void ContextState::RestoreBufferBindings() const { | 313 void ContextState::RestoreBufferBindings() const { |
| 325 if (vertex_attrib_manager.get()) { | 314 if (vertex_attrib_manager.get()) { |
| 326 Buffer* element_array_buffer = | 315 Buffer* element_array_buffer = |
| 327 vertex_attrib_manager->element_array_buffer(); | 316 vertex_attrib_manager->element_array_buffer(); |
| 328 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); | 317 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, GetBufferId(element_array_buffer)); |
| 329 } | 318 } |
| 330 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); | 319 glBindBuffer(GL_ARRAY_BUFFER, GetBufferId(bound_array_buffer.get())); |
| 331 if (feature_info_->IsES3Capable()) { | 320 if (feature_info_->IsES3Capable()) { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 UpdateUnpackParameters(); | 717 UpdateUnpackParameters(); |
| 729 } | 718 } |
| 730 | 719 |
| 731 // Include the auto-generated part of this file. We split this because it means | 720 // 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 | 721 // 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. | 722 // instead of having to edit some template or the code generator. |
| 734 #include "gpu/command_buffer/service/context_state_impl_autogen.h" | 723 #include "gpu/command_buffer/service/context_state_impl_autogen.h" |
| 735 | 724 |
| 736 } // namespace gles2 | 725 } // namespace gles2 |
| 737 } // namespace gpu | 726 } // namespace gpu |
| OLD | NEW |