Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4851)

Unified Diff: cc/output/shader.cc

Issue 658153003: cc: clang-format shader.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format the file Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/shader.cc
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index 72d89d23c0983ac7ddb3ec44acb0809984f3a80f..905d51aed4cd8f47db4af97aae2dc6944a3d1883 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -13,8 +13,9 @@
#define SHADER0(Src) #Src
#define VERTEX_SHADER(Src) SetVertexTexCoordPrecision(SHADER0(Src))
-#define FRAGMENT_SHADER(Src) SetFragmentTexCoordPrecision( \
- precision, SetFragmentSamplerType(sampler, SHADER0(Src)))
+#define FRAGMENT_SHADER(Src) \
+ SetFragmentTexCoordPrecision(precision, \
+ SetFragmentSamplerType(sampler, SHADER0(Src)))
using gpu::gles2::GLES2Interface;
@@ -35,21 +36,20 @@ static void GetProgramUniformLocations(GLES2Interface* context,
}
static std::string SetFragmentTexCoordPrecision(
- TexCoordPrecision requested_precision, std::string shader_string) {
+ TexCoordPrecision requested_precision,
+ std::string shader_string) {
switch (requested_precision) {
case TexCoordPrecisionHigh:
DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos);
- return
- "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
- " #define TexCoordPrecision highp\n"
- "#else\n"
- " #define TexCoordPrecision mediump\n"
- "#endif\n" +
- shader_string;
+ return "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
+ " #define TexCoordPrecision highp\n"
+ "#else\n"
+ " #define TexCoordPrecision mediump\n"
+ "#endif\n" +
+ shader_string;
case TexCoordPrecisionMedium:
DCHECK_NE(shader_string.find("TexCoordPrecision"), std::string::npos);
- return "#define TexCoordPrecision mediump\n" +
- shader_string;
+ return "#define TexCoordPrecision mediump\n" + shader_string;
case TexCoordPrecisionNA:
DCHECK_EQ(shader_string.find("TexCoordPrecision"), std::string::npos);
DCHECK_EQ(shader_string.find("texture2D"), std::string::npos);
@@ -67,24 +67,24 @@ static std::string SetVertexTexCoordPrecision(const char* shader_string) {
// we are unlikely to be vertex shader bound when drawing large quads.
// Also, some vertex shaders mutate the texture coordinate in such a
// way that the effective precision might be lower than expected.
- return "#define TexCoordPrecision highp\n" +
- std::string(shader_string);
+ return "#define TexCoordPrecision highp\n" + std::string(shader_string);
}
TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
- int *highp_threshold_cache,
+ int* highp_threshold_cache,
int highp_threshold_min,
- int x, int y) {
+ int x,
+ int y) {
if (*highp_threshold_cache == 0) {
// Initialize range and precision with minimum spec values for when
// GetShaderPrecisionFormat is a test stub.
// TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat
// everywhere.
- GLint range[2] = { 14, 14 };
+ GLint range[2] = {14, 14};
GLint precision = 10;
- GLC(context, context->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER,
- GL_MEDIUM_FLOAT,
- range, &precision));
+ GLC(context,
+ context->GetShaderPrecisionFormat(
+ GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range, &precision));
*highp_threshold_cache = 1 << precision;
}
@@ -94,32 +94,29 @@ TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
return TexCoordPrecisionMedium;
}
-static std::string SetFragmentSamplerType(
- SamplerType requested_type, std::string shader_string) {
+static std::string SetFragmentSamplerType(SamplerType requested_type,
+ std::string shader_string) {
switch (requested_type) {
case SamplerType2D:
DCHECK_NE(shader_string.find("SamplerType"), std::string::npos);
DCHECK_NE(shader_string.find("TextureLookup"), std::string::npos);
- return
- "#define SamplerType sampler2D\n"
- "#define TextureLookup texture2D\n" +
- shader_string;
+ return "#define SamplerType sampler2D\n"
+ "#define TextureLookup texture2D\n" +
+ shader_string;
case SamplerType2DRect:
DCHECK_NE(shader_string.find("SamplerType"), std::string::npos);
DCHECK_NE(shader_string.find("TextureLookup"), std::string::npos);
- return
- "#extension GL_ARB_texture_rectangle : require\n"
- "#define SamplerType sampler2DRect\n"
- "#define TextureLookup texture2DRect\n" +
- shader_string;
+ return "#extension GL_ARB_texture_rectangle : require\n"
+ "#define SamplerType sampler2DRect\n"
+ "#define TextureLookup texture2DRect\n" +
+ shader_string;
case SamplerTypeExternalOES:
DCHECK_NE(shader_string.find("SamplerType"), std::string::npos);
DCHECK_NE(shader_string.find("TextureLookup"), std::string::npos);
- return
- "#extension GL_OES_EGL_image_external : require\n"
- "#define SamplerType samplerExternalOES\n"
- "#define TextureLookup texture2D\n" +
- shader_string;
+ return "#extension GL_OES_EGL_image_external : require\n"
+ "#define SamplerType samplerExternalOES\n"
+ "#define TextureLookup texture2D\n" +
+ shader_string;
case SamplerTypeNA:
DCHECK_EQ(shader_string.find("SamplerType"), std::string::npos);
DCHECK_EQ(shader_string.find("TextureLookup"), std::string::npos);
@@ -138,21 +135,25 @@ TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
int highp_threshold_min,
const gfx::Point& max_coordinate) {
return TexCoordPrecisionRequired(context,
- highp_threshold_cache, highp_threshold_min,
- max_coordinate.x(), max_coordinate.y());
+ highp_threshold_cache,
+ highp_threshold_min,
+ max_coordinate.x(),
+ max_coordinate.y());
}
TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context,
- int *highp_threshold_cache,
+ int* highp_threshold_cache,
int highp_threshold_min,
const gfx::Size& max_size) {
return TexCoordPrecisionRequired(context,
- highp_threshold_cache, highp_threshold_min,
- max_size.width(), max_size.height());
+ highp_threshold_cache,
+ highp_threshold_min,
+ max_size.width(),
+ max_size.height());
}
-VertexShaderPosTex::VertexShaderPosTex()
- : matrix_location_(-1) {}
+VertexShaderPosTex::VertexShaderPosTex() : matrix_location_(-1) {
+}
void VertexShaderPosTex::Init(GLES2Interface* context,
unsigned program,
@@ -172,6 +173,7 @@ void VertexShaderPosTex::Init(GLES2Interface* context,
}
std::string VertexShaderPosTex::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute vec4 a_position;
attribute TexCoordPrecision vec2 a_texCoord;
@@ -182,18 +184,18 @@ std::string VertexShaderPosTex::GetShaderString() const {
v_texCoord = a_texCoord;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderPosTexYUVStretchOffset::VertexShaderPosTexYUVStretchOffset()
- : matrix_location_(-1), tex_scale_location_(-1), tex_offset_location_(-1) {}
+ : matrix_location_(-1), tex_scale_location_(-1), tex_offset_location_(-1) {
+}
void VertexShaderPosTexYUVStretchOffset::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "texScale",
- "texOffset",
+ "matrix", "texScale", "texOffset",
};
int locations[arraysize(uniforms)];
@@ -209,6 +211,7 @@ void VertexShaderPosTexYUVStretchOffset::Init(GLES2Interface* context,
}
std::string VertexShaderPosTexYUVStretchOffset::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
precision mediump float;
attribute vec4 a_position;
@@ -222,10 +225,11 @@ std::string VertexShaderPosTexYUVStretchOffset::GetShaderString() const {
v_texCoord = a_texCoord * texScale + texOffset;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
-VertexShaderPos::VertexShaderPos()
- : matrix_location_(-1) {}
+VertexShaderPos::VertexShaderPos() : matrix_location_(-1) {
+}
void VertexShaderPos::Init(GLES2Interface* context,
unsigned program,
@@ -245,6 +249,7 @@ void VertexShaderPos::Init(GLES2Interface* context,
}
std::string VertexShaderPos::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute vec4 a_position;
uniform mat4 matrix;
@@ -252,20 +257,20 @@ std::string VertexShaderPos::GetShaderString() const {
gl_Position = matrix * a_position;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderPosTexTransform::VertexShaderPosTexTransform()
: matrix_location_(-1),
tex_transform_location_(-1),
- vertex_opacity_location_(-1) {}
+ vertex_opacity_location_(-1) {
+}
void VertexShaderPosTexTransform::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "texTransform",
- "opacity",
+ "matrix", "texTransform", "opacity",
};
int locations[arraysize(uniforms)];
@@ -281,6 +286,7 @@ void VertexShaderPosTexTransform::Init(GLES2Interface* context,
}
std::string VertexShaderPosTexTransform::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute vec4 a_position;
attribute TexCoordPrecision vec2 a_texCoord;
@@ -298,9 +304,11 @@ std::string VertexShaderPosTexTransform::GetShaderString() const {
v_alpha = opacity[int(a_index)]; // NOLINT
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string VertexShaderPosTexIdentity::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute vec4 a_position;
varying TexCoordPrecision vec2 v_texCoord;
@@ -309,18 +317,18 @@ std::string VertexShaderPosTexIdentity::GetShaderString() const {
v_texCoord = (a_position.xy + vec2(1.0)) * 0.5;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderQuad::VertexShaderQuad()
- : matrix_location_(-1),
- quad_location_(-1) {}
+ : matrix_location_(-1), quad_location_(-1) {
+}
void VertexShaderQuad::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "quad",
+ "matrix", "quad",
};
int locations[arraysize(uniforms)];
@@ -336,9 +344,10 @@ void VertexShaderQuad::Init(GLES2Interface* context,
std::string VertexShaderQuad::GetShaderString() const {
#if defined(OS_ANDROID)
-// TODO(epenner): Find the cause of this 'quad' uniform
-// being missing if we don't add dummy variables.
-// http://crbug.com/240602
+ // TODO(epenner): Find the cause of this 'quad' uniform
+ // being missing if we don't add dummy variables.
+ // http://crbug.com/240602
+ // clang-format off
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
@@ -352,7 +361,9 @@ std::string VertexShaderQuad::GetShaderString() const {
dummy_varying = dummy_uniform;
}
); // NOLINT(whitespace/parens)
+// clang-format on
danakj 2014/10/16 19:25:11 why is this at column 0 :(
#else
+ // clang-format off
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
@@ -363,6 +374,7 @@ std::string VertexShaderQuad::GetShaderString() const {
gl_Position = matrix * vec4(pos, a_position.z, a_position.w);
}
); // NOLINT(whitespace/parens)
+// clang-format on
danakj 2014/10/16 19:25:10 and this? :(
#endif
}
@@ -370,16 +382,14 @@ VertexShaderQuadAA::VertexShaderQuadAA()
: matrix_location_(-1),
viewport_location_(-1),
quad_location_(-1),
- edge_location_(-1) {}
+ edge_location_(-1) {
+}
void VertexShaderQuadAA::Init(GLES2Interface* context,
- unsigned program,
- int* base_uniform_index) {
+ unsigned program,
+ int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "viewport",
- "quad",
- "edge",
+ "matrix", "viewport", "quad", "edge",
};
int locations[arraysize(uniforms)];
@@ -396,6 +406,7 @@ void VertexShaderQuadAA::Init(GLES2Interface* context,
}
std::string VertexShaderQuadAA::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
@@ -482,20 +493,20 @@ std::string VertexShaderQuadTexTransformAA::GetShaderString() const {
v_texCoord = (pos.xy + vec2(0.5)) * texTrans.zw + texTrans.xy;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderTile::VertexShaderTile()
: matrix_location_(-1),
quad_location_(-1),
- vertex_tex_transform_location_(-1) {}
+ vertex_tex_transform_location_(-1) {
+}
void VertexShaderTile::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "quad",
- "vertexTexTransform",
+ "matrix", "quad", "vertexTexTransform",
};
int locations[arraysize(uniforms)];
@@ -511,6 +522,7 @@ void VertexShaderTile::Init(GLES2Interface* context,
}
std::string VertexShaderTile::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
@@ -524,6 +536,7 @@ std::string VertexShaderTile::GetShaderString() const {
v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderTileAA::VertexShaderTileAA()
@@ -531,17 +544,14 @@ VertexShaderTileAA::VertexShaderTileAA()
viewport_location_(-1),
quad_location_(-1),
edge_location_(-1),
- vertex_tex_transform_location_(-1) {}
+ vertex_tex_transform_location_(-1) {
+}
void VertexShaderTileAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "viewport",
- "quad",
- "edge",
- "vertexTexTransform",
+ "matrix", "viewport", "quad", "edge", "vertexTexTransform",
};
int locations[arraysize(uniforms)];
@@ -559,6 +569,7 @@ void VertexShaderTileAA::Init(GLES2Interface* context,
}
std::string VertexShaderTileAA::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute TexCoordPrecision vec4 a_position;
attribute float a_index;
@@ -586,18 +597,18 @@ std::string VertexShaderTileAA::GetShaderString() const {
v_texCoord = pos.xy * vertexTexTransform.zw + vertexTexTransform.xy;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
VertexShaderVideoTransform::VertexShaderVideoTransform()
- : matrix_location_(-1),
- tex_matrix_location_(-1) {}
+ : matrix_location_(-1), tex_matrix_location_(-1) {
+}
void VertexShaderVideoTransform::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "matrix",
- "texMatrix",
+ "matrix", "texMatrix",
};
int locations[arraysize(uniforms)];
@@ -612,6 +623,7 @@ void VertexShaderVideoTransform::Init(GLES2Interface* context,
}
std::string VertexShaderVideoTransform::GetShaderString() const {
+ // clang-format off
return VERTEX_SHADER(
attribute vec4 a_position;
attribute TexCoordPrecision vec2 a_texCoord;
@@ -624,18 +636,18 @@ std::string VertexShaderVideoTransform::GetShaderString() const {
vec2(texMatrix * vec4(a_texCoord.x, 1.0 - a_texCoord.y, 0.0, 1.0));
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentTexAlphaBinding::FragmentTexAlphaBinding()
- : sampler_location_(-1),
- alpha_location_(-1) {}
+ : sampler_location_(-1), alpha_location_(-1) {
+}
void FragmentTexAlphaBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "alpha",
+ "s_texture", "alpha",
};
int locations[arraysize(uniforms)];
@@ -653,16 +665,14 @@ FragmentTexColorMatrixAlphaBinding::FragmentTexColorMatrixAlphaBinding()
: sampler_location_(-1),
alpha_location_(-1),
color_matrix_location_(-1),
- color_offset_location_(-1) {}
+ color_offset_location_(-1) {
+}
void FragmentTexColorMatrixAlphaBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "alpha",
- "colorMatrix",
- "colorOffset",
+ "s_texture", "alpha", "colorMatrix", "colorOffset",
};
int locations[arraysize(uniforms)];
@@ -678,14 +688,14 @@ void FragmentTexColorMatrixAlphaBinding::Init(GLES2Interface* context,
color_offset_location_ = locations[3];
}
-FragmentTexOpaqueBinding::FragmentTexOpaqueBinding()
- : sampler_location_(-1) {}
+FragmentTexOpaqueBinding::FragmentTexOpaqueBinding() : sampler_location_(-1) {
+}
void FragmentTexOpaqueBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
+ "s_texture",
};
int locations[arraysize(uniforms)];
@@ -699,7 +709,9 @@ void FragmentTexOpaqueBinding::Init(GLES2Interface* context,
}
std::string FragmentShaderRGBATexAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -710,10 +722,13 @@ std::string FragmentShaderRGBATexAlpha::GetShaderString(
gl_FragColor = texColor * alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -731,10 +746,13 @@ std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderString(
gl_FragColor = texColor * alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -745,10 +763,13 @@ std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString(
gl_FragColor = texColor * v_alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexPremultiplyAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -760,19 +781,18 @@ std::string FragmentShaderRGBATexPremultiplyAlpha::GetShaderString(
gl_FragColor = texColor * v_alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentTexBackgroundBinding::FragmentTexBackgroundBinding()
- : background_color_location_(-1),
- sampler_location_(-1) {
+ : background_color_location_(-1), sampler_location_(-1) {
}
void FragmentTexBackgroundBinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "background_color",
+ "s_texture", "background_color",
};
int locations[arraysize(uniforms)];
@@ -791,7 +811,9 @@ void FragmentTexBackgroundBinding::Init(GLES2Interface* context,
}
std::string FragmentShaderTexBackgroundVaryingAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -804,10 +826,13 @@ std::string FragmentShaderTexBackgroundVaryingAlpha::GetShaderString(
gl_FragColor = texColor * v_alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderTexBackgroundPremultiplyAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -821,10 +846,13 @@ std::string FragmentShaderTexBackgroundPremultiplyAlpha::GetShaderString(
gl_FragColor = texColor * v_alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexOpaque::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -834,10 +862,12 @@ std::string FragmentShaderRGBATexOpaque::GetShaderString(
gl_FragColor = vec4(texColor.rgb, 1.0);
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
-std::string FragmentShaderRGBATex::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+std::string FragmentShaderRGBATex::GetShaderString(TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -846,10 +876,13 @@ std::string FragmentShaderRGBATex::GetShaderString(
gl_FragColor = TextureLookup(s_texture, v_texCoord);
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexSwizzleAlpha::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -861,10 +894,13 @@ std::string FragmentShaderRGBATexSwizzleAlpha::GetShaderString(
vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexSwizzleOpaque::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
@@ -874,18 +910,18 @@ std::string FragmentShaderRGBATexSwizzleOpaque::GetShaderString(
gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, 1.0);
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA()
- : sampler_location_(-1),
- alpha_location_(-1) {}
+ : sampler_location_(-1), alpha_location_(-1) {
+}
void FragmentShaderRGBATexAlphaAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "alpha",
+ "s_texture", "alpha",
};
int locations[arraysize(uniforms)];
@@ -900,7 +936,9 @@ void FragmentShaderRGBATexAlphaAA::Init(GLES2Interface* context,
}
std::string FragmentShaderRGBATexAlphaAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
uniform SamplerType s_texture;
@@ -916,20 +954,20 @@ std::string FragmentShaderRGBATexAlphaAA::GetShaderString(
gl_FragColor = texColor * alpha * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding()
: sampler_location_(-1),
alpha_location_(-1),
- fragment_tex_transform_location_(-1) {}
+ fragment_tex_transform_location_(-1) {
+}
void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "alpha",
- "fragmentTexTransform",
+ "s_texture", "alpha", "fragmentTexTransform",
};
int locations[arraysize(uniforms)];
@@ -945,7 +983,9 @@ void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context,
}
std::string FragmentShaderRGBATexClampAlphaAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
uniform SamplerType s_texture;
@@ -965,10 +1005,13 @@ std::string FragmentShaderRGBATexClampAlphaAA::GetShaderString(
gl_FragColor = texColor * alpha * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
std::string FragmentShaderRGBATexClampSwizzleAlphaAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
danakj 2014/10/16 19:25:11 could we turn format on inside the shader code som
enne (OOO) 2014/10/16 19:39:30 Done. The only weirdness (other than the growing
precision mediump float;
uniform SamplerType s_texture;
@@ -989,23 +1032,21 @@ std::string FragmentShaderRGBATexClampSwizzleAlphaAA::GetShaderString(
alpha * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask()
: sampler_location_(-1),
mask_sampler_location_(-1),
alpha_location_(-1),
- mask_tex_coord_scale_location_(-1) {}
+ mask_tex_coord_scale_location_(-1) {
+}
void FragmentShaderRGBATexAlphaMask::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "s_mask",
- "alpha",
- "maskTexCoordScale",
- "maskTexCoordOffset",
+ "s_texture", "s_mask", "alpha", "maskTexCoordScale", "maskTexCoordOffset",
};
int locations[arraysize(uniforms)];
@@ -1023,17 +1064,19 @@ void FragmentShaderRGBATexAlphaMask::Init(GLES2Interface* context,
}
std::string FragmentShaderRGBATexAlphaMask::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
- uniform SamplerType s_texture;
+ uniform sampler2D s_texture;
danakj 2014/10/16 19:25:11 <_<
enne (OOO) 2014/10/16 19:39:30 I blame emacs.
uniform SamplerType s_mask;
uniform TexCoordPrecision vec2 maskTexCoordScale;
uniform TexCoordPrecision vec2 maskTexCoordOffset;
uniform float alpha;
void main() {
- vec4 texColor = TextureLookup(s_texture, v_texCoord);
+ vec4 texColor = texture2D(s_texture, v_texCoord);
TexCoordPrecision vec2 maskTexCoord =
vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x,
maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
@@ -1041,6 +1084,7 @@ std::string FragmentShaderRGBATexAlphaMask::GetShaderString(
gl_FragColor = texColor * alpha * maskColor.w;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
@@ -1048,17 +1092,14 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
mask_sampler_location_(-1),
alpha_location_(-1),
mask_tex_coord_scale_location_(-1),
- mask_tex_coord_offset_location_(-1) {}
+ mask_tex_coord_offset_location_(-1) {
+}
void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "s_mask",
- "alpha",
- "maskTexCoordScale",
- "maskTexCoordOffset",
+ "s_texture", "s_mask", "alpha", "maskTexCoordScale", "maskTexCoordOffset",
};
int locations[arraysize(uniforms)];
@@ -1076,10 +1117,12 @@ void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context,
}
std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
- uniform SamplerType s_texture;
+ uniform sampler2D s_texture;
uniform SamplerType s_mask;
uniform TexCoordPrecision vec2 maskTexCoordScale;
uniform TexCoordPrecision vec2 maskTexCoordOffset;
@@ -1088,7 +1131,7 @@ std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString(
varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances.
void main() {
- vec4 texColor = TextureLookup(s_texture, v_texCoord);
+ vec4 texColor = texture2D(s_texture, v_texCoord);
danakj 2014/10/16 19:25:10 <_<
TexCoordPrecision vec2 maskTexCoord =
vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x,
maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y);
@@ -1099,29 +1142,31 @@ std::string FragmentShaderRGBATexAlphaMaskAA::GetShaderString(
gl_FragColor = texColor * alpha * maskColor.w * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaMaskColorMatrixAA::
FragmentShaderRGBATexAlphaMaskColorMatrixAA()
- : sampler_location_(-1),
- mask_sampler_location_(-1),
- alpha_location_(-1),
- mask_tex_coord_scale_location_(-1),
- color_matrix_location_(-1),
- color_offset_location_(-1) {}
+ : sampler_location_(-1),
+ mask_sampler_location_(-1),
+ alpha_location_(-1),
+ mask_tex_coord_scale_location_(-1),
+ color_matrix_location_(-1),
+ color_offset_location_(-1) {
+}
void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init(
GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "s_mask",
- "alpha",
- "maskTexCoordScale",
- "maskTexCoordOffset",
- "colorMatrix",
- "colorOffset",
+ "s_texture",
+ "s_mask",
+ "alpha",
+ "maskTexCoordScale",
+ "maskTexCoordOffset",
+ "colorMatrix",
+ "colorOffset",
};
int locations[arraysize(uniforms)];
@@ -1141,10 +1186,12 @@ void FragmentShaderRGBATexAlphaMaskColorMatrixAA::Init(
}
std::string FragmentShaderRGBATexAlphaMaskColorMatrixAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
- uniform SamplerType s_texture;
+ uniform sampler2D s_texture;
uniform SamplerType s_mask;
uniform vec2 maskTexCoordScale;
uniform vec2 maskTexCoordOffset;
@@ -1155,7 +1202,7 @@ std::string FragmentShaderRGBATexAlphaMaskColorMatrixAA::GetShaderString(
varying TexCoordPrecision vec4 edge_dist[2]; // 8 edge distances.
void main() {
- vec4 texColor = TextureLookup(s_texture, v_texCoord);
+ vec4 texColor = texture2D(s_texture, v_texCoord);
float nonZeroAlpha = max(texColor.a, 0.00001);
texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha);
texColor = colorMatrix * texColor + colorOffset;
@@ -1171,24 +1218,22 @@ std::string FragmentShaderRGBATexAlphaMaskColorMatrixAA::GetShaderString(
gl_FragColor = texColor * alpha * maskColor.w * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaColorMatrixAA::
FragmentShaderRGBATexAlphaColorMatrixAA()
- : sampler_location_(-1),
- alpha_location_(-1),
- color_matrix_location_(-1),
- color_offset_location_(-1) {}
-
-void FragmentShaderRGBATexAlphaColorMatrixAA::Init(
- GLES2Interface* context,
- unsigned program,
- int* base_uniform_index) {
+ : sampler_location_(-1),
+ alpha_location_(-1),
+ color_matrix_location_(-1),
+ color_offset_location_(-1) {
+}
+
+void FragmentShaderRGBATexAlphaColorMatrixAA::Init(GLES2Interface* context,
+ unsigned program,
+ int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "alpha",
- "colorMatrix",
- "colorOffset",
+ "s_texture", "alpha", "colorMatrix", "colorOffset",
};
int locations[arraysize(uniforms)];
@@ -1205,7 +1250,9 @@ void FragmentShaderRGBATexAlphaColorMatrixAA::Init(
}
std::string FragmentShaderRGBATexAlphaColorMatrixAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
uniform SamplerType s_texture;
@@ -1228,27 +1275,28 @@ std::string FragmentShaderRGBATexAlphaColorMatrixAA::GetShaderString(
gl_FragColor = texColor * alpha * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderRGBATexAlphaMaskColorMatrix::
FragmentShaderRGBATexAlphaMaskColorMatrix()
- : sampler_location_(-1),
- mask_sampler_location_(-1),
- alpha_location_(-1),
- mask_tex_coord_scale_location_(-1) {}
+ : sampler_location_(-1),
+ mask_sampler_location_(-1),
+ alpha_location_(-1),
+ mask_tex_coord_scale_location_(-1) {
+}
-void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(
- GLES2Interface* context,
- unsigned program,
- int* base_uniform_index) {
+void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(GLES2Interface* context,
+ unsigned program,
+ int* base_uniform_index) {
static const char* uniforms[] = {
- "s_texture",
- "s_mask",
- "alpha",
- "maskTexCoordScale",
- "maskTexCoordOffset",
- "colorMatrix",
- "colorOffset",
+ "s_texture",
+ "s_mask",
+ "alpha",
+ "maskTexCoordScale",
+ "maskTexCoordOffset",
+ "colorMatrix",
+ "colorOffset",
};
int locations[arraysize(uniforms)];
@@ -1268,11 +1316,13 @@ void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(
}
std::string FragmentShaderRGBATexAlphaMaskColorMatrix::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
varying TexCoordPrecision vec2 v_texCoord;
- uniform SamplerType s_texture;
+ uniform sampler2D s_texture;
uniform SamplerType s_mask;
uniform vec2 maskTexCoordScale;
uniform vec2 maskTexCoordOffset;
@@ -1280,7 +1330,7 @@ std::string FragmentShaderRGBATexAlphaMaskColorMatrix::GetShaderString(
uniform vec4 colorOffset;
uniform float alpha;
void main() {
- vec4 texColor = TextureLookup(s_texture, v_texCoord);
+ vec4 texColor = texture2D(s_texture, v_texCoord);
float nonZeroAlpha = max(texColor.a, 0.00001);
texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha);
texColor = colorMatrix * texColor + colorOffset;
@@ -1293,6 +1343,7 @@ std::string FragmentShaderRGBATexAlphaMaskColorMatrix::GetShaderString(
gl_FragColor = texColor * alpha * maskColor.w;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderYUVVideo::FragmentShaderYUVVideo()
@@ -1301,18 +1352,14 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo()
v_texture_location_(-1),
alpha_location_(-1),
yuv_matrix_location_(-1),
- yuv_adj_location_(-1) {}
+ yuv_adj_location_(-1) {
+}
void FragmentShaderYUVVideo::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "y_texture",
- "u_texture",
- "v_texture",
- "alpha",
- "yuv_matrix",
- "yuv_adj",
+ "y_texture", "u_texture", "v_texture", "alpha", "yuv_matrix", "yuv_adj",
};
int locations[arraysize(uniforms)];
@@ -1330,8 +1377,9 @@ void FragmentShaderYUVVideo::Init(GLES2Interface* context,
yuv_adj_location_ = locations[5];
}
-std::string FragmentShaderYUVVideo::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+std::string FragmentShaderYUVVideo::GetShaderString(TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
precision mediump int;
@@ -1351,6 +1399,7 @@ std::string FragmentShaderYUVVideo::GetShaderString(
gl_FragColor = vec4(rgb, 1.0) * alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderYUVAVideo::FragmentShaderYUVAVideo()
@@ -1393,7 +1442,9 @@ void FragmentShaderYUVAVideo::Init(GLES2Interface* context,
}
std::string FragmentShaderYUVAVideo::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
precision mediump int;
@@ -1415,16 +1466,17 @@ std::string FragmentShaderYUVAVideo::GetShaderString(
gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw);
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
-FragmentShaderColor::FragmentShaderColor()
- : color_location_(-1) {}
+FragmentShaderColor::FragmentShaderColor() : color_location_(-1) {
+}
void FragmentShaderColor::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "color",
+ "color",
};
int locations[arraysize(uniforms)];
@@ -1437,8 +1489,9 @@ void FragmentShaderColor::Init(GLES2Interface* context,
color_location_ = locations[0];
}
-std::string FragmentShaderColor::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+std::string FragmentShaderColor::GetShaderString(TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
uniform vec4 color;
@@ -1446,16 +1499,17 @@ std::string FragmentShaderColor::GetShaderString(
gl_FragColor = color;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
-FragmentShaderColorAA::FragmentShaderColorAA()
- : color_location_(-1) {}
+FragmentShaderColorAA::FragmentShaderColorAA() : color_location_(-1) {
+}
void FragmentShaderColorAA::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "color",
+ "color",
};
int locations[arraysize(uniforms)];
@@ -1468,8 +1522,9 @@ void FragmentShaderColorAA::Init(GLES2Interface* context,
color_location_ = locations[0];
}
-std::string FragmentShaderColorAA::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+std::string FragmentShaderColorAA::GetShaderString(TexCoordPrecision precision,
+ SamplerType sampler) const {
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
uniform vec4 color;
@@ -1482,21 +1537,20 @@ std::string FragmentShaderColorAA::GetShaderString(
gl_FragColor = color * aa;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
FragmentShaderCheckerboard::FragmentShaderCheckerboard()
: alpha_location_(-1),
tex_transform_location_(-1),
- frequency_location_(-1) {}
+ frequency_location_(-1) {
+}
void FragmentShaderCheckerboard::Init(GLES2Interface* context,
unsigned program,
int* base_uniform_index) {
static const char* uniforms[] = {
- "alpha",
- "texTransform",
- "frequency",
- "color",
+ "alpha", "texTransform", "frequency", "color",
};
int locations[arraysize(uniforms)];
@@ -1513,9 +1567,11 @@ void FragmentShaderCheckerboard::Init(GLES2Interface* context,
}
std::string FragmentShaderCheckerboard::GetShaderString(
- TexCoordPrecision precision, SamplerType sampler) const {
+ TexCoordPrecision precision,
+ SamplerType sampler) const {
// Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide"
// by Munshi, Ginsburg, Shreiner.
+ // clang-format off
return FRAGMENT_SHADER(
precision mediump float;
precision mediump int;
@@ -1534,6 +1590,7 @@ std::string FragmentShaderCheckerboard::GetShaderString(
gl_FragColor = mix(color1, color2, picker) * alpha;
}
); // NOLINT(whitespace/parens)
+ // clang-format on
}
} // namespace cc
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698