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

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp

Issue 2175563003: Bundle SkShader::asFragmentProcessor arguments in a struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix indentation to be less arbitrary Created 4 years, 4 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/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | src/gpu/SkGr.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 "SkTwoPointConicalGradient_gpu.h" 8 #include "SkTwoPointConicalGradient_gpu.h"
9 9
10 #include "SkTwoPointConicalGradient.h" 10 #include "SkTwoPointConicalGradient.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 SkScalar diffLen = diff.length(); 201 SkScalar diffLen = diff.length();
202 radius2 = radius1 + diffLen; 202 radius2 = radius1 + diffLen;
203 203
204 SkColor colors[kMaxRandomGradientColors]; 204 SkColor colors[kMaxRandomGradientColors];
205 SkScalar stopsArray[kMaxRandomGradientColors]; 205 SkScalar stopsArray[kMaxRandomGradientColors];
206 SkScalar* stops = stopsArray; 206 SkScalar* stops = stopsArray;
207 SkShader::TileMode tm; 207 SkShader::TileMode tm;
208 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 208 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
209 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2, 209 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
210 colors, stops, colorCoun t, tm); 210 colors, stops, colorCoun t, tm);
211 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext, 211 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
212 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 212 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
213 SkSourceGammaTreatment::kRespect); 213 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
214 GrAlwaysAssert(fp); 214 GrAlwaysAssert(fp);
215 return fp; 215 return fp;
216 } 216 }
217 217
218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) 218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
219 : fVSVaryingName(nullptr) 219 : fVSVaryingName(nullptr)
220 , fFSVaryingName(nullptr) 220 , fFSVaryingName(nullptr)
221 , fCachedRadius(-SK_ScalarMax) 221 , fCachedRadius(-SK_ScalarMax)
222 , fCachedDiffRadius(-SK_ScalarMax) {} 222 , fCachedDiffRadius(-SK_ScalarMax) {}
223 223
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // Below makes sure that the focal point is not contained within circle two 478 // Below makes sure that the focal point is not contained within circle two
479 radius2 = d->fRandom->nextRangeF(0.f, diffLen); 479 radius2 = d->fRandom->nextRangeF(0.f, diffLen);
480 480
481 SkColor colors[kMaxRandomGradientColors]; 481 SkColor colors[kMaxRandomGradientColors];
482 SkScalar stopsArray[kMaxRandomGradientColors]; 482 SkScalar stopsArray[kMaxRandomGradientColors];
483 SkScalar* stops = stopsArray; 483 SkScalar* stops = stopsArray;
484 SkShader::TileMode tm; 484 SkShader::TileMode tm;
485 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 485 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
486 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2, 486 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
487 colors, stops, colorCoun t, tm); 487 colors, stops, colorCoun t, tm);
488 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext, 488 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
489 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 489 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
490 SkSourceGammaTreatment::kRespect); 490 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
491 GrAlwaysAssert(fp); 491 GrAlwaysAssert(fp);
492 return fp; 492 return fp;
493 } 493 }
494 494
495 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor) 495 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor)
496 : fVSVaryingName(nullptr) 496 : fVSVaryingName(nullptr)
497 , fFSVaryingName(nullptr) 497 , fFSVaryingName(nullptr)
498 , fCachedFocal(SK_ScalarMax) { 498 , fCachedFocal(SK_ScalarMax) {
499 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>(); 499 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>();
500 fIsFlipped = data.isFlipped(); 500 fIsFlipped = data.isFlipped();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 // If the circles are identical the factory will give us an empty shader . 686 // If the circles are identical the factory will give us an empty shader .
687 } while (radius1 == radius2 && center1 == center2); 687 } while (radius1 == radius2 && center1 == center2);
688 688
689 SkColor colors[kMaxRandomGradientColors]; 689 SkColor colors[kMaxRandomGradientColors];
690 SkScalar stopsArray[kMaxRandomGradientColors]; 690 SkScalar stopsArray[kMaxRandomGradientColors];
691 SkScalar* stops = stopsArray; 691 SkScalar* stops = stopsArray;
692 SkShader::TileMode tm; 692 SkShader::TileMode tm;
693 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 693 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
694 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2, 694 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
695 colors, stops, colorCoun t, tm); 695 colors, stops, colorCoun t, tm);
696 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext, 696 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
697 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 697 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
698 SkSourceGammaTreatment::kRespect); 698 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
699 GrAlwaysAssert(fp); 699 GrAlwaysAssert(fp);
700 return fp; 700 return fp;
701 } 701 }
702 702
703 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) 703 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
704 : fVSVaryingName(nullptr) 704 : fVSVaryingName(nullptr)
705 , fFSVaryingName(nullptr) 705 , fFSVaryingName(nullptr)
706 , fCachedFocal(SK_ScalarMax) {} 706 , fCachedFocal(SK_ScalarMax) {}
707 707
708 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { 708 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // If the circles are identical the factory will give us an empty shader . 934 // If the circles are identical the factory will give us an empty shader .
935 } while (radius1 == radius2 && center1 == center2); 935 } while (radius1 == radius2 && center1 == center2);
936 936
937 SkColor colors[kMaxRandomGradientColors]; 937 SkColor colors[kMaxRandomGradientColors];
938 SkScalar stopsArray[kMaxRandomGradientColors]; 938 SkScalar stopsArray[kMaxRandomGradientColors];
939 SkScalar* stops = stopsArray; 939 SkScalar* stops = stopsArray;
940 SkShader::TileMode tm; 940 SkShader::TileMode tm;
941 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 941 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
942 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2, 942 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
943 colors, stops, colorCoun t, tm); 943 colors, stops, colorCoun t, tm);
944 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext, 944 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
945 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 945 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
946 SkSourceGammaTreatment::kRespect); 946 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
947 GrAlwaysAssert(fp); 947 GrAlwaysAssert(fp);
948 return fp; 948 return fp;
949 } 949 }
950 950
951 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor) 951 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor)
952 : fVSVaryingName(nullptr) 952 : fVSVaryingName(nullptr)
953 , fFSVaryingName(nullptr) 953 , fFSVaryingName(nullptr)
954 , fCachedCenterX(SK_ScalarMax) 954 , fCachedCenterX(SK_ScalarMax)
955 , fCachedCenterY(SK_ScalarMax) 955 , fCachedCenterY(SK_ScalarMax)
956 , fCachedA(SK_ScalarMax) 956 , fCachedA(SK_ScalarMax)
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 // and have radius2 >= radius to match sorting on cpu side 1167 // and have radius2 >= radius to match sorting on cpu side
1168 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); 1168 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen);
1169 1169
1170 SkColor colors[kMaxRandomGradientColors]; 1170 SkColor colors[kMaxRandomGradientColors];
1171 SkScalar stopsArray[kMaxRandomGradientColors]; 1171 SkScalar stopsArray[kMaxRandomGradientColors];
1172 SkScalar* stops = stopsArray; 1172 SkScalar* stops = stopsArray;
1173 SkShader::TileMode tm; 1173 SkShader::TileMode tm;
1174 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 1174 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
1175 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2, 1175 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
1176 colors, stops, colorCoun t, tm); 1176 colors, stops, colorCoun t, tm);
1177 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor( 1177 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
1178 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 1178 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
1179 SkSourceGammaTreatment::kRespect); 1179 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
1180 GrAlwaysAssert(fp); 1180 GrAlwaysAssert(fp);
1181 return fp; 1181 return fp;
1182 } 1182 }
1183 1183
1184 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor) 1184 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor)
1185 : fVSVaryingName(nullptr) 1185 : fVSVaryingName(nullptr)
1186 , fFSVaryingName(nullptr) 1186 , fFSVaryingName(nullptr)
1187 , fCachedCenterX(SK_ScalarMax) 1187 , fCachedCenterX(SK_ScalarMax)
1188 , fCachedCenterY(SK_ScalarMax) 1188 , fCachedCenterY(SK_ScalarMax)
1189 , fCachedA(SK_ScalarMax) 1189 , fCachedA(SK_ScalarMax)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info) ; 1331 return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info) ;
1332 } else if (type == kEdge_ConicalType) { 1332 } else if (type == kEdge_ConicalType) {
1333 set_matrix_edge_conical(shader, &matrix); 1333 set_matrix_edge_conical(shader, &matrix);
1334 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm); 1334 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm);
1335 } else { 1335 } else {
1336 return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info ); 1336 return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info );
1337 } 1337 }
1338 } 1338 }
1339 1339
1340 #endif 1340 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698