| 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 "content/common/gpu/client/gl_helper_scaling.h" | 5 #include "content/common/gpu/client/gl_helper_scaling.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 texture_location_ = gl_->GetUniformLocation(program_, "s_texture"); | 863 texture_location_ = gl_->GetUniformLocation(program_, "s_texture"); |
| 864 src_subrect_location_ = gl_->GetUniformLocation(program_, "src_subrect"); | 864 src_subrect_location_ = gl_->GetUniformLocation(program_, "src_subrect"); |
| 865 src_pixelsize_location_ = gl_->GetUniformLocation(program_, "src_pixelsize"); | 865 src_pixelsize_location_ = gl_->GetUniformLocation(program_, "src_pixelsize"); |
| 866 dst_pixelsize_location_ = gl_->GetUniformLocation(program_, "dst_pixelsize"); | 866 dst_pixelsize_location_ = gl_->GetUniformLocation(program_, "dst_pixelsize"); |
| 867 scaling_vector_location_ = | 867 scaling_vector_location_ = |
| 868 gl_->GetUniformLocation(program_, "scaling_vector"); | 868 gl_->GetUniformLocation(program_, "scaling_vector"); |
| 869 color_weights_location_ = gl_->GetUniformLocation(program_, "color_weights"); | 869 color_weights_location_ = gl_->GetUniformLocation(program_, "color_weights"); |
| 870 // The only reason fetching these attribute locations should fail is | 870 // The only reason fetching these attribute locations should fail is |
| 871 // if the context was spontaneously lost (i.e., because the GPU | 871 // if the context was spontaneously lost (i.e., because the GPU |
| 872 // process crashed, perhaps deliberately for testing). | 872 // process crashed, perhaps deliberately for testing). |
| 873 // Unfortunately, the only way to reliably detect context loss from | 873 DCHECK_IMPLIES(!Initialized(), |
| 874 // GLES2Interface would be to repeatedly call GetError(), and this | 874 gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR); |
| 875 // seems fragile. Most of the APIs in GLHelper should be updated to | |
| 876 // be able to return an error. Fortunately, many users of this code | |
| 877 // check for context loss at a higher level. | |
| 878 if (!Initialized()) { | |
| 879 LOG(ERROR) << "ShaderProgram::Setup: initialization failed (context lost?)"; | |
| 880 } | |
| 881 return; | |
| 882 } | 875 } |
| 883 | 876 |
| 884 void ShaderProgram::UseProgram(const gfx::Size& src_size, | 877 void ShaderProgram::UseProgram(const gfx::Size& src_size, |
| 885 const gfx::Rect& src_subrect, | 878 const gfx::Rect& src_subrect, |
| 886 const gfx::Size& dst_size, | 879 const gfx::Size& dst_size, |
| 887 bool scale_x, | 880 bool scale_x, |
| 888 bool flip_y, | 881 bool flip_y, |
| 889 GLfloat color_weights[4]) { | 882 GLfloat color_weights[4]) { |
| 890 gl_->UseProgram(program_); | 883 gl_->UseProgram(program_); |
| 891 | 884 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 gl_->Uniform2f(dst_pixelsize_location_, | 923 gl_->Uniform2f(dst_pixelsize_location_, |
| 931 static_cast<float>(dst_size.width()), | 924 static_cast<float>(dst_size.width()), |
| 932 static_cast<float>(dst_size.height())); | 925 static_cast<float>(dst_size.height())); |
| 933 | 926 |
| 934 gl_->Uniform2f( | 927 gl_->Uniform2f( |
| 935 scaling_vector_location_, scale_x ? 1.0 : 0.0, scale_x ? 0.0 : 1.0); | 928 scaling_vector_location_, scale_x ? 1.0 : 0.0, scale_x ? 0.0 : 1.0); |
| 936 gl_->Uniform4fv(color_weights_location_, 1, color_weights); | 929 gl_->Uniform4fv(color_weights_location_, 1, color_weights); |
| 937 } | 930 } |
| 938 | 931 |
| 939 } // namespace content | 932 } // namespace content |
| OLD | NEW |