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

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

Issue 1110033004: Make XPFragmentBuilder only Builder with access to DstCopy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 1 / (radius + 0. 5)) for regular 131 // The circle uniform is (center.x, center.y, radius + 0.5, 1 / (radius + 0. 5)) for regular
132 // fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills. 132 // fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills.
133 fCircleUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit y, 133 fCircleUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit y,
134 kVec4f_GrSLType, kDefault_GrSLPrecision , 134 kVec4f_GrSLType, kDefault_GrSLPrecision ,
135 "circle", 135 "circle",
136 &circleName); 136 &circleName);
137 137
138 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 138 GrGLFragmentBuilder* 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 // TODO: Right now the distance to circle caclulation is performed in a spac e normalized to the 142 // TODO: Right now the distance to circle caclulation is performed in a spac e normalized to the
143 // radius and then denormalized. This is to prevent overflow on devices that have a "real" 143 // radius and then denormalized. This is to prevent overflow on devices that have a "real"
144 // mediump. It'd be nice to only to this on mediump devices but we currently don't have the 144 // mediump. It'd be nice to only to this on mediump devices but we currently don't have the
145 // caps here. 145 // caps here.
146 if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) { 146 if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) {
147 fsBuilder->codeAppendf("\t\tfloat d = (length((%s.xy - %s.xy) * %s.w) - 1.0) * %s.z;\n", 147 fsBuilder->codeAppendf("\t\tfloat d = (length((%s.xy - %s.xy) * %s.w) - 1.0) * %s.z;\n",
148 circleName, fragmentPos, circleName, circleName) ; 148 circleName, fragmentPos, circleName, circleName) ;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 const TransformedCoordsArray&, 310 const TransformedCoordsArray&,
311 const TextureSamplerArray& samplers) { 311 const TextureSamplerArray& samplers) {
312 const EllipseEffect& ee = fp.cast<EllipseEffect>(); 312 const EllipseEffect& ee = fp.cast<EllipseEffect>();
313 const char *ellipseName; 313 const char *ellipseName;
314 // The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2) 314 // The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
315 fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty, 315 fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty,
316 kVec4f_GrSLType, kDefault_GrSLPrecision , 316 kVec4f_GrSLType, kDefault_GrSLPrecision ,
317 "ellipse", 317 "ellipse",
318 &ellipseName); 318 &ellipseName);
319 319
320 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 320 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
321 const char* fragmentPos = fsBuilder->fragmentPosition(); 321 const char* fragmentPos = fsBuilder->fragmentPosition();
322 322
323 // d is the offset to the ellipse center 323 // d is the offset to the ellipse center
324 fsBuilder->codeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name); 324 fsBuilder->codeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name);
325 fsBuilder->codeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName); 325 fsBuilder->codeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName);
326 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1. 326 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
327 fsBuilder->codeAppend("\t\tfloat implicit = dot(Z, d) - 1.0;\n"); 327 fsBuilder->codeAppend("\t\tfloat implicit = dot(Z, d) - 1.0;\n");
328 // grad_dot is the squared length of the gradient of the implicit. 328 // grad_dot is the squared length of the gradient of the implicit.
329 fsBuilder->codeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n"); 329 fsBuilder->codeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n");
330 // avoid calling inversesqrt on zero. 330 // avoid calling inversesqrt on zero.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 w /= 2; 392 w /= 2;
393 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w); 393 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w);
394 } else { 394 } else {
395 w /= 2; 395 w /= 2;
396 h /= 2; 396 h /= 2;
397 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h); 397 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h);
398 } 398 }
399 399
400 return NULL; 400 return NULL;
401 } 401 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrMatrixConvolutionEffect.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698