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

Side by Side Diff: src/gpu/effects/GrDashingEffect.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
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/effects/GrDisableColorXP.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 "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NU LL, &fColorUniform); 884 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NU LL, &fColorUniform);
885 885
886 // Setup position 886 // Setup position
887 this->setupPosition(pb, gpArgs, dce.inPosition()->fName, dce.viewMatrix()); 887 this->setupPosition(pb, gpArgs, dce.inPosition()->fName, dce.viewMatrix());
888 888
889 // emit transforms 889 // emit transforms
890 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dce.inPosition()->fName , dce.localMatrix(), 890 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dce.inPosition()->fName , dce.localMatrix(),
891 args.fTransformsIn, args.fTransformsOut); 891 args.fTransformsIn, args.fTransformsOut);
892 892
893 // transforms all points so that we can compare them to our test circle 893 // transforms all points so that we can compare them to our test circle
894 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 894 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
895 fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;", 895 fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
896 dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn (), 896 dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn (),
897 dashParams.fsIn()); 897 dashParams.fsIn());
898 fsBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashPa rams.fsIn()); 898 fsBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashPa rams.fsIn());
899 fsBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn() ); 899 fsBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn() );
900 fsBuilder->codeAppend("float dist = length(center - fragPosShifted);"); 900 fsBuilder->codeAppend("float dist = length(center - fragPosShifted);");
901 if (dce.aaMode() != kBW_DashAAMode) { 901 if (dce.aaMode() != kBW_DashAAMode) {
902 fsBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn()) ; 902 fsBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn()) ;
903 fsBuilder->codeAppend("diff = 1.0 - diff;"); 903 fsBuilder->codeAppend("diff = 1.0 - diff;");
904 fsBuilder->codeAppend("float alpha = clamp(diff, 0.0, 1.0);"); 904 fsBuilder->codeAppend("float alpha = clamp(diff, 0.0, 1.0);");
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NU LL, &fColorUniform); 1127 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor, NU LL, &fColorUniform);
1128 1128
1129 // Setup position 1129 // Setup position
1130 this->setupPosition(pb, gpArgs, de.inPosition()->fName, de.viewMatrix()); 1130 this->setupPosition(pb, gpArgs, de.inPosition()->fName, de.viewMatrix());
1131 1131
1132 // emit transforms 1132 // emit transforms
1133 this->emitTransforms(args.fPB, gpArgs->fPositionVar, de.inPosition()->fName, de.localMatrix(), 1133 this->emitTransforms(args.fPB, gpArgs->fPositionVar, de.inPosition()->fName, de.localMatrix(),
1134 args.fTransformsIn, args.fTransformsOut); 1134 args.fTransformsIn, args.fTransformsOut);
1135 1135
1136 // transforms all points so that we can compare them to our test rect 1136 // transforms all points so that we can compare them to our test rect
1137 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 1137 GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
1138 fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;", 1138 fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
1139 inDashParams.fsIn(), inDashParams.fsIn(), inDashParam s.fsIn(), 1139 inDashParams.fsIn(), inDashParams.fsIn(), inDashParam s.fsIn(),
1140 inDashParams.fsIn()); 1140 inDashParams.fsIn());
1141 fsBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDash Params.fsIn()); 1141 fsBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDash Params.fsIn());
1142 if (de.aaMode() == kEdgeAA_DashAAMode) { 1142 if (de.aaMode() == kEdgeAA_DashAAMode) {
1143 // The amount of coverage removed in x and y by the edges is computed as a pair of negative 1143 // The amount of coverage removed in x and y by the edges is computed as a pair of negative
1144 // numbers, xSub and ySub. 1144 // numbers, xSub and ySub.
1145 fsBuilder->codeAppend("float xSub, ySub;"); 1145 fsBuilder->codeAppend("float xSub, ySub;");
1146 fsBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRe ctParams.fsIn()); 1146 fsBuilder->codeAppendf("xSub = min(fragPosShifted.x - %s.x, 0.0);", inRe ctParams.fsIn());
1147 fsBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inR ectParams.fsIn()); 1147 fsBuilder->codeAppendf("xSub += min(%s.z - fragPosShifted.x, 0.0);", inR ectParams.fsIn());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 switch (cap) { 1273 switch (cap) {
1274 case kRound_DashCap: 1274 case kRound_DashCap:
1275 return DashingCircleEffect::Create(color, dashAAMode, localMatrix); 1275 return DashingCircleEffect::Create(color, dashAAMode, localMatrix);
1276 case kNonRound_DashCap: 1276 case kNonRound_DashCap:
1277 return DashingLineEffect::Create(color, dashAAMode, localMatrix); 1277 return DashingLineEffect::Create(color, dashAAMode, localMatrix);
1278 default: 1278 default:
1279 SkFAIL("Unexpected dashed cap."); 1279 SkFAIL("Unexpected dashed cap.");
1280 } 1280 }
1281 return NULL; 1281 return NULL;
1282 } 1282 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/effects/GrDisableColorXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698