OLD | NEW |
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 SkShader::TileMode tm; | 206 SkShader::TileMode tm; |
207 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 207 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
208 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 208 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
209 center
2, radius2, | 209 center
2, radius2, |
210 colors
, stops, colorCount, | 210 colors
, stops, colorCount, |
211 tm)); | 211 tm)); |
212 SkPaint paint; | 212 SkPaint paint; |
213 GrFragmentProcessor* fp; | 213 GrFragmentProcessor* fp; |
214 GrColor paintColor; | 214 GrColor paintColor; |
215 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 215 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
216 GrTest::TestMatrix(d->fRandom), N
ULL, | 216 GrTest::TestMatrix(d->fRandom), n
ullptr, |
217 &paintColor, d->fProcDataManager,
&fp)); | 217 &paintColor, d->fProcDataManager,
&fp)); |
218 return fp; | 218 return fp; |
219 } | 219 } |
220 | 220 |
221 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) | 221 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) |
222 : fVSVaryingName(NULL) | 222 : fVSVaryingName(nullptr) |
223 , fFSVaryingName(NULL) | 223 , fFSVaryingName(nullptr) |
224 , fCachedRadius(-SK_ScalarMax) | 224 , fCachedRadius(-SK_ScalarMax) |
225 , fCachedDiffRadius(-SK_ScalarMax) {} | 225 , fCachedDiffRadius(-SK_ScalarMax) {} |
226 | 226 |
227 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) { | 227 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) { |
228 const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>(); | 228 const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>(); |
229 this->emitUniforms(args.fBuilder, ge); | 229 this->emitUniforms(args.fBuilder, ge); |
230 fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Vis
ibility, | 230 fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Vis
ibility, |
231 kFloat_GrSLType, kDefault_GrSLPrecision
, | 231 kFloat_GrSLType, kDefault_GrSLPrecision
, |
232 "Conical2FSParams", 3); | 232 "Conical2FSParams", 3); |
233 | 233 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 486 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
487 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 487 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
488 center
2, radius2, | 488 center
2, radius2, |
489 colors
, stops, colorCount, | 489 colors
, stops, colorCount, |
490 tm)); | 490 tm)); |
491 SkPaint paint; | 491 SkPaint paint; |
492 GrFragmentProcessor* effect; | 492 GrFragmentProcessor* effect; |
493 GrColor paintColor; | 493 GrColor paintColor; |
494 GrPaint grPaint; | 494 GrPaint grPaint; |
495 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 495 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
496 GrTest::TestMatrix(d->fRandom), N
ULL, | 496 GrTest::TestMatrix(d->fRandom), n
ullptr, |
497 &paintColor, d->fProcDataManager, | 497 &paintColor, d->fProcDataManager, |
498 &effect)); | 498 &effect)); |
499 return effect; | 499 return effect; |
500 } | 500 } |
501 | 501 |
502 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) | 502 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) |
503 : fVSVaryingName(NULL) | 503 : fVSVaryingName(nullptr) |
504 , fFSVaryingName(NULL) | 504 , fFSVaryingName(nullptr) |
505 , fCachedFocal(SK_ScalarMax) { | 505 , fCachedFocal(SK_ScalarMax) { |
506 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 506 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
507 fIsFlipped = data.isFlipped(); | 507 fIsFlipped = data.isFlipped(); |
508 } | 508 } |
509 | 509 |
510 void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) { | 510 void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) { |
511 const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConica
lEffect>(); | 511 const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConica
lEffect>(); |
512 this->emitUniforms(args.fBuilder, ge); | 512 this->emitUniforms(args.fBuilder, ge); |
513 fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Vis
ibility, | 513 fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Vis
ibility, |
514 kFloat_GrSLType, kDefault_GrSLPrecision
, | 514 kFloat_GrSLType, kDefault_GrSLPrecision
, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 SkShader::TileMode tm; | 698 SkShader::TileMode tm; |
699 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 699 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
700 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 700 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
701 center
2, radius2, | 701 center
2, radius2, |
702 colors
, stops, colorCount, | 702 colors
, stops, colorCount, |
703 tm)); | 703 tm)); |
704 SkPaint paint; | 704 SkPaint paint; |
705 GrColor paintColor; | 705 GrColor paintColor; |
706 GrFragmentProcessor* fp; | 706 GrFragmentProcessor* fp; |
707 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 707 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
708 GrTest::TestMatrix(d->fRandom), N
ULL, | 708 GrTest::TestMatrix(d->fRandom), n
ullptr, |
709 &paintColor, d->fProcDataManager,
&fp)); | 709 &paintColor, d->fProcDataManager,
&fp)); |
710 return fp; | 710 return fp; |
711 } | 711 } |
712 | 712 |
713 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) | 713 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) |
714 : fVSVaryingName(NULL) | 714 : fVSVaryingName(nullptr) |
715 , fFSVaryingName(NULL) | 715 , fFSVaryingName(nullptr) |
716 , fCachedFocal(SK_ScalarMax) {} | 716 , fCachedFocal(SK_ScalarMax) {} |
717 | 717 |
718 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { | 718 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { |
719 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); | 719 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); |
720 this->emitUniforms(args.fBuilder, ge); | 720 this->emitUniforms(args.fBuilder, ge); |
721 fFocalUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili
ty, | 721 fFocalUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili
ty, |
722 kFloat_GrSLType, kDefault_GrSLPrecision, | 722 kFloat_GrSLType, kDefault_GrSLPrecision, |
723 "Conical2FSParams"); | 723 "Conical2FSParams"); |
724 SkString tName("t"); | 724 SkString tName("t"); |
725 | 725 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 SkShader::TileMode tm; | 945 SkShader::TileMode tm; |
946 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 946 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
947 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 947 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
948 center
2, radius2, | 948 center
2, radius2, |
949 colors
, stops, colorCount, | 949 colors
, stops, colorCount, |
950 tm)); | 950 tm)); |
951 SkPaint paint; | 951 SkPaint paint; |
952 GrColor paintColor; | 952 GrColor paintColor; |
953 GrFragmentProcessor* fp; | 953 GrFragmentProcessor* fp; |
954 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 954 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
955 GrTest::TestMatrix(d->fRandom), N
ULL, | 955 GrTest::TestMatrix(d->fRandom), n
ullptr, |
956 &paintColor, d->fProcDataManager,
&fp)); | 956 &paintColor, d->fProcDataManager,
&fp)); |
957 return fp; | 957 return fp; |
958 } | 958 } |
959 | 959 |
960 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) | 960 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) |
961 : fVSVaryingName(NULL) | 961 : fVSVaryingName(nullptr) |
962 , fFSVaryingName(NULL) | 962 , fFSVaryingName(nullptr) |
963 , fCachedCenterX(SK_ScalarMax) | 963 , fCachedCenterX(SK_ScalarMax) |
964 , fCachedCenterY(SK_ScalarMax) | 964 , fCachedCenterY(SK_ScalarMax) |
965 , fCachedA(SK_ScalarMax) | 965 , fCachedA(SK_ScalarMax) |
966 , fCachedB(SK_ScalarMax) | 966 , fCachedB(SK_ScalarMax) |
967 , fCachedC(SK_ScalarMax) {} | 967 , fCachedC(SK_ScalarMax) {} |
968 | 968 |
969 void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) { | 969 void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) { |
970 const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConica
lEffect>(); | 970 const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConica
lEffect>(); |
971 this->emitUniforms(args.fBuilder, ge); | 971 this->emitUniforms(args.fBuilder, ge); |
972 fCenterUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibil
ity, | 972 fCenterUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibil
ity, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 SkShader::TileMode tm; | 1176 SkShader::TileMode tm; |
1177 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 1177 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
1178 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 1178 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
1179 center
2, radius2, | 1179 center
2, radius2, |
1180 colors
, stops, colorCount, | 1180 colors
, stops, colorCount, |
1181 tm)); | 1181 tm)); |
1182 SkPaint paint; | 1182 SkPaint paint; |
1183 GrColor paintColor; | 1183 GrColor paintColor; |
1184 GrFragmentProcessor* fp; | 1184 GrFragmentProcessor* fp; |
1185 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 1185 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
1186 GrTest::TestMatrix(d->fRandom), N
ULL, | 1186 GrTest::TestMatrix(d->fRandom), n
ullptr, |
1187 &paintColor, d->fProcDataManager,
&fp)); | 1187 &paintColor, d->fProcDataManager,
&fp)); |
1188 return fp; | 1188 return fp; |
1189 } | 1189 } |
1190 | 1190 |
1191 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) | 1191 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) |
1192 : fVSVaryingName(NULL) | 1192 : fVSVaryingName(nullptr) |
1193 , fFSVaryingName(NULL) | 1193 , fFSVaryingName(nullptr) |
1194 , fCachedCenterX(SK_ScalarMax) | 1194 , fCachedCenterX(SK_ScalarMax) |
1195 , fCachedCenterY(SK_ScalarMax) | 1195 , fCachedCenterY(SK_ScalarMax) |
1196 , fCachedA(SK_ScalarMax) | 1196 , fCachedA(SK_ScalarMax) |
1197 , fCachedB(SK_ScalarMax) | 1197 , fCachedB(SK_ScalarMax) |
1198 , fCachedC(SK_ScalarMax) | 1198 , fCachedC(SK_ScalarMax) |
1199 , fCachedTLimit(SK_ScalarMax) { | 1199 , fCachedTLimit(SK_ScalarMax) { |
1200 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); | 1200 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); |
1201 fIsFlipped = data.isFlipped(); | 1201 fIsFlipped = data.isFlipped(); |
1202 } | 1202 } |
1203 | 1203 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 | 1294 |
1295 ////////////////////////////////////////////////////////////////////////////// | 1295 ////////////////////////////////////////////////////////////////////////////// |
1296 | 1296 |
1297 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx, | 1297 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx, |
1298 GrProcessorDataManager*
procDataManager, | 1298 GrProcessorDataManager*
procDataManager, |
1299 const SkTwoPointConicalG
radient& shader, | 1299 const SkTwoPointConicalG
radient& shader, |
1300 SkShader::TileMode tm, | 1300 SkShader::TileMode tm, |
1301 const SkMatrix* localMat
rix) { | 1301 const SkMatrix* localMat
rix) { |
1302 SkMatrix matrix; | 1302 SkMatrix matrix; |
1303 if (!shader.getLocalMatrix().invert(&matrix)) { | 1303 if (!shader.getLocalMatrix().invert(&matrix)) { |
1304 return NULL; | 1304 return nullptr; |
1305 } | 1305 } |
1306 if (localMatrix) { | 1306 if (localMatrix) { |
1307 SkMatrix inv; | 1307 SkMatrix inv; |
1308 if (!localMatrix->invert(&inv)) { | 1308 if (!localMatrix->invert(&inv)) { |
1309 return NULL; | 1309 return nullptr; |
1310 } | 1310 } |
1311 matrix.postConcat(inv); | 1311 matrix.postConcat(inv); |
1312 } | 1312 } |
1313 | 1313 |
1314 if (shader.getStartRadius() < kErrorTol) { | 1314 if (shader.getStartRadius() < kErrorTol) { |
1315 SkScalar focalX; | 1315 SkScalar focalX; |
1316 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); | 1316 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); |
1317 if (type == kInside_ConicalType) { | 1317 if (type == kInside_ConicalType) { |
1318 return FocalInside2PtConicalEffect::Create(ctx, procDataManager, sha
der, matrix, tm, | 1318 return FocalInside2PtConicalEffect::Create(ctx, procDataManager, sha
der, matrix, tm, |
1319 focalX); | 1319 focalX); |
(...skipping 15 matching lines...) Expand all Loading... |
1335 } else if (type == kEdge_ConicalType) { | 1335 } else if (type == kEdge_ConicalType) { |
1336 set_matrix_edge_conical(shader, &matrix); | 1336 set_matrix_edge_conical(shader, &matrix); |
1337 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, matrix
, tm); | 1337 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, matrix
, tm); |
1338 } else { | 1338 } else { |
1339 return CircleOutside2PtConicalEffect::Create(ctx, procDataManager, shade
r, matrix, tm, | 1339 return CircleOutside2PtConicalEffect::Create(ctx, procDataManager, shade
r, matrix, tm, |
1340 info); | 1340 info); |
1341 } | 1341 } |
1342 } | 1342 } |
1343 | 1343 |
1344 #endif | 1344 #endif |
OLD | NEW |