| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 PROGRAM_TYPE_SOLID_COLOR, | 59 PROGRAM_TYPE_SOLID_COLOR, |
| 60 PROGRAM_TYPE_TILE, | 60 PROGRAM_TYPE_TILE, |
| 61 PROGRAM_TYPE_TEXTURE, | 61 PROGRAM_TYPE_TEXTURE, |
| 62 PROGRAM_TYPE_RENDER_PASS, | 62 PROGRAM_TYPE_RENDER_PASS, |
| 63 PROGRAM_TYPE_VIDEO_STREAM, | 63 PROGRAM_TYPE_VIDEO_STREAM, |
| 64 PROGRAM_TYPE_YUV_VIDEO, | 64 PROGRAM_TYPE_YUV_VIDEO, |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class CC_EXPORT ProgramKey { | 67 class CC_EXPORT ProgramKey { |
| 68 public: | 68 public: |
| 69 ProgramKey(); |
| 69 ProgramKey(const ProgramKey& other); | 70 ProgramKey(const ProgramKey& other); |
| 70 ~ProgramKey(); | 71 ~ProgramKey(); |
| 71 | 72 |
| 72 static ProgramKey DebugBorder(); | 73 static ProgramKey DebugBorder(); |
| 73 static ProgramKey SolidColor(AAMode aa_mode); | 74 static ProgramKey SolidColor(AAMode aa_mode); |
| 74 static ProgramKey Tile(TexCoordPrecision precision, | 75 static ProgramKey Tile(TexCoordPrecision precision, |
| 75 SamplerType sampler, | 76 SamplerType sampler, |
| 76 AAMode aa_mode, | 77 AAMode aa_mode, |
| 77 SwizzleMode swizzle_mode, | 78 SwizzleMode swizzle_mode, |
| 78 bool is_opaque); | 79 bool is_opaque); |
| 79 static ProgramKey Texture(TexCoordPrecision precision, | 80 static ProgramKey Texture(TexCoordPrecision precision, |
| 80 SamplerType sampler, | 81 SamplerType sampler, |
| 81 PremultipliedAlphaMode premultiplied_alpha, | 82 PremultipliedAlphaMode premultiplied_alpha, |
| 82 bool has_background_color); | 83 bool has_background_color); |
| 83 | 84 |
| 84 // TODO(ccameron): Merge |mask_for_background| into MaskMode. | 85 // TODO(ccameron): Merge |mask_for_background| into MaskMode. |
| 85 static ProgramKey RenderPass(TexCoordPrecision precision, | 86 static ProgramKey RenderPass(TexCoordPrecision precision, |
| 86 SamplerType sampler, | 87 SamplerType sampler, |
| 87 BlendMode blend_mode, | 88 BlendMode blend_mode, |
| 88 AAMode aa_mode, | 89 AAMode aa_mode, |
| 89 MaskMode mask_mode, | 90 MaskMode mask_mode, |
| 90 bool mask_for_background, | 91 bool mask_for_background, |
| 91 bool has_color_matrix); | 92 bool has_color_matrix); |
| 92 static ProgramKey VideoStream(TexCoordPrecision precision); | 93 static ProgramKey VideoStream(TexCoordPrecision precision); |
| 93 static ProgramKey YUVVideo(TexCoordPrecision precision, | 94 static ProgramKey YUVVideo(TexCoordPrecision precision, |
| 94 SamplerType sampler, | 95 SamplerType sampler, |
| 95 YUVAlphaTextureMode yuv_alpha_texture_mode, | 96 YUVAlphaTextureMode yuv_alpha_texture_mode, |
| 96 UVTextureMode uv_texture_mode, | 97 UVTextureMode uv_texture_mode); |
| 97 ColorConversionMode color_conversion_mode); | |
| 98 | 98 |
| 99 bool operator==(const ProgramKey& other) const; | 99 bool operator==(const ProgramKey& other) const; |
| 100 bool operator!=(const ProgramKey& other) const; |
| 101 |
| 102 void SetColorConversionMode(ColorConversionMode color_conversion_mode) { |
| 103 color_conversion_mode_ = color_conversion_mode; |
| 104 } |
| 100 | 105 |
| 101 private: | 106 private: |
| 102 ProgramKey(); | |
| 103 friend struct ProgramKeyHash; | 107 friend struct ProgramKeyHash; |
| 104 friend class Program; | 108 friend class Program; |
| 105 | 109 |
| 106 ProgramType type_ = PROGRAM_TYPE_DEBUG_BORDER; | 110 ProgramType type_ = PROGRAM_TYPE_DEBUG_BORDER; |
| 107 TexCoordPrecision precision_ = TEX_COORD_PRECISION_NA; | 111 TexCoordPrecision precision_ = TEX_COORD_PRECISION_NA; |
| 108 SamplerType sampler_ = SAMPLER_TYPE_NA; | 112 SamplerType sampler_ = SAMPLER_TYPE_NA; |
| 109 BlendMode blend_mode_ = BLEND_MODE_NONE; | 113 BlendMode blend_mode_ = BLEND_MODE_NONE; |
| 110 AAMode aa_mode_ = NO_AA; | 114 AAMode aa_mode_ = NO_AA; |
| 111 SwizzleMode swizzle_mode_ = NO_SWIZZLE; | 115 SwizzleMode swizzle_mode_ = NO_SWIZZLE; |
| 112 bool is_opaque_ = false; | 116 bool is_opaque_ = false; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Set parameters that are common to all sub-classes. | 156 // Set parameters that are common to all sub-classes. |
| 153 vertex_shader_.aa_mode_ = key.aa_mode_; | 157 vertex_shader_.aa_mode_ = key.aa_mode_; |
| 154 fragment_shader_.aa_mode_ = key.aa_mode_; | 158 fragment_shader_.aa_mode_ = key.aa_mode_; |
| 155 fragment_shader_.blend_mode_ = key.blend_mode_; | 159 fragment_shader_.blend_mode_ = key.blend_mode_; |
| 156 fragment_shader_.tex_coord_precision_ = key.precision_; | 160 fragment_shader_.tex_coord_precision_ = key.precision_; |
| 157 fragment_shader_.sampler_type_ = key.sampler_; | 161 fragment_shader_.sampler_type_ = key.sampler_; |
| 158 fragment_shader_.swizzle_mode_ = key.swizzle_mode_; | 162 fragment_shader_.swizzle_mode_ = key.swizzle_mode_; |
| 159 fragment_shader_.premultiply_alpha_mode_ = key.premultiplied_alpha_; | 163 fragment_shader_.premultiply_alpha_mode_ = key.premultiplied_alpha_; |
| 160 fragment_shader_.mask_mode_ = key.mask_mode_; | 164 fragment_shader_.mask_mode_ = key.mask_mode_; |
| 161 fragment_shader_.mask_for_background_ = key.mask_for_background_; | 165 fragment_shader_.mask_for_background_ = key.mask_for_background_; |
| 166 fragment_shader_.color_conversion_mode_ = key.color_conversion_mode_; |
| 162 | 167 |
| 163 switch (key.type_) { | 168 switch (key.type_) { |
| 164 case PROGRAM_TYPE_DEBUG_BORDER: | 169 case PROGRAM_TYPE_DEBUG_BORDER: |
| 165 InitializeDebugBorderProgram(); | 170 InitializeDebugBorderProgram(); |
| 166 break; | 171 break; |
| 167 case PROGRAM_TYPE_SOLID_COLOR: | 172 case PROGRAM_TYPE_SOLID_COLOR: |
| 168 InitializeSolidColorProgram(key); | 173 InitializeSolidColorProgram(key); |
| 169 break; | 174 break; |
| 170 case PROGRAM_TYPE_TILE: | 175 case PROGRAM_TYPE_TILE: |
| 171 InitializeTileProgram(key); | 176 InitializeTileProgram(key); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 380 |
| 376 void InitializeYUVVideo(const ProgramKey& key) { | 381 void InitializeYUVVideo(const ProgramKey& key) { |
| 377 vertex_shader_.tex_coord_source_ = TEX_COORD_SOURCE_ATTRIBUTE; | 382 vertex_shader_.tex_coord_source_ = TEX_COORD_SOURCE_ATTRIBUTE; |
| 378 vertex_shader_.has_matrix_ = true; | 383 vertex_shader_.has_matrix_ = true; |
| 379 vertex_shader_.is_ya_uv_ = true; | 384 vertex_shader_.is_ya_uv_ = true; |
| 380 | 385 |
| 381 fragment_shader_.input_color_type_ = INPUT_COLOR_SOURCE_YUV_TEXTURES; | 386 fragment_shader_.input_color_type_ = INPUT_COLOR_SOURCE_YUV_TEXTURES; |
| 382 fragment_shader_.has_uniform_alpha_ = true; | 387 fragment_shader_.has_uniform_alpha_ = true; |
| 383 fragment_shader_.yuv_alpha_texture_mode_ = key.yuv_alpha_texture_mode_; | 388 fragment_shader_.yuv_alpha_texture_mode_ = key.yuv_alpha_texture_mode_; |
| 384 fragment_shader_.uv_texture_mode_ = key.uv_texture_mode_; | 389 fragment_shader_.uv_texture_mode_ = key.uv_texture_mode_; |
| 385 fragment_shader_.color_conversion_mode_ = key.color_conversion_mode_; | |
| 386 } | 390 } |
| 387 | 391 |
| 388 void InitializeInternal(ContextProvider* context_provider) { | 392 void InitializeInternal(ContextProvider* context_provider) { |
| 389 DCHECK(context_provider); | 393 DCHECK(context_provider); |
| 390 DCHECK(!initialized_); | 394 DCHECK(!initialized_); |
| 391 | 395 |
| 392 if (IsContextLost(context_provider->ContextGL())) | 396 if (IsContextLost(context_provider->ContextGL())) |
| 393 return; | 397 return; |
| 394 | 398 |
| 395 if (!ProgramBindingBase::Init(context_provider->ContextGL(), | 399 if (!ProgramBindingBase::Init(context_provider->ContextGL(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 416 | 420 |
| 417 VertexShader vertex_shader_; | 421 VertexShader vertex_shader_; |
| 418 FragmentShader fragment_shader_; | 422 FragmentShader fragment_shader_; |
| 419 | 423 |
| 420 DISALLOW_COPY_AND_ASSIGN(Program); | 424 DISALLOW_COPY_AND_ASSIGN(Program); |
| 421 }; | 425 }; |
| 422 | 426 |
| 423 } // namespace cc | 427 } // namespace cc |
| 424 | 428 |
| 425 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ | 429 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ |
| OLD | NEW |