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

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkTwoPointConicalGradient_gpu.h" 9 #include "SkTwoPointConicalGradient_gpu.h"
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SkString p2; // difference in radii (r1 - r0) 247 SkString p2; // difference in radii (r1 - r0)
248 248
249 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); 249 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
250 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); 250 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
251 builder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2); 251 builder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
252 252
253 // We interpolate the linear component in coords[1]. 253 // We interpolate the linear component in coords[1].
254 SkASSERT(coords[0].getType() == coords[1].getType()); 254 SkASSERT(coords[0].getType() == coords[1].getType());
255 const char* coords2D; 255 const char* coords2D;
256 SkString bVar; 256 SkString bVar;
257 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 257 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
258 if (kVec3f_GrSLType == coords[0].getType()) { 258 if (kVec3f_GrSLType == coords[0].getType()) {
259 fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n", 259 fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
260 coords[0].c_str(), coords[0].c_str(), coords[1].c _str(), 260 coords[0].c_str(), coords[0].c_str(), coords[1].c _str(),
261 coords[1].c_str()); 261 coords[1].c_str());
262 coords2D = "interpolants.xy"; 262 coords2D = "interpolants.xy";
263 bVar = "interpolants.z"; 263 bVar = "interpolants.z";
264 } else { 264 } else {
265 coords2D = coords[0].c_str(); 265 coords2D = coords[0].c_str();
266 bVar.printf("%s.x", coords[1].c_str()); 266 bVar.printf("%s.x", coords[1].c_str());
267 } 267 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 kFloat_GrSLType, kDefault_GrSLPrecision , 529 kFloat_GrSLType, kDefault_GrSLPrecision ,
530 "Conical2FSParams", 2); 530 "Conical2FSParams", 2);
531 SkString tName("t"); 531 SkString tName("t");
532 SkString p0; // focalX 532 SkString p0; // focalX
533 SkString p1; // 1 - focalX * focalX 533 SkString p1; // 1 - focalX * focalX
534 534
535 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); 535 builder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
536 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); 536 builder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
537 537
538 // if we have a vec3 from being in perspective, convert it to a vec2 first 538 // if we have a vec3 from being in perspective, convert it to a vec2 first
539 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 539 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
540 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0); 540 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0);
541 const char* coords2D = coords2DString.c_str(); 541 const char* coords2D = coords2DString.c_str();
542 542
543 // t = p.x * focal.x +/- sqrt(p.x^2 + (1 - focal.x^2) * p.y^2) 543 // t = p.x * focal.x +/- sqrt(p.x^2 + (1 - focal.x^2) * p.y^2)
544 544
545 // output will default to transparent black (we simply won't write anything 545 // output will default to transparent black (we simply won't write anything
546 // else to it if invalid, instead of discarding or returning prematurely) 546 // else to it if invalid, instead of discarding or returning prematurely)
547 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", outputColor); 547 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", outputColor);
548 548
549 fsBuilder->codeAppendf("\tfloat xs = %s.x * %s.x;\n", coords2D, coords2D); 549 fsBuilder->codeAppendf("\tfloat xs = %s.x * %s.x;\n", coords2D, coords2D);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 fFocalUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 745 fFocalUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
746 kFloat_GrSLType, kDefault_GrSLPrecision, 746 kFloat_GrSLType, kDefault_GrSLPrecision,
747 "Conical2FSParams"); 747 "Conical2FSParams");
748 SkString tName("t"); 748 SkString tName("t");
749 749
750 // this is the distance along x-axis from the end center to focal point in 750 // this is the distance along x-axis from the end center to focal point in
751 // transformed coordinates 751 // transformed coordinates
752 GrGLShaderVar focal = builder->getUniformVariable(fFocalUni); 752 GrGLShaderVar focal = builder->getUniformVariable(fFocalUni);
753 753
754 // if we have a vec3 from being in perspective, convert it to a vec2 first 754 // if we have a vec3 from being in perspective, convert it to a vec2 first
755 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 755 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
756 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0); 756 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0);
757 const char* coords2D = coords2DString.c_str(); 757 const char* coords2D = coords2DString.c_str();
758 758
759 // t = p.x * focalX + length(p) 759 // t = p.x * focalX + length(p)
760 fsBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_st r(), 760 fsBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_st r(),
761 coords2D, focal.c_str(), coords2D); 761 coords2D, focal.c_str(), coords2D);
762 762
763 this->emitColor(builder, ge, tName.c_str(), outputColor, inputColor, sampler s); 763 this->emitColor(builder, ge, tName.c_str(), outputColor, inputColor, sampler s);
764 } 764 }
765 765
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 "Conical2FSParams"); 1009 "Conical2FSParams");
1010 SkString tName("t"); 1010 SkString tName("t");
1011 1011
1012 GrGLShaderVar center = builder->getUniformVariable(fCenterUni); 1012 GrGLShaderVar center = builder->getUniformVariable(fCenterUni);
1013 // params.x = A 1013 // params.x = A
1014 // params.y = B 1014 // params.y = B
1015 // params.z = C 1015 // params.z = C
1016 GrGLShaderVar params = builder->getUniformVariable(fParamUni); 1016 GrGLShaderVar params = builder->getUniformVariable(fParamUni);
1017 1017
1018 // if we have a vec3 from being in perspective, convert it to a vec2 first 1018 // if we have a vec3 from being in perspective, convert it to a vec2 first
1019 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 1019 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
1020 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0); 1020 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0);
1021 const char* coords2D = coords2DString.c_str(); 1021 const char* coords2D = coords2DString.c_str();
1022 1022
1023 // p = coords2D 1023 // p = coords2D
1024 // e = center end 1024 // e = center end
1025 // r = radius end 1025 // r = radius end
1026 // A = dot(e, e) - r^2 + 2 * r - 1 1026 // A = dot(e, e) - r^2 + 2 * r - 1
1027 // B = (r -1) / A 1027 // B = (r -1) / A
1028 // C = 1 / A 1028 // C = 1 / A
1029 // d = dot(e, p) + B 1029 // d = dot(e, p) + B
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 "Conical2FSParams"); 1255 "Conical2FSParams");
1256 SkString tName("t"); 1256 SkString tName("t");
1257 1257
1258 GrGLShaderVar center = builder->getUniformVariable(fCenterUni); 1258 GrGLShaderVar center = builder->getUniformVariable(fCenterUni);
1259 // params.x = A 1259 // params.x = A
1260 // params.y = B 1260 // params.y = B
1261 // params.z = C 1261 // params.z = C
1262 GrGLShaderVar params = builder->getUniformVariable(fParamUni); 1262 GrGLShaderVar params = builder->getUniformVariable(fParamUni);
1263 1263
1264 // if we have a vec3 from being in perspective, convert it to a vec2 first 1264 // if we have a vec3 from being in perspective, convert it to a vec2 first
1265 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 1265 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
1266 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0); 1266 SkString coords2DString = fsBuilder->ensureFSCoords2D(coords, 0);
1267 const char* coords2D = coords2DString.c_str(); 1267 const char* coords2D = coords2DString.c_str();
1268 1268
1269 // output will default to transparent black (we simply won't write anything 1269 // output will default to transparent black (we simply won't write anything
1270 // else to it if invalid, instead of discarding or returning prematurely) 1270 // else to it if invalid, instead of discarding or returning prematurely)
1271 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", outputColor); 1271 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", outputColor);
1272 1272
1273 // p = coords2D 1273 // p = coords2D
1274 // e = center end 1274 // e = center end
1275 // r = radius end 1275 // r = radius end
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1372 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o);
1373 } else if (type == kEdge_ConicalType) { 1373 } else if (type == kEdge_ConicalType) {
1374 set_matrix_edge_conical(shader, &matrix); 1374 set_matrix_edge_conical(shader, &matrix);
1375 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1375 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
1376 } else { 1376 } else {
1377 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1377 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo);
1378 } 1378 }
1379 } 1379 }
1380 1380
1381 #endif 1381 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkTwoPointRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698