Chromium Code Reviews| Index: cc/output/shader.h |
| diff --git a/cc/output/shader.h b/cc/output/shader.h |
| index c0cb75801e2cabe43f0467b3d2046b94d7d9a848..6afd22b8fa6e62a0845746d0976ca7db7aba0905 100644 |
| --- a/cc/output/shader.h |
| +++ b/cc/output/shader.h |
| @@ -113,257 +113,163 @@ CC_EXPORT TexCoordPrecision TexCoordPrecisionRequired( |
| int highp_threshold_min, |
| const gfx::Size& max_size); |
| -class VertexShaderPosTex { |
| +class VertexShaderBase { |
| public: |
| - VertexShaderPosTex(); |
| - |
| + VertexShaderBase(); |
| void Init(gpu::gles2::GLES2Interface* context, |
| unsigned program, |
| int* base_uniform_index); |
| std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - |
| - int matrix_location() const { return matrix_location_; } |
| - |
| - private: |
| - int matrix_location_; |
| + void FillLocations(ShaderLocations* locations) const; |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTex); |
| -}; |
| + int tex_transform_location() const { return tex_transform_location_; } |
| -class VertexShaderPosTexYUVStretchOffset { |
| - public: |
| - VertexShaderPosTexYUVStretchOffset(); |
| + int vertex_tex_transform_location() const { |
| + return vertex_tex_transform_location_; |
| + } |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| + int tex_matrix_location() const { return tex_matrix_location_; } |
| - int matrix_location() const { return matrix_location_; } |
| int ya_tex_scale_location() const { return ya_tex_scale_location_; } |
| int ya_tex_offset_location() const { return ya_tex_offset_location_; } |
| int uv_tex_scale_location() const { return uv_tex_scale_location_; } |
| int uv_tex_offset_location() const { return uv_tex_offset_location_; } |
| - private: |
| - int matrix_location_; |
| - int ya_tex_scale_location_; |
| - int ya_tex_offset_location_; |
| - int uv_tex_scale_location_; |
| - int uv_tex_offset_location_; |
| + int matrix_location() const { return matrix_location_; } |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexYUVStretchOffset); |
| -}; |
| + int vertex_opacity_location() const { return vertex_opacity_location_; } |
| -class VertexShaderPos { |
| - public: |
| - VertexShaderPos(); |
| + int viewport_location() const { return viewport_location_; } |
| + int edge_location() const { return edge_location_; } |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| + int quad_location() const { return quad_location_; } |
| - int matrix_location() const { return matrix_location_; } |
| + protected: |
| + virtual std::string GetShaderSource() const = 0; |
|
ccameron
2017/01/04 09:06:12
has_tex_transform_, has_vertex_tex_transform, has_
|
| - private: |
| - int matrix_location_; |
| + bool has_tex_transform_ = false; |
| + int tex_transform_location_ = -1; |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderPos); |
| -}; |
| + bool has_vertex_tex_transform_ = false; |
| + int vertex_tex_transform_location_ = -1; |
| -class VertexShaderPosTexIdentity { |
| - public: |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index) {} |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| -}; |
| + bool has_tex_matrix_ = false; |
| + int tex_matrix_location_ = -1; |
| -class VertexShaderPosTexTransform { |
| - public: |
| - VertexShaderPosTexTransform(); |
| + bool has_ya_uv_tex_scale_offset_ = false; |
| + int ya_tex_scale_location_ = -1; |
| + int ya_tex_offset_location_ = -1; |
| + int uv_tex_scale_location_ = -1; |
| + int uv_tex_offset_location_ = -1; |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - void FillLocations(ShaderLocations* locations) const; |
| + bool has_matrix_ = false; |
| + int matrix_location_ = -1; |
| - int matrix_location() const { return matrix_location_; } |
| - int tex_transform_location() const { return tex_transform_location_; } |
| - int vertex_opacity_location() const { return vertex_opacity_location_; } |
| + bool has_vertex_opacity_ = false; |
| + int vertex_opacity_location_ = -1; |
| - private: |
| - int matrix_location_; |
| - int tex_transform_location_; |
| - int vertex_opacity_location_; |
| + bool has_aa_ = false; |
| + int viewport_location_ = -1; |
| + int edge_location_ = -1; |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderPosTexTransform); |
| + bool has_quad_ = false; |
| + int quad_location_ = -1; |
| }; |
| -class VertexShaderQuad { |
| +class VertexShaderPosTex : public VertexShaderBase { |
| public: |
| - VertexShaderQuad(); |
| - |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - |
| - int matrix_location() const { return matrix_location_; } |
| - int viewport_location() const { return -1; } |
| - int quad_location() const { return quad_location_; } |
| - int edge_location() const { return -1; } |
| - |
| - private: |
| - int matrix_location_; |
| - int quad_location_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderQuad); |
| + VertexShaderPosTex() { has_matrix_ = true; } |
| + std::string GetShaderSource() const override; |
| }; |
| -class VertexShaderQuadAA { |
| +class VertexShaderPosTexYUVStretchOffset : public VertexShaderBase { |
| public: |
| - VertexShaderQuadAA(); |
| - |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - |
| - int matrix_location() const { return matrix_location_; } |
| - int viewport_location() const { return viewport_location_; } |
| - int quad_location() const { return quad_location_; } |
| - int edge_location() const { return edge_location_; } |
| - |
| - private: |
| - int matrix_location_; |
| - int viewport_location_; |
| - int quad_location_; |
| - int edge_location_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadAA); |
| + VertexShaderPosTexYUVStretchOffset() { |
| + has_matrix_ = true; |
| + has_ya_uv_tex_scale_offset_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| }; |
| - |
| -class VertexShaderQuadTexTransformAA { |
| +class VertexShaderPos : public VertexShaderBase { |
| public: |
| - VertexShaderQuadTexTransformAA(); |
| - |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - void FillLocations(ShaderLocations* locations) const; |
| - |
| - int matrix_location() const { return matrix_location_; } |
| - int viewport_location() const { return viewport_location_; } |
| - int quad_location() const { return quad_location_; } |
| - int edge_location() const { return edge_location_; } |
| - int tex_transform_location() const { return tex_transform_location_; } |
| - |
| - private: |
| - int matrix_location_; |
| - int viewport_location_; |
| - int quad_location_; |
| - int edge_location_; |
| - int tex_transform_location_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderQuadTexTransformAA); |
| + VertexShaderPos() { has_matrix_ = true; } |
| + std::string GetShaderSource() const override; |
| }; |
| -class VertexShaderTile { |
| +class VertexShaderPosTexIdentity : public VertexShaderBase { |
| public: |
| - VertexShaderTile(); |
| - |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| + std::string GetShaderSource() const override; |
| +}; |
| - int matrix_location() const { return matrix_location_; } |
| - int viewport_location() const { return -1; } |
| - int quad_location() const { return quad_location_; } |
| - int edge_location() const { return -1; } |
| - int vertex_tex_transform_location() const { |
| - return vertex_tex_transform_location_; |
| +class VertexShaderPosTexTransform : public VertexShaderBase { |
| + public: |
| + VertexShaderPosTexTransform() { |
| + has_matrix_ = true; |
| + has_tex_transform_ = true; |
| + has_vertex_opacity_ = true; |
| } |
| - |
| - private: |
| - int matrix_location_; |
| - int quad_location_; |
| - int vertex_tex_transform_location_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderTile); |
| + std::string GetShaderSource() const override; |
| }; |
| -class VertexShaderTileAA { |
| +class VertexShaderQuad : public VertexShaderBase { |
| public: |
| - VertexShaderTileAA(); |
| - |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| - |
| - int matrix_location() const { return matrix_location_; } |
| - int viewport_location() const { return viewport_location_; } |
| - int quad_location() const { return quad_location_; } |
| - int edge_location() const { return edge_location_; } |
| - int vertex_tex_transform_location() const { |
| - return vertex_tex_transform_location_; |
| + VertexShaderQuad() { |
| + has_matrix_ = true; |
| + has_quad_ = true; |
| } |
| - |
| - private: |
| - int matrix_location_; |
| - int viewport_location_; |
| - int quad_location_; |
| - int edge_location_; |
| - int vertex_tex_transform_location_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderTileAA); |
| + std::string GetShaderSource() const override; |
| }; |
| -class VertexShaderVideoTransform { |
| +class VertexShaderQuadAA : public VertexShaderBase { |
| public: |
| - VertexShaderVideoTransform(); |
| + VertexShaderQuadAA() { |
| + has_matrix_ = true; |
| + has_aa_ = true; |
| + has_quad_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| +}; |
| - void Init(gpu::gles2::GLES2Interface* context, |
| - unsigned program, |
| - int* base_uniform_index); |
| - std::string GetShaderString() const; |
| - static std::string GetShaderHead(); |
| - static std::string GetShaderBody(); |
| +class VertexShaderQuadTexTransformAA : public VertexShaderBase { |
| + public: |
| + VertexShaderQuadTexTransformAA() { |
| + has_matrix_ = true; |
| + has_aa_ = true; |
| + has_quad_ = true; |
| + has_tex_transform_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| +}; |
| - int matrix_location() const { return matrix_location_; } |
| - int tex_matrix_location() const { return tex_matrix_location_; } |
| +class VertexShaderTile : public VertexShaderBase { |
| + public: |
| + VertexShaderTile() { |
| + has_matrix_ = true; |
| + has_quad_ = true; |
| + has_vertex_tex_transform_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| +}; |
| - private: |
| - int matrix_location_; |
| - int tex_matrix_location_; |
| +class VertexShaderTileAA : public VertexShaderBase { |
| + public: |
| + VertexShaderTileAA() { |
| + has_matrix_ = true; |
| + has_quad_ = true; |
| + has_vertex_tex_transform_ = true; |
| + has_aa_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| +}; |
| - DISALLOW_COPY_AND_ASSIGN(VertexShaderVideoTransform); |
| +class VertexShaderVideoTransform : public VertexShaderBase { |
| + public: |
| + VertexShaderVideoTransform() { |
| + has_matrix_ = true; |
| + has_tex_matrix_ = true; |
| + } |
| + std::string GetShaderSource() const override; |
| }; |
| class FragmentShaderBase { |