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

Side by Side Diff: cc/output/shader.cc

Issue 1271843005: cc: Remove code for drawing checkerboard quads, it's not used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm-checkers: sizes Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/shader.h" 5 #include "cc/output/shader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 return SHADER0([]() { 2246 return SHADER0([]() {
2247 void main() { 2247 void main() {
2248 vec4 d4 = min(edge_dist[0], edge_dist[1]); 2248 vec4 d4 = min(edge_dist[0], edge_dist[1]);
2249 vec2 d2 = min(d4.xz, d4.yw); 2249 vec2 d2 = min(d4.xz, d4.yw);
2250 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); 2250 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0);
2251 gl_FragColor = color * aa; 2251 gl_FragColor = color * aa;
2252 } 2252 }
2253 }); 2253 });
2254 } 2254 }
2255 2255
2256 FragmentShaderCheckerboard::FragmentShaderCheckerboard()
2257 : alpha_location_(-1),
2258 tex_transform_location_(-1),
2259 frequency_location_(-1) {
2260 }
2261
2262 void FragmentShaderCheckerboard::Init(GLES2Interface* context,
2263 unsigned program,
2264 int* base_uniform_index) {
2265 static const char* uniforms[] = {
2266 "alpha", "texTransform", "frequency", "color",
2267 };
2268 int locations[arraysize(uniforms)];
2269
2270 GetProgramUniformLocations(context,
2271 program,
2272 arraysize(uniforms),
2273 uniforms,
2274 locations,
2275 base_uniform_index);
2276 alpha_location_ = locations[0];
2277 tex_transform_location_ = locations[1];
2278 frequency_location_ = locations[2];
2279 color_location_ = locations[3];
2280 }
2281
2282 std::string FragmentShaderCheckerboard::GetShaderString(
2283 TexCoordPrecision precision,
2284 SamplerType sampler) const {
2285 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody());
2286 }
2287
2288 std::string FragmentShaderCheckerboard::GetShaderHead() {
2289 return SHADER0([]() {
2290 precision mediump float;
2291 precision mediump int;
2292 varying vec2 v_texCoord;
2293 uniform float alpha;
2294 uniform float frequency;
2295 uniform vec4 texTransform;
2296 uniform vec4 color;
2297 });
2298 }
2299
2300 std::string FragmentShaderCheckerboard::GetShaderBody() {
2301 // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide"
2302 // by Munshi, Ginsburg, Shreiner.
2303 return SHADER0([]() {
2304 void main() {
2305 vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0);
2306 vec4 color2 = color;
2307 vec2 texCoord =
2308 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy;
2309 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
2310 float picker = abs(coord.x - coord.y); // NOLINT
2311 gl_FragColor = mix(color1, color2, picker) * alpha;
2312 }
2313 });
2314 }
2315
2316 } // namespace cc 2256 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698