| 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_SHADER_H_ | 5 #ifndef CC_OUTPUT_SHADER_H_ |
| 6 #define CC_OUTPUT_SHADER_H_ | 6 #define CC_OUTPUT_SHADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 FRAG_COLOR_MODE_OPAQUE, | 118 FRAG_COLOR_MODE_OPAQUE, |
| 119 FRAG_COLOR_MODE_APPLY_BLEND_MODE, | 119 FRAG_COLOR_MODE_APPLY_BLEND_MODE, |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 enum MaskMode { | 122 enum MaskMode { |
| 123 NO_MASK = 0, | 123 NO_MASK = 0, |
| 124 HAS_MASK = 1, | 124 HAS_MASK = 1, |
| 125 LAST_MASK_VALUE = HAS_MASK | 125 LAST_MASK_VALUE = HAS_MASK |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 struct ShaderLocations { | |
| 129 ShaderLocations(); | |
| 130 | |
| 131 int sampler = -1; | |
| 132 int quad = -1; | |
| 133 int edge = -1; | |
| 134 int viewport = -1; | |
| 135 int mask_sampler = -1; | |
| 136 int mask_tex_coord_scale = -1; | |
| 137 int mask_tex_coord_offset = -1; | |
| 138 int matrix = -1; | |
| 139 int alpha = -1; | |
| 140 int color_matrix = -1; | |
| 141 int color_offset = -1; | |
| 142 int vertex_tex_transform = -1; | |
| 143 int backdrop = -1; | |
| 144 int backdrop_rect = -1; | |
| 145 int original_backdrop = -1; | |
| 146 }; | |
| 147 | |
| 148 // Note: The highp_threshold_cache must be provided by the caller to make | 128 // Note: The highp_threshold_cache must be provided by the caller to make |
| 149 // the caching multi-thread/context safe in an easy low-overhead manner. | 129 // the caching multi-thread/context safe in an easy low-overhead manner. |
| 150 // The caller must make sure to clear highp_threshold_cache to 0, so it can be | 130 // The caller must make sure to clear highp_threshold_cache to 0, so it can be |
| 151 // reinitialized, if a new or different context is used. | 131 // reinitialized, if a new or different context is used. |
| 152 CC_EXPORT TexCoordPrecision | 132 CC_EXPORT TexCoordPrecision |
| 153 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, | 133 TexCoordPrecisionRequired(gpu::gles2::GLES2Interface* context, |
| 154 int* highp_threshold_cache, | 134 int* highp_threshold_cache, |
| 155 int highp_threshold_min, | 135 int highp_threshold_min, |
| 156 const gfx::Point& max_coordinate); | 136 const gfx::Point& max_coordinate); |
| 157 | 137 |
| 158 CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired( | 138 CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired( |
| 159 gpu::gles2::GLES2Interface* context, | 139 gpu::gles2::GLES2Interface* context, |
| 160 int *highp_threshold_cache, | 140 int *highp_threshold_cache, |
| 161 int highp_threshold_min, | 141 int highp_threshold_min, |
| 162 const gfx::Size& max_size); | 142 const gfx::Size& max_size); |
| 163 | 143 |
| 164 class VertexShaderBase { | 144 class VertexShaderBase { |
| 165 public: | 145 public: |
| 166 VertexShaderBase(); | 146 VertexShaderBase(); |
| 167 void Init(gpu::gles2::GLES2Interface* context, | 147 void Init(gpu::gles2::GLES2Interface* context, |
| 168 unsigned program, | 148 unsigned program, |
| 169 int* base_uniform_index); | 149 int* base_uniform_index); |
| 170 std::string GetShaderString() const; | 150 std::string GetShaderString() const; |
| 171 void FillLocations(ShaderLocations* locations) const; | |
| 172 | |
| 173 int vertex_tex_transform_location() const { | |
| 174 return vertex_tex_transform_location_; | |
| 175 } | |
| 176 | |
| 177 int tex_matrix_location() const { return tex_matrix_location_; } | |
| 178 | |
| 179 int ya_tex_scale_location() const { return ya_tex_scale_location_; } | |
| 180 int ya_tex_offset_location() const { return ya_tex_offset_location_; } | |
| 181 int uv_tex_scale_location() const { return uv_tex_scale_location_; } | |
| 182 int uv_tex_offset_location() const { return uv_tex_offset_location_; } | |
| 183 | |
| 184 int matrix_location() const { return matrix_location_; } | |
| 185 | |
| 186 int vertex_opacity_location() const { return vertex_opacity_location_; } | |
| 187 | |
| 188 int viewport_location() const { return viewport_location_; } | |
| 189 int edge_location() const { return edge_location_; } | |
| 190 | |
| 191 int quad_location() const { return quad_location_; } | |
| 192 | 151 |
| 193 protected: | 152 protected: |
| 194 template <class VertexShader, class FragmentShader> | 153 template <class VertexShader, class FragmentShader> |
| 195 friend class ProgramBinding; | 154 friend class ProgramBinding; |
| 196 | 155 |
| 197 // Use arrays of uniforms for matrix, texTransform, and opacity. | 156 // Use arrays of uniforms for matrix, texTransform, and opacity. |
| 198 bool use_uniform_arrays_ = false; | 157 bool use_uniform_arrays_ = false; |
| 199 | 158 |
| 200 PositionSource position_source_ = POSITION_SOURCE_ATTRIBUTE; | 159 PositionSource position_source_ = POSITION_SOURCE_ATTRIBUTE; |
| 201 TexCoordSource tex_coord_source_ = TEX_COORD_SOURCE_NONE; | 160 TexCoordSource tex_coord_source_ = TEX_COORD_SOURCE_NONE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 int viewport_location_ = -1; | 192 int viewport_location_ = -1; |
| 234 int edge_location_ = -1; | 193 int edge_location_ = -1; |
| 235 }; | 194 }; |
| 236 | 195 |
| 237 class FragmentShaderBase { | 196 class FragmentShaderBase { |
| 238 public: | 197 public: |
| 239 virtual void Init(gpu::gles2::GLES2Interface* context, | 198 virtual void Init(gpu::gles2::GLES2Interface* context, |
| 240 unsigned program, | 199 unsigned program, |
| 241 int* base_uniform_index); | 200 int* base_uniform_index); |
| 242 std::string GetShaderString() const; | 201 std::string GetShaderString() const; |
| 243 void FillLocations(ShaderLocations* locations) const; | |
| 244 | |
| 245 int sampler_location() const { return sampler_location_; } | |
| 246 int alpha_location() const { return alpha_location_; } | |
| 247 int color_location() const { return color_location_; } | |
| 248 int background_color_location() const { return background_color_location_; } | |
| 249 int fragment_tex_transform_location() const { | |
| 250 return fragment_tex_transform_location_; | |
| 251 } | |
| 252 | 202 |
| 253 protected: | 203 protected: |
| 254 FragmentShaderBase(); | 204 FragmentShaderBase(); |
| 255 virtual std::string GetShaderSource() const; | 205 virtual std::string GetShaderSource() const; |
| 256 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } | 206 bool has_blend_mode() const { return blend_mode_ != BLEND_MODE_NONE; } |
| 257 | 207 |
| 258 std::string SetBlendModeFunctions(const std::string& shader_string) const; | 208 std::string SetBlendModeFunctions(const std::string& shader_string) const; |
| 259 | 209 |
| 260 // Settings that are modified by sub-classes. | 210 // Settings that are modified by sub-classes. |
| 261 AAMode aa_mode_ = NO_AA; | 211 AAMode aa_mode_ = NO_AA; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 int yuv_adj_location_ = -1; | 312 int yuv_adj_location_ = -1; |
| 363 int ya_clamp_rect_location_ = -1; | 313 int ya_clamp_rect_location_ = -1; |
| 364 int uv_clamp_rect_location_ = -1; | 314 int uv_clamp_rect_location_ = -1; |
| 365 int resource_multiplier_location_ = -1; | 315 int resource_multiplier_location_ = -1; |
| 366 int resource_offset_location_ = -1; | 316 int resource_offset_location_ = -1; |
| 367 }; | 317 }; |
| 368 | 318 |
| 369 } // namespace cc | 319 } // namespace cc |
| 370 | 320 |
| 371 #endif // CC_OUTPUT_SHADER_H_ | 321 #endif // CC_OUTPUT_SHADER_H_ |
| OLD | NEW |