summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 02:06:17 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 02:06:17 +0000
commitef42bd09a75449561b9f69db5e53f97f419d38f7 (patch)
tree23b376582d966a73c059289fc0ae5827945b1b4e /cc
parent71d763524920672b5cd00e6cb19eb048b0bf2ba8 (diff)
downloadchromium_src-ef42bd09a75449561b9f69db5e53f97f419d38f7.zip
chromium_src-ef42bd09a75449561b9f69db5e53f97f419d38f7.tar.gz
chromium_src-ef42bd09a75449561b9f69db5e53f97f419d38f7.tar.bz2
Delete VertexShaderPosTexTransformFlip.
The flip can be easily done using the texture transform in VertexShaderPosTexTransform. There is no need for a different shader just to do the flip. Review URL: https://chromiumcodereview.appspot.com/18084004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/output/gl_renderer.cc55
-rw-r--r--cc/output/gl_renderer.h6
-rw-r--r--cc/output/gl_renderer_unittest.cc1
-rw-r--r--cc/output/shader.cc21
-rw-r--r--cc/output/shader.h9
5 files changed, 19 insertions, 73 deletions
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 74fe4942..0b8a9f3 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -87,6 +87,17 @@ bool NeedsIOSurfaceReadbackWorkaround() {
#endif
}
+Float4 UVTransform(const TextureDrawQuad* quad) {
+ gfx::PointF uv0 = quad->uv_top_left;
+ gfx::PointF uv1 = quad->uv_bottom_right;
+ Float4 xform = { { uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y() } };
+ if (quad->flipped) {
+ xform.data[1] = 1.0f - xform.data[1];
+ xform.data[3] = -xform.data[3];
+ }
+ return xform;
+}
+
// Smallest unit that impact anti-aliasing output. We use this to
// determine when anti-aliasing is unnecessary.
const float kAntiAliasingEpsilon = 1.0f / 1024.0f;
@@ -1747,10 +1758,7 @@ void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
// Choose the correct texture program binding
TexTransformTextureProgramBinding binding;
- if (quad->flipped)
- binding.Set(GetTextureProgramFlip(tex_coord_precision), Context());
- else
- binding.Set(GetTextureProgram(tex_coord_precision), Context());
+ binding.Set(GetTextureProgram(tex_coord_precision), Context());
int resource_id = quad->resource_id;
@@ -1772,10 +1780,7 @@ void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame,
}
// Generate the uv-transform
- gfx::PointF uv0 = quad->uv_top_left;
- gfx::PointF uv1 = quad->uv_bottom_right;
- Float4 uv = { { uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y() } };
- draw_cache_.uv_xform_data.push_back(uv);
+ draw_cache_.uv_xform_data.push_back(UVTransform(quad));
// Generate the vertex opacity
const float opacity = quad->opacity();
@@ -1801,20 +1806,16 @@ void GLRenderer::DrawTextureQuad(const DrawingFrame* frame,
quad->shared_quad_state->visible_content_rect.bottom_right());
TexTransformTextureProgramBinding binding;
- if (quad->flipped)
- binding.Set(GetTextureProgramFlip(tex_coord_precision), Context());
- else
- binding.Set(GetTextureProgram(tex_coord_precision), Context());
+ binding.Set(GetTextureProgram(tex_coord_precision), Context());
SetUseProgram(binding.program_id);
GLC(Context(), Context()->uniform1i(binding.sampler_location, 0));
- gfx::PointF uv0 = quad->uv_top_left;
- gfx::PointF uv1 = quad->uv_bottom_right;
+ Float4 uv_xform = UVTransform(quad);
GLC(Context(),
Context()->uniform4f(binding.tex_transform_location,
- uv0.x(),
- uv0.y(),
- uv1.x() - uv0.x(),
- uv1.y() - uv0.y()));
+ uv_xform.data[0],
+ uv_xform.data[1],
+ uv_xform.data[2],
+ uv_xform.data[3]));
GLC(Context(),
Context()->uniform1fv(
@@ -2810,20 +2811,6 @@ const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram(
return program.get();
}
-const GLRenderer::TextureProgramFlip* GLRenderer::GetTextureProgramFlip(
- TexCoordPrecision precision) {
- scoped_ptr<TextureProgramFlip>& program =
- (precision == TexCoordPrecisionHigh) ? texture_program_flip_highp_
- : texture_program_flip_;
- if (!program)
- program = make_scoped_ptr(new TextureProgramFlip(context_, precision));
- if (!program->initialized()) {
- TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize");
- program->Initialize(context_, is_using_bind_uniform_);
- }
- return program.get();
-}
-
const GLRenderer::TextureIOSurfaceProgram*
GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) {
scoped_ptr<TextureIOSurfaceProgram>& program =
@@ -2953,15 +2940,11 @@ void GLRenderer::CleanupSharedObjects() {
if (texture_program_)
texture_program_->Cleanup(context_);
- if (texture_program_flip_)
- texture_program_flip_->Cleanup(context_);
if (texture_io_surface_program_)
texture_io_surface_program_->Cleanup(context_);
if (texture_program_highp_)
texture_program_highp_->Cleanup(context_);
- if (texture_program_flip_highp_)
- texture_program_flip_highp_->Cleanup(context_);
if (texture_io_surface_program_highp_)
texture_io_surface_program_highp_->Cleanup(context_);
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index 21acdde..3283324 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -256,8 +256,6 @@ class CC_EXPORT GLRenderer
// Texture shaders.
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexVaryingAlpha> TextureProgram;
- typedef ProgramBinding<VertexShaderPosTexTransformFlip,
- FragmentShaderRGBATexVaryingAlpha> TextureProgramFlip;
typedef ProgramBinding<VertexShaderPosTexTransform,
FragmentShaderRGBATexRectVaryingAlpha>
TextureIOSurfaceProgram;
@@ -331,8 +329,6 @@ class CC_EXPORT GLRenderer
const TextureProgram* GetTextureProgram(
TexCoordPrecision precision);
- const TextureProgramFlip* GetTextureProgramFlip(
- TexCoordPrecision precision);
const TextureIOSurfaceProgram* GetTextureIOSurfaceProgram(
TexCoordPrecision precision);
@@ -363,11 +359,9 @@ class CC_EXPORT GLRenderer
scoped_ptr<TileProgramSwizzleAA> tile_program_swizzle_aa_highp_;
scoped_ptr<TextureProgram> texture_program_;
- scoped_ptr<TextureProgramFlip> texture_program_flip_;
scoped_ptr<TextureIOSurfaceProgram> texture_io_surface_program_;
scoped_ptr<TextureProgram> texture_program_highp_;
- scoped_ptr<TextureProgramFlip> texture_program_flip_highp_;
scoped_ptr<TextureIOSurfaceProgram> texture_io_surface_program_highp_;
scoped_ptr<RenderPassProgram> render_pass_program_;
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index 27db3a7..97c73fa 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -93,7 +93,6 @@ class GLRendererShaderPixelTest : public GLRendererPixelTest {
EXPECT_PROGRAM_VALID(
renderer()->GetRenderPassMaskColorMatrixProgram(precision));
EXPECT_PROGRAM_VALID(renderer()->GetTextureProgram(precision));
- EXPECT_PROGRAM_VALID(renderer()->GetTextureProgramFlip(precision));
EXPECT_PROGRAM_VALID(renderer()->GetTextureIOSurfaceProgram(precision));
EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVProgram(precision));
EXPECT_PROGRAM_VALID(renderer()->GetVideoYUVAProgram(precision));
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index 161ee90..e08ee8a 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -289,27 +289,6 @@ std::string VertexShaderPosTexTransform::GetShaderString() const {
); // NOLINT(whitespace/parens)
}
-std::string VertexShaderPosTexTransformFlip::GetShaderString() const {
- return VERTEX_SHADER(
- attribute vec4 a_position;
- attribute TexCoordPrecision vec2 a_texCoord;
- attribute float a_index;
- uniform mat4 matrix[8];
- uniform TexCoordPrecision vec4 texTransform[8];
- uniform float opacity[32];
- varying TexCoordPrecision vec2 v_texCoord;
- varying float v_alpha;
- void main() {
- gl_Position = matrix[int(a_index * 0.25)] * a_position; // NOLINT
- TexCoordPrecision vec4 texTrans =
- texTransform[int(a_index * 0.25)]; // NOLINT
- v_texCoord = a_texCoord * texTrans.zw + texTrans.xy;
- v_texCoord.y = 1.0 - v_texCoord.y;
- v_alpha = opacity[int(a_index)]; // NOLINT
- }
- ); // NOLINT(whitespace/parens)
-}
-
std::string VertexShaderPosTexIdentity::GetShaderString() const {
return VERTEX_SHADER(
attribute vec4 a_position;
diff --git a/cc/output/shader.h b/cc/output/shader.h
index d8a039c..44eedef 100644
--- a/cc/output/shader.h
+++ b/cc/output/shader.h
@@ -131,15 +131,6 @@ class VertexShaderPosTexTransform {
DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform);
};
-class VertexShaderPosTexTransformFlip : public VertexShaderPosTexTransform {
- public:
- VertexShaderPosTexTransformFlip() {}
- std::string GetShaderString() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransformFlip);
-};
-
class VertexShaderQuad {
public:
VertexShaderQuad();