| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef CC_OUTPUT_PROGRAM_BINDING_H_ | 5 #ifndef CC_OUTPUT_PROGRAM_BINDING_H_ |
| 6 #define CC_OUTPUT_PROGRAM_BINDING_H_ | 6 #define CC_OUTPUT_PROGRAM_BINDING_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 unsigned vertex_shader_id_; | 41 unsigned vertex_shader_id_; |
| 42 unsigned fragment_shader_id_; | 42 unsigned fragment_shader_id_; |
| 43 bool initialized_; | 43 bool initialized_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 template <class VertexShader, class FragmentShader> | 46 template <class VertexShader, class FragmentShader> |
| 47 class ProgramBinding : public ProgramBindingBase { | 47 class ProgramBinding : public ProgramBindingBase { |
| 48 public: | 48 public: |
| 49 explicit ProgramBinding(WebKit::WebGraphicsContext3D* context) { | 49 explicit ProgramBinding(WebKit::WebGraphicsContext3D* context) { |
| 50 ProgramBindingBase::Init(context, | 50 ProgramBindingBase::Init(context, |
| 51 vertex_shader_.getShaderString(), | 51 vertex_shader_.GetShaderString(), |
| 52 fragment_shader_.getShaderString()); | 52 fragment_shader_.GetShaderString()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Initialize(WebKit::WebGraphicsContext3D* context, | 55 void Initialize(WebKit::WebGraphicsContext3D* context, |
| 56 bool using_bind_uniform) { | 56 bool using_bind_uniform) { |
| 57 DCHECK(context); | 57 DCHECK(context); |
| 58 DCHECK(!initialized_); | 58 DCHECK(!initialized_); |
| 59 | 59 |
| 60 if (IsContextLost(context)) | 60 if (IsContextLost(context)) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 // Need to bind uniforms before linking | 63 // Need to bind uniforms before linking |
| 64 if (!using_bind_uniform) | 64 if (!using_bind_uniform) |
| 65 Link(context); | 65 Link(context); |
| 66 | 66 |
| 67 int base_uniform_index = 0; | 67 int base_uniform_index = 0; |
| 68 vertex_shader_.init( | 68 vertex_shader_.Init( |
| 69 context, program_, using_bind_uniform, &base_uniform_index); | 69 context, program_, using_bind_uniform, &base_uniform_index); |
| 70 fragment_shader_.init( | 70 fragment_shader_.Init( |
| 71 context, program_, using_bind_uniform, &base_uniform_index); | 71 context, program_, using_bind_uniform, &base_uniform_index); |
| 72 | 72 |
| 73 // Link after binding uniforms | 73 // Link after binding uniforms |
| 74 if (using_bind_uniform) | 74 if (using_bind_uniform) |
| 75 Link(context); | 75 Link(context); |
| 76 | 76 |
| 77 initialized_ = true; | 77 initialized_ = true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 const VertexShader& vertex_shader() const { return vertex_shader_; } | 80 const VertexShader& vertex_shader() const { return vertex_shader_; } |
| 81 const FragmentShader& fragment_shader() const { return fragment_shader_; } | 81 const FragmentShader& fragment_shader() const { return fragment_shader_; } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 VertexShader vertex_shader_; | 84 VertexShader vertex_shader_; |
| 85 FragmentShader fragment_shader_; | 85 FragmentShader fragment_shader_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace cc | 88 } // namespace cc |
| 89 | 89 |
| 90 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ | 90 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ |
| OLD | NEW |