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

Side by Side Diff: src/gpu/effects/GrDitherEffect.cpp

Issue 345083002: Stop referencing gl_FragCoord z and w components. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix circle effect Created 6 years, 6 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 | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDitherEffect.h" 8 #include "GrDitherEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Generate a random number based on the fragment position. For this 95 // Generate a random number based on the fragment position. For this
96 // random number generator, we use the "GLSL rand" function 96 // random number generator, we use the "GLSL rand" function
97 // that seems to be floating around on the internet. It works under 97 // that seems to be floating around on the internet. It works under
98 // the assumption that sin(<big number>) oscillates with high frequency 98 // the assumption that sin(<big number>) oscillates with high frequency
99 // and sampling it will generate "randomness". Since we're using this 99 // and sampling it will generate "randomness". Since we're using this
100 // for rendering and not cryptography it should be OK. 100 // for rendering and not cryptography it should be OK.
101 101
102 // For each channel c, add the random offset to the pixel to either bump 102 // For each channel c, add the random offset to the pixel to either bump
103 // it up or let it remain constant during quantization. 103 // it up or let it remain constant during quantization.
104 builder->fsCodeAppendf("\t\tfloat r = " 104 builder->fsCodeAppendf("\t\tfloat r = "
105 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758. 5453);\n", 105 "fract(sin(dot(%s ,vec2(12.9898,78.233))) * 43758.545 3);\n",
106 builder->fragmentPosition()); 106 builder->fragmentPosition());
107 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", 107 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n",
108 outputColor, GrGLSLExpr4(inputColor).c_str()); 108 outputColor, GrGLSLExpr4(inputColor).c_str());
109 } 109 }
110 110
111 ////////////////////////////////////////////////////////////////////////////// 111 //////////////////////////////////////////////////////////////////////////////
112 112
113 GrEffectRef* GrDitherEffect::Create() { 113 GrEffectRef* GrDitherEffect::Create() {
114 return DitherEffect::Create(); 114 return DitherEffect::Create();
115 } 115 }
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698