| Index: cc/output/shader.cc
|
| diff --git a/cc/output/shader.cc b/cc/output/shader.cc
|
| index 29721834e5b16451b806b1eccf44df5aa76fa0de..7b46db25b395346b0755857700fd572cc53bd41e 100644
|
| --- a/cc/output/shader.cc
|
| +++ b/cc/output/shader.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "cc/output/static_geometry_binding.h"
|
| #include "gpu/command_buffer/client/gles2_interface.h"
|
| +#include "ui/gfx/color_transform.h"
|
| #include "ui/gfx/geometry/point.h"
|
| #include "ui/gfx/geometry/size.h"
|
|
|
| @@ -439,7 +440,8 @@ void FragmentShader::Init(GLES2Interface* context,
|
| uniforms.push_back("a_texture");
|
| uniforms.push_back("ya_clamp_rect");
|
| uniforms.push_back("uv_clamp_rect");
|
| - uniforms.push_back("yuv_and_resource_matrix");
|
| + uniforms.push_back("resource_multiplier");
|
| + uniforms.push_back("resource_offset");
|
| break;
|
| case INPUT_COLOR_SOURCE_UNIFORM:
|
| uniforms.push_back("color");
|
| @@ -492,7 +494,8 @@ void FragmentShader::Init(GLES2Interface* context,
|
| a_texture_location_ = locations[index++];
|
| ya_clamp_rect_location_ = locations[index++];
|
| uv_clamp_rect_location_ = locations[index++];
|
| - yuv_and_resource_matrix_location_ = locations[index++];
|
| + resource_multiplier_location_ = locations[index++];
|
| + resource_offset_location_ = locations[index++];
|
| break;
|
| case INPUT_COLOR_SOURCE_UNIFORM:
|
| color_location_ = locations[index++];
|
| @@ -862,10 +865,12 @@ std::string FragmentShader::GetShaderSource() const {
|
| HDR("uniform SamplerType a_texture;");
|
| HDR("uniform vec4 ya_clamp_rect;");
|
| HDR("uniform vec4 uv_clamp_rect;");
|
| - HDR("uniform mat4 yuv_and_resource_matrix;");
|
| + HDR("uniform float resource_multiplier;");
|
| + HDR("uniform float resource_offset;");
|
| HDR("varying TexCoordPrecision vec2 v_yaTexCoord;");
|
| HDR("varying TexCoordPrecision vec2 v_uvTexCoord;");
|
| - SRC("texColor = yuv_and_resource_matrix * texColor;");
|
| + SRC("texColor.xyz -= vec3(resource_offset);");
|
| + SRC("texColor.xyz *= resource_multiplier;");
|
| break;
|
| case INPUT_COLOR_SOURCE_UNIFORM:
|
| DCHECK(!ignore_sampler_type_);
|
| @@ -877,22 +882,30 @@ std::string FragmentShader::GetShaderSource() const {
|
| }
|
|
|
| // Apply LUT based color conversion.
|
| - if (color_conversion_mode_ == COLOR_CONVERSION_MODE_LUT) {
|
| - HDR("uniform sampler2D lut_texture;");
|
| - HDR("uniform float lut_size;");
|
| - HDR("vec4 LUT(sampler2D sampler, vec3 pos, float size) {");
|
| - HDR(" pos *= size - 1.0;");
|
| - HDR(" // Select layer");
|
| - HDR(" float layer = min(floor(pos.z), size - 2.0);");
|
| - HDR(" // Compress the xy coordinates so they stay within");
|
| - HDR(" // [0.5 .. 31.5] / N (assuming a LUT size of 17^3)");
|
| - HDR(" pos.xy = (pos.xy + vec2(0.5)) / size;");
|
| - HDR(" pos.y = (pos.y + layer) / size;");
|
| - HDR(" return mix(LutLookup(sampler, pos.xy),");
|
| - HDR(" LutLookup(sampler, pos.xy + vec2(0, 1.0 / size)),");
|
| - HDR(" pos.z - layer);");
|
| - HDR("}");
|
| - SRC("texColor.xyz = LUT(lut_texture, texColor.xyz, lut_size).xyz;");
|
| + switch (color_conversion_mode_) {
|
| + case COLOR_CONVERSION_MODE_LUT:
|
| + HDR("uniform sampler2D lut_texture;");
|
| + HDR("uniform float lut_size;");
|
| + HDR("vec4 LUT(sampler2D sampler, vec3 pos, float size) {");
|
| + HDR(" pos *= size - 1.0;");
|
| + HDR(" // Select layer");
|
| + HDR(" float layer = min(floor(pos.z), size - 2.0);");
|
| + HDR(" // Compress the xy coordinates so they stay within");
|
| + HDR(" // [0.5 .. 31.5] / N (assuming a LUT size of 17^3)");
|
| + HDR(" pos.xy = (pos.xy + vec2(0.5)) / size;");
|
| + HDR(" pos.y = (pos.y + layer) / size;");
|
| + HDR(" return mix(LutLookup(sampler, pos.xy),");
|
| + HDR(" LutLookup(sampler, pos.xy + vec2(0, 1.0 / size)),");
|
| + HDR(" pos.z - layer);");
|
| + HDR("}");
|
| + SRC("texColor.rgb = LUT(lut_texture, texColor.xyz, lut_size).xyz;");
|
| + break;
|
| + case COLOR_CONVERSION_MODE_SHADER:
|
| + header += color_transform_->GetShaderSource();
|
| + SRC("texColor.rgb = DoColorConversion(texColor.xyz);");
|
| + break;
|
| + case COLOR_CONVERSION_MODE_NONE:
|
| + break;
|
| }
|
|
|
| // Apply the color matrix to texColor.
|
|
|