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

Unified Diff: cc/shader.cc

Issue 12393053: Re-land: cc: Added antialiasing support for solid color layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Chrome style formatting changes. Created 7 years, 9 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 | « cc/shader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/shader.cc
diff --git a/cc/shader.cc b/cc/shader.cc
index 0bd4e85abfcc35584292b2e45ac5123a932957f9..eaf4b56b88332cb03a7ea6ccf8ba3bf48493b9ef 100644
--- a/cc/shader.cc
+++ b/cc/shader.cc
@@ -842,6 +842,49 @@ std::string FragmentShaderColor::getShaderString() const
);
}
+FragmentShaderColorAA::FragmentShaderColorAA()
+ : m_edgeLocation(-1)
+ , m_colorLocation(-1)
+{
+}
+
+void FragmentShaderColorAA::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex)
+{
+ static const char* shaderUniforms[] = {
+ "edge",
+ "color",
+ };
+ int locations[2];
+
+ getProgramUniformLocations(context, program, shaderUniforms, arraysize(shaderUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex);
+
+ m_edgeLocation = locations[0];
+ m_colorLocation = locations[1];
+ DCHECK(m_edgeLocation != -1 && m_colorLocation != -1);
+}
+
+std::string FragmentShaderColorAA::getShaderString() const
+{
+ return SHADER(
+ precision mediump float;
+ uniform vec4 color;
+ uniform vec3 edge[8];
+ void main()
+ {
+ vec3 pos = vec3(gl_FragCoord.xy, 1);
+ float a0 = clamp(dot(edge[0], pos), 0.0, 1.0);
+ float a1 = clamp(dot(edge[1], pos), 0.0, 1.0);
+ float a2 = clamp(dot(edge[2], pos), 0.0, 1.0);
+ float a3 = clamp(dot(edge[3], pos), 0.0, 1.0);
+ float a4 = clamp(dot(edge[4], pos), 0.0, 1.0);
+ float a5 = clamp(dot(edge[5], pos), 0.0, 1.0);
+ float a6 = clamp(dot(edge[6], pos), 0.0, 1.0);
+ float a7 = clamp(dot(edge[7], pos), 0.0, 1.0);
+ gl_FragColor = color * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7));
+ }
+ );
+}
+
FragmentShaderCheckerboard::FragmentShaderCheckerboard()
: m_alphaLocation(-1)
, m_texTransformLocation(-1)
« no previous file with comments | « cc/shader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698