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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static ProgramKey RenderPass(TexCoordPrecision precision, | 85 static ProgramKey RenderPass(TexCoordPrecision precision, |
86 SamplerType sampler, | 86 SamplerType sampler, |
87 BlendMode blend_mode, | 87 BlendMode blend_mode, |
88 AAMode aa_mode, | 88 AAMode aa_mode, |
89 MaskMode mask_mode, | 89 MaskMode mask_mode, |
90 bool mask_for_background, | 90 bool mask_for_background, |
91 bool has_color_matrix); | 91 bool has_color_matrix); |
92 static ProgramKey VideoStream(TexCoordPrecision precision); | 92 static ProgramKey VideoStream(TexCoordPrecision precision); |
93 static ProgramKey YUVVideo(TexCoordPrecision precision, | 93 static ProgramKey YUVVideo(TexCoordPrecision precision, |
94 SamplerType sampler, | 94 SamplerType sampler, |
95 bool use_alpha_texture, | 95 YUVAlphaTextureMode yuv_alpha_texture_mode, |
96 bool use_nv12, | 96 UVTextureMode uv_texture_mode, |
97 bool use_color_lut); | 97 ColorConversionMode color_conversion_mode); |
98 | 98 |
99 bool operator==(const ProgramKey& other) const; | 99 bool operator==(const ProgramKey& other) const; |
100 | 100 |
101 private: | 101 private: |
102 ProgramKey(); | 102 ProgramKey(); |
103 friend struct ProgramKeyHash; | 103 friend struct ProgramKeyHash; |
104 friend class Program; | 104 friend class Program; |
105 | 105 |
106 ProgramType type_ = PROGRAM_TYPE_DEBUG_BORDER; | 106 ProgramType type_ = PROGRAM_TYPE_DEBUG_BORDER; |
107 TexCoordPrecision precision_ = TEX_COORD_PRECISION_NA; | 107 TexCoordPrecision precision_ = TEX_COORD_PRECISION_NA; |
108 SamplerType sampler_ = SAMPLER_TYPE_NA; | 108 SamplerType sampler_ = SAMPLER_TYPE_NA; |
109 BlendMode blend_mode_ = BLEND_MODE_NONE; | 109 BlendMode blend_mode_ = BLEND_MODE_NONE; |
110 AAMode aa_mode_ = NO_AA; | 110 AAMode aa_mode_ = NO_AA; |
111 SwizzleMode swizzle_mode_ = NO_SWIZZLE; | 111 SwizzleMode swizzle_mode_ = NO_SWIZZLE; |
112 bool is_opaque_ = false; | 112 bool is_opaque_ = false; |
113 | 113 |
114 PremultipliedAlphaMode premultiplied_alpha_ = PREMULTIPLIED_ALPHA; | 114 PremultipliedAlphaMode premultiplied_alpha_ = PREMULTIPLIED_ALPHA; |
115 bool has_background_color_ = false; | 115 bool has_background_color_ = false; |
116 | 116 |
117 MaskMode mask_mode_ = NO_MASK; | 117 MaskMode mask_mode_ = NO_MASK; |
118 bool mask_for_background_ = false; | 118 bool mask_for_background_ = false; |
119 bool has_color_matrix_ = false; | 119 bool has_color_matrix_ = false; |
120 | 120 |
121 bool use_alpha_texture_ = false; | 121 YUVAlphaTextureMode yuv_alpha_texture_mode_ = YUV_NO_ALPHA_TEXTURE; |
122 bool use_nv12_ = false; | 122 UVTextureMode uv_texture_mode_ = UV_TEXTURE_MODE_NA; |
123 bool use_color_lut_ = false; | 123 |
| 124 ColorConversionMode color_conversion_mode_ = COLOR_CONVERSION_MODE_NONE; |
124 }; | 125 }; |
125 | 126 |
126 struct ProgramKeyHash { | 127 struct ProgramKeyHash { |
127 size_t operator()(const ProgramKey& key) const { | 128 size_t operator()(const ProgramKey& key) const { |
128 return (static_cast<size_t>(key.type_) << 0) ^ | 129 return (static_cast<size_t>(key.type_) << 0) ^ |
129 (static_cast<size_t>(key.precision_) << 3) ^ | 130 (static_cast<size_t>(key.precision_) << 3) ^ |
130 (static_cast<size_t>(key.sampler_) << 6) ^ | 131 (static_cast<size_t>(key.sampler_) << 6) ^ |
131 (static_cast<size_t>(key.blend_mode_) << 9) ^ | 132 (static_cast<size_t>(key.blend_mode_) << 9) ^ |
132 (static_cast<size_t>(key.aa_mode_) << 15) ^ | 133 (static_cast<size_t>(key.aa_mode_) << 15) ^ |
133 (static_cast<size_t>(key.swizzle_mode_) << 16) ^ | 134 (static_cast<size_t>(key.swizzle_mode_) << 16) ^ |
134 (static_cast<size_t>(key.is_opaque_) << 17) ^ | 135 (static_cast<size_t>(key.is_opaque_) << 17) ^ |
135 (static_cast<size_t>(key.premultiplied_alpha_) << 19) ^ | 136 (static_cast<size_t>(key.premultiplied_alpha_) << 19) ^ |
136 (static_cast<size_t>(key.has_background_color_) << 20) ^ | 137 (static_cast<size_t>(key.has_background_color_) << 20) ^ |
137 (static_cast<size_t>(key.mask_mode_) << 21) ^ | 138 (static_cast<size_t>(key.mask_mode_) << 21) ^ |
138 (static_cast<size_t>(key.mask_for_background_) << 22) ^ | 139 (static_cast<size_t>(key.mask_for_background_) << 22) ^ |
139 (static_cast<size_t>(key.has_color_matrix_) << 23) ^ | 140 (static_cast<size_t>(key.has_color_matrix_) << 23) ^ |
140 (static_cast<size_t>(key.use_alpha_texture_) << 24) ^ | 141 (static_cast<size_t>(key.yuv_alpha_texture_mode_) << 24) ^ |
141 (static_cast<size_t>(key.use_nv12_) << 25) ^ | 142 (static_cast<size_t>(key.uv_texture_mode_) << 25) ^ |
142 (static_cast<size_t>(key.use_color_lut_) << 26); | 143 (static_cast<size_t>(key.color_conversion_mode_) << 26); |
143 } | 144 } |
144 }; | 145 }; |
145 | 146 |
146 class Program : public ProgramBindingBase { | 147 class Program : public ProgramBindingBase { |
147 public: | 148 public: |
148 Program() {} | 149 Program() {} |
149 | 150 |
150 void Initialize(ContextProvider* context_provider, const ProgramKey& key) { | 151 void Initialize(ContextProvider* context_provider, const ProgramKey& key) { |
151 // Set parameters that are common to all sub-classes. | 152 // Set parameters that are common to all sub-classes. |
152 vertex_shader_.aa_mode_ = key.aa_mode_; | 153 vertex_shader_.aa_mode_ = key.aa_mode_; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 vertex_shader_.has_matrix_ = true; | 378 vertex_shader_.has_matrix_ = true; |
378 DCHECK_EQ(key.sampler_, SAMPLER_TYPE_EXTERNAL_OES); | 379 DCHECK_EQ(key.sampler_, SAMPLER_TYPE_EXTERNAL_OES); |
379 } | 380 } |
380 | 381 |
381 void InitializeYUVVideo(const ProgramKey& key) { | 382 void InitializeYUVVideo(const ProgramKey& key) { |
382 vertex_shader_.tex_coord_source_ = TEX_COORD_SOURCE_ATTRIBUTE; | 383 vertex_shader_.tex_coord_source_ = TEX_COORD_SOURCE_ATTRIBUTE; |
383 vertex_shader_.has_matrix_ = true; | 384 vertex_shader_.has_matrix_ = true; |
384 vertex_shader_.is_ya_uv_ = true; | 385 vertex_shader_.is_ya_uv_ = true; |
385 | 386 |
386 fragment_shader_.input_color_type_ = INPUT_COLOR_SOURCE_YUV_TEXTURES; | 387 fragment_shader_.input_color_type_ = INPUT_COLOR_SOURCE_YUV_TEXTURES; |
387 fragment_shader_.use_alpha_texture_ = key.use_alpha_texture_; | 388 fragment_shader_.has_uniform_alpha_ = true; |
388 fragment_shader_.use_nv12_ = key.use_nv12_; | 389 fragment_shader_.yuv_alpha_texture_mode_ = key.yuv_alpha_texture_mode_; |
389 fragment_shader_.use_color_lut_ = key.use_color_lut_; | 390 fragment_shader_.uv_texture_mode_ = key.uv_texture_mode_; |
| 391 fragment_shader_.color_conversion_mode_ = key.color_conversion_mode_; |
390 } | 392 } |
391 | 393 |
392 void InitializeInternal(ContextProvider* context_provider) { | 394 void InitializeInternal(ContextProvider* context_provider) { |
393 DCHECK(context_provider); | 395 DCHECK(context_provider); |
394 DCHECK(!initialized_); | 396 DCHECK(!initialized_); |
395 | 397 |
396 if (IsContextLost(context_provider->ContextGL())) | 398 if (IsContextLost(context_provider->ContextGL())) |
397 return; | 399 return; |
398 | 400 |
399 if (!ProgramBindingBase::Init(context_provider->ContextGL(), | 401 if (!ProgramBindingBase::Init(context_provider->ContextGL(), |
(...skipping 20 matching lines...) Expand all Loading... |
420 | 422 |
421 VertexShader vertex_shader_; | 423 VertexShader vertex_shader_; |
422 FragmentShader fragment_shader_; | 424 FragmentShader fragment_shader_; |
423 | 425 |
424 DISALLOW_COPY_AND_ASSIGN(Program); | 426 DISALLOW_COPY_AND_ASSIGN(Program); |
425 }; | 427 }; |
426 | 428 |
427 } // namespace cc | 429 } // namespace cc |
428 | 430 |
429 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ | 431 #endif // CC_OUTPUT_PROGRAM_BINDING_H_ |
OLD | NEW |