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

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

Issue 788733003: Make addUniform take a precision (Closed) Base URL: https://skia.googlesource.com/skia.git@move_prec
Patch Set: rebase Created 6 years 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/effects/GrMatrixConvolutionEffect.cpp ('k') | src/gpu/effects/GrRRectEffect.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 "GrOvalEffect.h" 8 #include "GrOvalEffect.h"
9 9
10 #include "GrFragmentProcessor.h" 10 #include "GrFragmentProcessor.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const GrFragmentProcessor& fp, 124 const GrFragmentProcessor& fp,
125 const char* outputColor, 125 const char* outputColor,
126 const char* inputColor, 126 const char* inputColor,
127 const TransformedCoordsArray&, 127 const TransformedCoordsArray&,
128 const TextureSamplerArray& samplers) { 128 const TextureSamplerArray& samplers) {
129 const CircleEffect& ce = fp.cast<CircleEffect>(); 129 const CircleEffect& ce = fp.cast<CircleEffect>();
130 const char *circleName; 130 const char *circleName;
131 // The circle uniform is (center.x, center.y, radius + 0.5) for regular fill s and 131 // The circle uniform is (center.x, center.y, radius + 0.5) for regular fill s and
132 // (... ,radius - 0.5) for inverse fills. 132 // (... ,radius - 0.5) for inverse fills.
133 fCircleUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit y, 133 fCircleUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit y,
134 kVec3f_GrSLType, 134 kVec3f_GrSLType, kDefault_GrSLPrecision ,
135 "circle", 135 "circle",
136 &circleName); 136 &circleName);
137 137
138 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 138 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
139 const char* fragmentPos = fsBuilder->fragmentPosition(); 139 const char* fragmentPos = fsBuilder->fragmentPosition();
140 140
141 SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType()); 141 SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
142 if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) { 142 if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) {
143 fsBuilder->codeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n", 143 fsBuilder->codeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n",
144 circleName, fragmentPos, circleName); 144 circleName, fragmentPos, circleName);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void GLEllipseEffect::emitCode(GrGLFPBuilder* builder, 301 void GLEllipseEffect::emitCode(GrGLFPBuilder* builder,
302 const GrFragmentProcessor& fp, 302 const GrFragmentProcessor& fp,
303 const char* outputColor, 303 const char* outputColor,
304 const char* inputColor, 304 const char* inputColor,
305 const TransformedCoordsArray&, 305 const TransformedCoordsArray&,
306 const TextureSamplerArray& samplers) { 306 const TextureSamplerArray& samplers) {
307 const EllipseEffect& ee = fp.cast<EllipseEffect>(); 307 const EllipseEffect& ee = fp.cast<EllipseEffect>();
308 const char *ellipseName; 308 const char *ellipseName;
309 // The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2) 309 // The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
310 fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty, 310 fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty,
311 kVec4f_GrSLType, 311 kVec4f_GrSLType, kDefault_GrSLPrecision ,
312 "ellipse", 312 "ellipse",
313 &ellipseName); 313 &ellipseName);
314 314
315 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 315 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
316 const char* fragmentPos = fsBuilder->fragmentPosition(); 316 const char* fragmentPos = fsBuilder->fragmentPosition();
317 317
318 // d is the offset to the ellipse center 318 // d is the offset to the ellipse center
319 fsBuilder->codeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name); 319 fsBuilder->codeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name);
320 fsBuilder->codeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName); 320 fsBuilder->codeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName);
321 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1. 321 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 w /= 2; 387 w /= 2;
388 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w); 388 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w);
389 } else { 389 } else {
390 w /= 2; 390 w /= 2;
391 h /= 2; 391 h /= 2;
392 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h); 392 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h);
393 } 393 }
394 394
395 return NULL; 395 return NULL;
396 } 396 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrMatrixConvolutionEffect.cpp ('k') | src/gpu/effects/GrRRectEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698