Skip to content

Commit

Permalink
Revert "cc: Cleanup vertex shaders used for anti-aliasing."
Browse files Browse the repository at this point in the history
This reverts commit 6cfd71b.

This broke the win7 bot:

LayerTreeHostFiltersPixelTest.BackgroundFilterBlurOffAxis:
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(180)]
Percentage of pixels with an error: 0.0125
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(182)]
Percentage of pixels with errors not greater than 1: 0.0125
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(185)] Average
absolute error (excluding identical pixels): R=0.4 G=1 B=0.4 A=0
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(190)] Largest
absolute error: R=1 G=1 B=1 A=0
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(205)] Pixel
error at x=23 y=75; actual RGBA=(147,147,147,255); expected
RGBA=(146,146,146,255)
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(205)] Pixel
error at x=24 y=97; actual RGBA=(186,186,186,255); expected
RGBA=(185,185,185,255)
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(205)] Pixel
error at x=101 y=71; actual RGBA=(0,70,0,255); expected
RGBA=(0,71,0,255)
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(205)] Pixel
error at x=109 y=75; actual RGBA=(0,54,0,255); expected
RGBA=(0,55,0,255)
[8388:8392:0508/084355:938938:ERROR:pixel_comparator.cc(205)] Pixel
error at x=147 y=94; actual RGBA=(11,48,11,255); expected
RGBA=(11,49,11,255)
test\layer_tree_pixel_test.cc(61): error: Value of:
MatchesPNGFile(*bitmap, test_data_dir.Append(ref_file_),
*pixel_comparator_)
Actual: false
Expected: true

Your try results showed the same failure.

R=reveman@chromium.org
TBR=reveman@chromium.org
BUG=238644

Review URL: https://codereview.chromium.org/15027017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198912 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sky@chromium.org committed May 8, 2013
1 parent eedffc5 commit 9dffa61
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 112 deletions.
43 changes: 23 additions & 20 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GLC(Context(),
Context()->uniform1i(program->fragment_shader().sampler_location(), 0));

shader_quad_location = program->vertex_shader().quad_location();
shader_quad_location = program->vertex_shader().point_location();
shader_edge_location = program->fragment_shader().edge_location();
shader_mask_sampler_location =
program->fragment_shader().mask_sampler_location();
Expand Down Expand Up @@ -829,7 +829,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GLC(Context(),
Context()->uniform1i(program->fragment_shader().sampler_location(), 0));

shader_quad_location = program->vertex_shader().quad_location();
shader_quad_location = program->vertex_shader().point_location();
shader_edge_location = program->fragment_shader().edge_location();
shader_matrix_location = program->vertex_shader().matrix_location();
shader_alpha_location = program->fragment_shader().alpha_location();
Expand All @@ -842,7 +842,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
Context()->uniform1i(program->fragment_shader().sampler_location(), 0));

shader_matrix_location = program->vertex_shader().matrix_location();
shader_quad_location = program->vertex_shader().quad_location();
shader_quad_location = program->vertex_shader().point_location();
shader_tex_scale_location = program->vertex_shader().tex_scale_location();
shader_edge_location = program->fragment_shader().edge_location();
shader_alpha_location = program->fragment_shader().alpha_location();
Expand All @@ -864,7 +864,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
Context()->uniform1i(program->fragment_shader().sampler_location(), 0));

shader_matrix_location = program->vertex_shader().matrix_location();
shader_quad_location = program->vertex_shader().quad_location();
shader_quad_location = program->vertex_shader().point_location();
shader_tex_scale_location = program->vertex_shader().tex_scale_location();
shader_edge_location = program->fragment_shader().edge_location();
shader_alpha_location = program->fragment_shader().alpha_location();
Expand Down Expand Up @@ -1009,7 +1009,8 @@ struct SolidColorProgramUniforms {
unsigned program;
unsigned matrix_location;
unsigned color_location;
unsigned quad_location;
unsigned point_location;
unsigned tex_scale_location;
unsigned edge_location;
};

Expand All @@ -1019,7 +1020,8 @@ static void SolidColorUniformLocation(T program,
uniforms->program = program->program();
uniforms->matrix_location = program->vertex_shader().matrix_location();
uniforms->color_location = program->fragment_shader().color_location();
uniforms->quad_location = program->vertex_shader().quad_location();
uniforms->point_location = program->vertex_shader().point_location();
uniforms->tex_scale_location = program->vertex_shader().tex_scale_location();
uniforms->edge_location = program->fragment_shader().edge_location();
}

Expand Down Expand Up @@ -1110,6 +1112,7 @@ bool GLRenderer::SetupQuadForAntialiasing(

void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
const SolidColorDrawQuad* quad) {
SetBlendEnabled(quad->ShouldDrawWithBlending());
gfx::Rect tile_rect = quad->visible_rect;

SkColor color = quad->color;
Expand Down Expand Up @@ -1156,7 +1159,7 @@ void GLRenderer::DrawSolidColorQuad(const DrawingFrame* frame,
// Normalize to tile_rect.
local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());

SetShaderQuadF(local_quad, uniforms.quad_location);
SetShaderQuadF(local_quad, uniforms.point_location);

// The transform and vertex data are used to figure out the extents that the
// un-antialiased quad should have and which vertex this is and the float
Expand All @@ -1177,7 +1180,7 @@ struct TileProgramUniforms {
unsigned edge_location;
unsigned matrix_location;
unsigned alpha_location;
unsigned quad_location;
unsigned point_location;
};

template <class T>
Expand All @@ -1186,7 +1189,7 @@ static void TileUniformLocation(T program, TileProgramUniforms* uniforms) {
uniforms->vertex_tex_transform_location =
program->vertex_shader().vertex_tex_transform_location();
uniforms->matrix_location = program->vertex_shader().matrix_location();
uniforms->quad_location = program->vertex_shader().quad_location();
uniforms->point_location = program->vertex_shader().point_location();

uniforms->sampler_location = program->fragment_shader().sampler_location();
uniforms->alpha_location = program->fragment_shader().alpha_location();
Expand Down Expand Up @@ -1350,7 +1353,7 @@ void GLRenderer::DrawContentQuad(const DrawingFrame* frame,
local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());

SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
SetShaderQuadF(local_quad, uniforms.quad_location);
SetShaderQuadF(local_quad, uniforms.point_location);

// The transform and vertex data are used to figure out the extents that the
// un-antialiased quad should have and which vertex this is and the float
Expand Down Expand Up @@ -1815,16 +1818,16 @@ void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) {
if (quad_location == -1)
return;

float gl_quad[8];
gl_quad[0] = quad.p1().x();
gl_quad[1] = quad.p1().y();
gl_quad[2] = quad.p2().x();
gl_quad[3] = quad.p2().y();
gl_quad[4] = quad.p3().x();
gl_quad[5] = quad.p3().y();
gl_quad[6] = quad.p4().x();
gl_quad[7] = quad.p4().y();
GLC(context_, context_->uniform2fv(quad_location, 4, gl_quad));
float point[8];
point[0] = quad.p1().x();
point[1] = quad.p1().y();
point[2] = quad.p2().x();
point[3] = quad.p2().y();
point[4] = quad.p3().x();
point[5] = quad.p3().y();
point[6] = quad.p4().x();
point[7] = quad.p4().y();
GLC(context_, context_->uniform2fv(quad_location, 4, point));
}

void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) {
Expand Down
8 changes: 4 additions & 4 deletions cc/output/gl_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,17 @@ class CC_EXPORT GLRenderer
FragmentShaderRGBATexAlpha> RenderPassProgram;
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexAlphaMask> RenderPassMaskProgram;
typedef ProgramBinding<VertexShaderQuadTex, FragmentShaderRGBATexAlphaAA>
typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexAlphaAA>
RenderPassProgramAA;
typedef ProgramBinding<VertexShaderQuadTex, FragmentShaderRGBATexAlphaMaskAA>
typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexAlphaMaskAA>
RenderPassMaskProgramAA;
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexColorMatrixAlpha>
RenderPassColorMatrixProgram;
typedef ProgramBinding<VertexShaderQuadTex,
typedef ProgramBinding<VertexShaderQuad,
FragmentShaderRGBATexAlphaMaskColorMatrixAA>
RenderPassMaskColorMatrixProgramAA;
typedef ProgramBinding<VertexShaderQuadTex,
typedef ProgramBinding<VertexShaderQuad,
FragmentShaderRGBATexAlphaColorMatrixAA>
RenderPassColorMatrixProgramAA;
typedef ProgramBinding<VertexShaderPosTexTransform,
Expand Down
91 changes: 28 additions & 63 deletions cc/output/shader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,59 +323,16 @@ std::string VertexShaderPosTexIdentity::GetShaderString() const {

VertexShaderQuad::VertexShaderQuad()
: matrix_location_(-1),
quad_location_(-1) {}
point_location_(-1),
tex_scale_location_(-1) {}

void VertexShaderQuad::Init(WebGraphicsContext3D* context,
unsigned program,
bool using_bind_uniform,
int* base_uniform_index) {
static const char* shader_uniforms[] = {
"matrix",
"quad",
};
int locations[2];

GetProgramUniformLocations(context,
program,
shader_uniforms,
arraysize(shader_uniforms),
arraysize(locations),
locations,
using_bind_uniform,
base_uniform_index);

matrix_location_ = locations[0];
quad_location_ = locations[1];
DCHECK_NE(matrix_location_, -1);
DCHECK_NE(quad_location_, -1);
}

std::string VertexShaderQuad::GetShaderString() const {
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
uniform mat4 matrix;
uniform TexCoordPrecision vec2 quad[4];
void main() {
vec2 pos = quad[int(a_index)]; // NOLINT
gl_Position = matrix * vec4(
pos.x, pos.y, a_position.z, a_position.w);
}
); // NOLINT(whitespace/parens)
}

VertexShaderQuadTex::VertexShaderQuadTex()
: matrix_location_(-1),
quad_location_(-1),
tex_scale_location_(-1) {}

void VertexShaderQuadTex::Init(WebGraphicsContext3D* context,
unsigned program,
bool using_bind_uniform,
int* base_uniform_index) {
static const char* shader_uniforms[] = {
"matrix",
"quad",
"point",
"texScale",
};
int locations[3];
Expand All @@ -390,33 +347,37 @@ void VertexShaderQuadTex::Init(WebGraphicsContext3D* context,
base_uniform_index);

matrix_location_ = locations[0];
quad_location_ = locations[1];
point_location_ = locations[1];
tex_scale_location_ = locations[2];
DCHECK_NE(matrix_location_, -1);
DCHECK_NE(quad_location_, -1);
DCHECK_NE(point_location_, -1);
DCHECK_NE(tex_scale_location_, -1);
}

std::string VertexShaderQuadTex::GetShaderString() const {
std::string VertexShaderQuad::GetShaderString() const {
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
uniform TexCoordPrecision vec2 quad[4];
uniform TexCoordPrecision vec2 point[4];
uniform TexCoordPrecision vec2 texScale;
varying TexCoordPrecision vec2 v_texCoord;
void main() {
vec2 pos = quad[int(a_index)]; // NOLINT
gl_Position = matrix * vec4(
pos.x, pos.y, a_position.z, a_position.w);
TexCoordPrecision vec2 complement = abs(a_texCoord - 1.0);
TexCoordPrecision vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
pos.xy += (complement.x * complement.y) * point[0];
pos.xy += (a_texCoord.x * complement.y) * point[1];
pos.xy += (a_texCoord.x * a_texCoord.y) * point[2];
pos.xy += (complement.x * a_texCoord.y) * point[3];
gl_Position = matrix * pos;
v_texCoord = (pos.xy + vec2(0.5)) * texScale;
}
); // NOLINT(whitespace/parens)
}

VertexShaderTile::VertexShaderTile()
: matrix_location_(-1),
quad_location_(-1),
point_location_(-1),
vertex_tex_transform_location_(-1) {}

void VertexShaderTile::Init(WebGraphicsContext3D* context,
Expand All @@ -425,7 +386,7 @@ void VertexShaderTile::Init(WebGraphicsContext3D* context,
int* base_uniform_index) {
static const char* shader_uniforms[] = {
"matrix",
"quad",
"point",
"vertexTexTransform",
};
int locations[3];
Expand All @@ -440,24 +401,28 @@ void VertexShaderTile::Init(WebGraphicsContext3D* context,
base_uniform_index);

matrix_location_ = locations[0];
quad_location_ = locations[1];
point_location_ = locations[1];
vertex_tex_transform_location_ = locations[2];
DCHECK(matrix_location_ != -1 && quad_location_ != -1 &&
DCHECK(matrix_location_ != -1 && point_location_ != -1 &&
vertex_tex_transform_location_ != -1);
}

std::string VertexShaderTile::GetShaderString() const {
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
attribute TexCoordPrecision vec2 a_texCoord;
uniform mat4 matrix;
uniform TexCoordPrecision vec2 quad[4];
uniform TexCoordPrecision vec2 point[4];
uniform TexCoordPrecision vec4 vertexTexTransform;
varying TexCoordPrecision vec2 v_texCoord;
void main() {
vec2 pos = quad[int(a_index)]; // NOLINT
gl_Position = matrix * vec4(
pos.x, pos.y, a_position.z, a_position.w);
TexCoordPrecision vec2 complement = abs(a_texCoord - 1.0);
TexCoordPrecision vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w);
pos.xy += (complement.x * complement.y) * point[0];
pos.xy += (a_texCoord.x * complement.y) * point[1];
pos.xy += (a_texCoord.x * a_texCoord.y) * point[2];
pos.xy += (complement.x * a_texCoord.y) * point[3];
gl_Position = matrix * pos;
v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy;
}
); // NOLINT(whitespace/parens)
Expand Down
30 changes: 5 additions & 25 deletions cc/output/shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,35 +147,15 @@ class VertexShaderQuad {
std::string GetShaderString() const;

int matrix_location() const { return matrix_location_; }
int quad_location() const { return quad_location_; }

private:
int matrix_location_;
int quad_location_;

DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad);
};

class VertexShaderQuadTex {
public:
VertexShaderQuadTex();

void Init(WebKit::WebGraphicsContext3D* context,
unsigned program,
bool using_bind_uniform,
int* base_uniform_index);
std::string GetShaderString() const;

int matrix_location() const { return matrix_location_; }
int quad_location() const { return quad_location_; }
int point_location() const { return point_location_; }
int tex_scale_location() const { return tex_scale_location_; }

private:
int matrix_location_;
int quad_location_;
int point_location_;
int tex_scale_location_;

DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTex);
DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad);
};

class VertexShaderTile {
Expand All @@ -189,14 +169,14 @@ class VertexShaderTile {
std::string GetShaderString() const;

int matrix_location() const { return matrix_location_; }
int quad_location() const { return quad_location_; }
int point_location() const { return point_location_; }
int vertex_tex_transform_location() const {
return vertex_tex_transform_location_;
}

private:
int matrix_location_;
int quad_location_;
int point_location_;
int vertex_tex_transform_location_;

DISALLOW_COPY_AND_ASSIGN(VertexShaderTile);
Expand Down
Binary file modified cc/test/data/background_filter_blur_off_axis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9dffa61

Please sign in to comment.