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

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

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // and both circles are touching on an edge 200 // and both circles are touching on an edge
201 SkPoint diff = center2 - center1; 201 SkPoint diff = center2 - center1;
202 SkScalar diffLen = diff.length(); 202 SkScalar diffLen = diff.length();
203 radius2 = radius1 + diffLen; 203 radius2 = radius1 + diffLen;
204 204
205 SkColor colors[kMaxRandomGradientColors]; 205 SkColor colors[kMaxRandomGradientColors];
206 SkScalar stopsArray[kMaxRandomGradientColors]; 206 SkScalar stopsArray[kMaxRandomGradientColors];
207 SkScalar* stops = stopsArray; 207 SkScalar* stops = stopsArray;
208 SkShader::TileMode tm; 208 SkShader::TileMode tm;
209 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 209 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
210 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 210 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
211 center 2, radius2, 211 colors, stops, colorCoun t, tm);
212 colors , stops, colorCount,
213 tm));
214 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 212 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
215 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 213 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality);
216 GrAlwaysAssert(fp); 214 GrAlwaysAssert(fp);
217 return fp; 215 return fp;
218 } 216 }
219 217
220 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) 218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
221 : fVSVaryingName(nullptr) 219 : fVSVaryingName(nullptr)
222 , fFSVaryingName(nullptr) 220 , fFSVaryingName(nullptr)
223 , fCachedRadius(-SK_ScalarMax) 221 , fCachedRadius(-SK_ScalarMax)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 SkPoint diff = center2 - center1; 475 SkPoint diff = center2 - center1;
478 SkScalar diffLen = diff.length(); 476 SkScalar diffLen = diff.length();
479 // Below makes sure that the focal point is not contained within circle two 477 // Below makes sure that the focal point is not contained within circle two
480 radius2 = d->fRandom->nextRangeF(0.f, diffLen); 478 radius2 = d->fRandom->nextRangeF(0.f, diffLen);
481 479
482 SkColor colors[kMaxRandomGradientColors]; 480 SkColor colors[kMaxRandomGradientColors];
483 SkScalar stopsArray[kMaxRandomGradientColors]; 481 SkScalar stopsArray[kMaxRandomGradientColors];
484 SkScalar* stops = stopsArray; 482 SkScalar* stops = stopsArray;
485 SkShader::TileMode tm; 483 SkShader::TileMode tm;
486 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 484 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
487 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 485 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
488 center 2, radius2, 486 colors, stops, colorCoun t, tm);
489 colors , stops, colorCount,
490 tm));
491 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 487 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
492 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 488 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality);
493 GrAlwaysAssert(fp); 489 GrAlwaysAssert(fp);
494 return fp; 490 return fp;
495 } 491 }
496 492
497 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor) 493 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor)
498 : fVSVaryingName(nullptr) 494 : fVSVaryingName(nullptr)
499 , fFSVaryingName(nullptr) 495 , fFSVaryingName(nullptr)
500 , fCachedFocal(SK_ScalarMax) { 496 , fCachedFocal(SK_ScalarMax) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 SkScalar diffLen = diff.length(); 681 SkScalar diffLen = diff.length();
686 radius2 = diffLen + increase; 682 radius2 = diffLen + increase;
687 // If the circles are identical the factory will give us an empty shader . 683 // If the circles are identical the factory will give us an empty shader .
688 } while (radius1 == radius2 && center1 == center2); 684 } while (radius1 == radius2 && center1 == center2);
689 685
690 SkColor colors[kMaxRandomGradientColors]; 686 SkColor colors[kMaxRandomGradientColors];
691 SkScalar stopsArray[kMaxRandomGradientColors]; 687 SkScalar stopsArray[kMaxRandomGradientColors];
692 SkScalar* stops = stopsArray; 688 SkScalar* stops = stopsArray;
693 SkShader::TileMode tm; 689 SkShader::TileMode tm;
694 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 690 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
695 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 691 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
696 center 2, radius2, 692 colors, stops, colorCoun t, tm);
697 colors , stops, colorCount,
698 tm));
699 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 693 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
700 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 694 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality);
701 GrAlwaysAssert(fp); 695 GrAlwaysAssert(fp);
702 return fp; 696 return fp;
703 } 697 }
704 698
705 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) 699 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
706 : fVSVaryingName(nullptr) 700 : fVSVaryingName(nullptr)
707 , fFSVaryingName(nullptr) 701 , fFSVaryingName(nullptr)
708 , fCachedFocal(SK_ScalarMax) {} 702 , fCachedFocal(SK_ScalarMax) {}
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 SkScalar diffLen = diff.length(); 927 SkScalar diffLen = diff.length();
934 radius2 = radius1 + diffLen + increase; 928 radius2 = radius1 + diffLen + increase;
935 // If the circles are identical the factory will give us an empty shader . 929 // If the circles are identical the factory will give us an empty shader .
936 } while (radius1 == radius2 && center1 == center2); 930 } while (radius1 == radius2 && center1 == center2);
937 931
938 SkColor colors[kMaxRandomGradientColors]; 932 SkColor colors[kMaxRandomGradientColors];
939 SkScalar stopsArray[kMaxRandomGradientColors]; 933 SkScalar stopsArray[kMaxRandomGradientColors];
940 SkScalar* stops = stopsArray; 934 SkScalar* stops = stopsArray;
941 SkShader::TileMode tm; 935 SkShader::TileMode tm;
942 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 936 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
943 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 937 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
944 center 2, radius2, 938 colors, stops, colorCoun t, tm);
945 colors , stops, colorCount,
946 tm));
947 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 939 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
948 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 940 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality);
949 GrAlwaysAssert(fp); 941 GrAlwaysAssert(fp);
950 return fp; 942 return fp;
951 } 943 }
952 944
953 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor) 945 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor)
954 : fVSVaryingName(nullptr) 946 : fVSVaryingName(nullptr)
955 , fFSVaryingName(nullptr) 947 , fFSVaryingName(nullptr)
956 , fCachedCenterX(SK_ScalarMax) 948 , fCachedCenterX(SK_ScalarMax)
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 diffLen = diff.length(); 1158 diffLen = diff.length();
1167 // Below makes sure that circle one is not contained within circle two 1159 // Below makes sure that circle one is not contained within circle two
1168 // and have radius2 >= radius to match sorting on cpu side 1160 // and have radius2 >= radius to match sorting on cpu side
1169 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); 1161 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen);
1170 1162
1171 SkColor colors[kMaxRandomGradientColors]; 1163 SkColor colors[kMaxRandomGradientColors];
1172 SkScalar stopsArray[kMaxRandomGradientColors]; 1164 SkScalar stopsArray[kMaxRandomGradientColors];
1173 SkScalar* stops = stopsArray; 1165 SkScalar* stops = stopsArray;
1174 SkShader::TileMode tm; 1166 SkShader::TileMode tm;
1175 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 1167 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
1176 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 1168 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center 2, radius2,
1177 center 2, radius2, 1169 colors, stops, colorCoun t, tm);
1178 colors , stops, colorCount,
1179 tm));
1180 const GrFragmentProcessor* fp = shader->asFragmentProcessor( 1170 const GrFragmentProcessor* fp = shader->asFragmentProcessor(
1181 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality) ; 1171 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality) ;
1182 GrAlwaysAssert(fp); 1172 GrAlwaysAssert(fp);
1183 return fp; 1173 return fp;
1184 } 1174 }
1185 1175
1186 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor) 1176 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor)
1187 : fVSVaryingName(nullptr) 1177 : fVSVaryingName(nullptr)
1188 , fFSVaryingName(nullptr) 1178 , fFSVaryingName(nullptr)
1189 , fCachedCenterX(SK_ScalarMax) 1179 , fCachedCenterX(SK_ScalarMax)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1323 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o);
1334 } else if (type == kEdge_ConicalType) { 1324 } else if (type == kEdge_ConicalType) {
1335 set_matrix_edge_conical(shader, &matrix); 1325 set_matrix_edge_conical(shader, &matrix);
1336 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1326 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm);
1337 } else { 1327 } else {
1338 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1328 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo);
1339 } 1329 }
1340 } 1330 }
1341 1331
1342 #endif 1332 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698