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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 4944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4955 !SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)), | 4955 !SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)), |
4956 &size_needed) || | 4956 &size_needed) || |
4957 size_needed > 0x7FFFFFFFU) { | 4957 size_needed > 0x7FFFFFFFU) { |
4958 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); | 4958 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); |
4959 return false; | 4959 return false; |
4960 } | 4960 } |
4961 | 4961 |
4962 CopyRealGLErrorsToWrapper(); | 4962 CopyRealGLErrorsToWrapper(); |
4963 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 4963 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
4964 | 4964 |
4965 if (static_cast<GLsizei>(size_needed) > attrib_0_size_) { | 4965 bool new_buffer = static_cast<GLsizei>(size_needed) > attrib_0_size_; |
| 4966 if (new_buffer) { |
4966 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); | 4967 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); |
4967 GLenum error = glGetError(); | 4968 GLenum error = glGetError(); |
4968 if (error != GL_NO_ERROR) { | 4969 if (error != GL_NO_ERROR) { |
4969 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); | 4970 SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0"); |
4970 return false; | 4971 return false; |
4971 } | 4972 } |
4972 attrib_0_buffer_matches_value_ = false; | |
4973 } | 4973 } |
4974 if (attrib_0_used && | 4974 if (new_buffer || |
4975 (!attrib_0_buffer_matches_value_ || | 4975 (attrib_0_used && |
4976 (info->value().v[0] != attrib_0_value_.v[0] || | 4976 (!attrib_0_buffer_matches_value_ || |
4977 info->value().v[1] != attrib_0_value_.v[1] || | 4977 (info->value().v[0] != attrib_0_value_.v[0] || |
4978 info->value().v[2] != attrib_0_value_.v[2] || | 4978 info->value().v[1] != attrib_0_value_.v[1] || |
4979 info->value().v[3] != attrib_0_value_.v[3]))) { | 4979 info->value().v[2] != attrib_0_value_.v[2] || |
| 4980 info->value().v[3] != attrib_0_value_.v[3])))) { |
4980 std::vector<Vec4> temp(num_vertices, info->value()); | 4981 std::vector<Vec4> temp(num_vertices, info->value()); |
4981 glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); | 4982 glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]); |
4982 attrib_0_buffer_matches_value_ = true; | 4983 attrib_0_buffer_matches_value_ = true; |
4983 attrib_0_value_ = info->value(); | 4984 attrib_0_value_ = info->value(); |
4984 attrib_0_size_ = size_needed; | 4985 attrib_0_size_ = size_needed; |
4985 } | 4986 } |
4986 | 4987 |
4987 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); | 4988 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); |
4988 | 4989 |
4989 if (info->divisor()) | 4990 if (info->divisor()) |
(...skipping 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8308 } | 8309 } |
8309 } | 8310 } |
8310 | 8311 |
8311 // Include the auto-generated part of this file. We split this because it means | 8312 // Include the auto-generated part of this file. We split this because it means |
8312 // we can easily edit the non-auto generated parts right here in this file | 8313 // we can easily edit the non-auto generated parts right here in this file |
8313 // instead of having to edit some template or the code generator. | 8314 // instead of having to edit some template or the code generator. |
8314 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8315 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8315 | 8316 |
8316 } // namespace gles2 | 8317 } // namespace gles2 |
8317 } // namespace gpu | 8318 } // namespace gpu |
OLD | NEW |