| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 SkScalar invDiffLen = SkScalarInvert(diffLen); | 53 SkScalar invDiffLen = SkScalarInvert(diffLen); |
| 54 SkMatrix rot; | 54 SkMatrix rot; |
| 55 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY), | 55 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY), |
| 56 SkScalarMul(invDiffLen, diff.fX)); | 56 SkScalarMul(invDiffLen, diff.fX)); |
| 57 invLMatrix->postConcat(rot); | 57 invLMatrix->postConcat(rot); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 class Edge2PtConicalEffect : public GrGradientEffect { | 61 class Edge2PtConicalEffect : public GrGradientEffect { |
| 62 public: | 62 public: |
| 63 class GLSLEdge2PtConicalProcessor; |
| 63 | 64 |
| 64 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 65 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, |
| 65 const SkTwoPointConicalGradient& shad
er, | 66 const SkTwoPointConicalGradient& shad
er, |
| 66 const SkMatrix& matrix, | 67 const SkMatrix& matrix, |
| 67 SkShader::TileMode tm) { | 68 SkShader::TileMode tm) { |
| 68 return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader,
matrix, tm)); | 69 return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader,
matrix, tm)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 virtual ~Edge2PtConicalEffect() {} | 72 virtual ~Edge2PtConicalEffect() {} |
| 72 | 73 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 GrCoordTransform fBTransform; | 134 GrCoordTransform fBTransform; |
| 134 SkScalar fCenterX1; | 135 SkScalar fCenterX1; |
| 135 SkScalar fRadius0; | 136 SkScalar fRadius0; |
| 136 SkScalar fDiffRadius; | 137 SkScalar fDiffRadius; |
| 137 | 138 |
| 138 // @} | 139 // @} |
| 139 | 140 |
| 140 typedef GrGradientEffect INHERITED; | 141 typedef GrGradientEffect INHERITED; |
| 141 }; | 142 }; |
| 142 | 143 |
| 143 class GLEdge2PtConicalEffect : public GrGLGradientEffect { | 144 class Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor : public GrGradientEffec
t::GLSLProcessor { |
| 144 public: | 145 public: |
| 145 GLEdge2PtConicalEffect(const GrProcessor&); | 146 GLSLEdge2PtConicalProcessor(const GrProcessor&); |
| 146 virtual ~GLEdge2PtConicalEffect() { } | 147 virtual ~GLSLEdge2PtConicalProcessor() { } |
| 147 | 148 |
| 148 virtual void emitCode(EmitArgs&) override; | 149 virtual void emitCode(EmitArgs&) override; |
| 149 | 150 |
| 150 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); | 151 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); |
| 151 | 152 |
| 152 protected: | 153 protected: |
| 153 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 154 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 154 | 155 |
| 155 UniformHandle fParamUni; | 156 UniformHandle fParamUni; |
| 156 | 157 |
| 157 const char* fVSVaryingName; | 158 const char* fVSVaryingName; |
| 158 const char* fFSVaryingName; | 159 const char* fFSVaryingName; |
| 159 | 160 |
| 160 // @{ | 161 // @{ |
| 161 /// Values last uploaded as uniforms | 162 /// Values last uploaded as uniforms |
| 162 | 163 |
| 163 SkScalar fCachedRadius; | 164 SkScalar fCachedRadius; |
| 164 SkScalar fCachedDiffRadius; | 165 SkScalar fCachedDiffRadius; |
| 165 | 166 |
| 166 // @} | 167 // @} |
| 167 | 168 |
| 168 private: | 169 private: |
| 169 typedef GrGLGradientEffect INHERITED; | 170 typedef GrGradientEffect::GLSLProcessor INHERITED; |
| 170 | 171 |
| 171 }; | 172 }; |
| 172 | 173 |
| 173 void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 174 void Edge2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 174 GrProcessorKeyBuilder* b) const
{ | 175 GrProcessorKeyBuilder* b) const
{ |
| 175 GLEdge2PtConicalEffect::GenKey(*this, caps, b); | 176 Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(*this, caps, b); |
| 176 } | 177 } |
| 177 | 178 |
| 178 GrGLSLFragmentProcessor* Edge2PtConicalEffect::onCreateGLSLInstance() const { | 179 GrGLSLFragmentProcessor* Edge2PtConicalEffect::onCreateGLSLInstance() const { |
| 179 return new GLEdge2PtConicalEffect(*this); | 180 return new Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor(*this); |
| 180 } | 181 } |
| 181 | 182 |
| 182 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); | 183 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); |
| 183 | 184 |
| 184 /* | 185 /* |
| 185 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 186 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
| 186 */ | 187 */ |
| 187 sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
d) { | 188 sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
d) { |
| 188 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 189 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
| 189 SkScalar radius1 = d->fRandom->nextUScalar1(); | 190 SkScalar radius1 = d->fRandom->nextUScalar1(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 209 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, | 210 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, |
| 210 colors, stops, colorCoun
t, tm); | 211 colors, stops, colorCoun
t, tm); |
| 211 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); | 212 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); |
| 212 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( | 213 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( |
| 213 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, | 214 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, |
| 214 SkSourceGammaTreatment::kRespect)); | 215 SkSourceGammaTreatment::kRespect)); |
| 215 GrAlwaysAssert(fp); | 216 GrAlwaysAssert(fp); |
| 216 return fp; | 217 return fp; |
| 217 } | 218 } |
| 218 | 219 |
| 219 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) | 220 Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GLSLEdge2PtConicalProcessor(c
onst GrProcessor&) |
| 220 : fVSVaryingName(nullptr) | 221 : fVSVaryingName(nullptr) |
| 221 , fFSVaryingName(nullptr) | 222 , fFSVaryingName(nullptr) |
| 222 , fCachedRadius(-SK_ScalarMax) | 223 , fCachedRadius(-SK_ScalarMax) |
| 223 , fCachedDiffRadius(-SK_ScalarMax) {} | 224 , fCachedDiffRadius(-SK_ScalarMax) {} |
| 224 | 225 |
| 225 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) { | 226 void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
{ |
| 226 const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>(); | 227 const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>(); |
| 227 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 228 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 228 this->emitUniforms(uniformHandler, ge); | 229 this->emitUniforms(uniformHandler, ge); |
| 229 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 230 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 230 kVec3f_GrSLType, kDefault_GrSLPrecisi
on, | 231 kVec3f_GrSLType, kDefault_GrSLPrecisi
on, |
| 231 "Conical2FSParams"); | 232 "Conical2FSParams"); |
| 232 | 233 |
| 233 SkString cName("c"); | 234 SkString cName("c"); |
| 234 SkString tName("t"); | 235 SkString tName("t"); |
| 235 SkString p0; // start radius | 236 SkString p0; // start radius |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 uniformHandler, | 278 uniformHandler, |
| 278 args.fGLSLCaps, | 279 args.fGLSLCaps, |
| 279 ge, | 280 ge, |
| 280 tName.c_str(), | 281 tName.c_str(), |
| 281 args.fOutputColor, | 282 args.fOutputColor, |
| 282 args.fInputColor, | 283 args.fInputColor, |
| 283 args.fTexSamplers); | 284 args.fTexSamplers); |
| 284 fragBuilder->codeAppend("\t}\n"); | 285 fragBuilder->codeAppend("\t}\n"); |
| 285 } | 286 } |
| 286 | 287 |
| 287 void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 288 void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::onSetData(const GrGLSLPr
ogramDataManager& pdman, |
| 288 const GrProcessor& processor) { | 289 const GrProcessor& processor) { |
| 289 INHERITED::onSetData(pdman, processor); | 290 INHERITED::onSetData(pdman, processor); |
| 290 const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>(); | 291 const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>(); |
| 291 SkScalar radius0 = data.radius(); | 292 SkScalar radius0 = data.radius(); |
| 292 SkScalar diffRadius = data.diffRadius(); | 293 SkScalar diffRadius = data.diffRadius(); |
| 293 | 294 |
| 294 if (fCachedRadius != radius0 || | 295 if (fCachedRadius != radius0 || |
| 295 fCachedDiffRadius != diffRadius) { | 296 fCachedDiffRadius != diffRadius) { |
| 296 | 297 |
| 297 pdman.set3f(fParamUni, SkScalarToFloat(radius0), | 298 pdman.set3f(fParamUni, SkScalarToFloat(radius0), |
| 298 SkScalarToFloat(SkScalarMul(radius0, radius0)), SkScalarToFl
oat(diffRadius)); | 299 SkScalarToFloat(SkScalarMul(radius0, radius0)), SkScalarToFl
oat(diffRadius)); |
| 299 fCachedRadius = radius0; | 300 fCachedRadius = radius0; |
| 300 fCachedDiffRadius = diffRadius; | 301 fCachedDiffRadius = diffRadius; |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 | 304 |
| 304 void GLEdge2PtConicalEffect::GenKey(const GrProcessor& processor, | 305 void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::GenKey(const GrProcessor
& processor, |
| 305 const GrGLSLCaps&, GrProcessorKeyBuilder* b)
{ | 306 const GrGLSLCaps&, GrProcessorKeyBuilder* b)
{ |
| 306 b->add32(GenBaseGradientKey(processor)); | 307 b->add32(GenBaseGradientKey(processor)); |
| 307 } | 308 } |
| 308 | 309 |
| 309 ////////////////////////////////////////////////////////////////////////////// | 310 ////////////////////////////////////////////////////////////////////////////// |
| 310 // Focal Conical Gradients | 311 // Focal Conical Gradients |
| 311 ////////////////////////////////////////////////////////////////////////////// | 312 ////////////////////////////////////////////////////////////////////////////// |
| 312 | 313 |
| 313 static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
der, | 314 static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
der, |
| 314 SkMatrix* invLMatrix, SkScalar* foca
lX) { | 315 SkMatrix* invLMatrix, SkScalar* foca
lX) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 364 |
| 364 invLMatrix->postConcat(matrix); | 365 invLMatrix->postConcat(matrix); |
| 365 | 366 |
| 366 return conicalType; | 367 return conicalType; |
| 367 } | 368 } |
| 368 | 369 |
| 369 ////////////////////////////////////////////////////////////////////////////// | 370 ////////////////////////////////////////////////////////////////////////////// |
| 370 | 371 |
| 371 class FocalOutside2PtConicalEffect : public GrGradientEffect { | 372 class FocalOutside2PtConicalEffect : public GrGradientEffect { |
| 372 public: | 373 public: |
| 374 class GLSLFocalOutside2PtConicalProcessor; |
| 373 | 375 |
| 374 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 376 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, |
| 375 const SkTwoPointConicalGradient& shad
er, | 377 const SkTwoPointConicalGradient& shad
er, |
| 376 const SkMatrix& matrix, | 378 const SkMatrix& matrix, |
| 377 SkShader::TileMode tm, | 379 SkShader::TileMode tm, |
| 378 SkScalar focalX) { | 380 SkScalar focalX) { |
| 379 return sk_sp<GrFragmentProcessor>( | 381 return sk_sp<GrFragmentProcessor>( |
| 380 new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); | 382 new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); |
| 381 } | 383 } |
| 382 | 384 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 413 } | 415 } |
| 414 | 416 |
| 415 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 417 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 416 | 418 |
| 417 SkScalar fFocalX; | 419 SkScalar fFocalX; |
| 418 bool fIsFlipped; | 420 bool fIsFlipped; |
| 419 | 421 |
| 420 typedef GrGradientEffect INHERITED; | 422 typedef GrGradientEffect INHERITED; |
| 421 }; | 423 }; |
| 422 | 424 |
| 423 class GLFocalOutside2PtConicalEffect : public GrGLGradientEffect { | 425 class FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor : public
GrGradientEffect::GLSLProcessor { |
| 424 public: | 426 public: |
| 425 GLFocalOutside2PtConicalEffect(const GrProcessor&); | 427 GLSLFocalOutside2PtConicalProcessor(const GrProcessor&); |
| 426 virtual ~GLFocalOutside2PtConicalEffect() { } | 428 virtual ~GLSLFocalOutside2PtConicalProcessor() { } |
| 427 | 429 |
| 428 virtual void emitCode(EmitArgs&) override; | 430 virtual void emitCode(EmitArgs&) override; |
| 429 | 431 |
| 430 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); | 432 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); |
| 431 | 433 |
| 432 protected: | 434 protected: |
| 433 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 435 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 434 | 436 |
| 435 UniformHandle fParamUni; | 437 UniformHandle fParamUni; |
| 436 | 438 |
| 437 const char* fVSVaryingName; | 439 const char* fVSVaryingName; |
| 438 const char* fFSVaryingName; | 440 const char* fFSVaryingName; |
| 439 | 441 |
| 440 bool fIsFlipped; | 442 bool fIsFlipped; |
| 441 | 443 |
| 442 // @{ | 444 // @{ |
| 443 /// Values last uploaded as uniforms | 445 /// Values last uploaded as uniforms |
| 444 | 446 |
| 445 SkScalar fCachedFocal; | 447 SkScalar fCachedFocal; |
| 446 | 448 |
| 447 // @} | 449 // @} |
| 448 | 450 |
| 449 private: | 451 private: |
| 450 typedef GrGLGradientEffect INHERITED; | 452 typedef GrGradientEffect::GLSLProcessor INHERITED; |
| 451 | 453 |
| 452 }; | 454 }; |
| 453 | 455 |
| 454 void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 456 void FocalOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 455 GrProcessorKeyBuilder*
b) const { | 457 GrProcessorKeyBuilder*
b) const { |
| 456 GLFocalOutside2PtConicalEffect::GenKey(*this, caps, b); | 458 FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(*t
his, caps, b); |
| 457 } | 459 } |
| 458 | 460 |
| 459 GrGLSLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLSLInstance() co
nst { | 461 GrGLSLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLSLInstance() co
nst { |
| 460 return new GLFocalOutside2PtConicalEffect(*this); | 462 return new FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor
(*this); |
| 461 } | 463 } |
| 462 | 464 |
| 463 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); | 465 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); |
| 464 | 466 |
| 465 /* | 467 /* |
| 466 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 468 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
| 467 */ | 469 */ |
| 468 sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { | 470 sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { |
| 469 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 471 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
| 470 SkScalar radius1 = 0.f; | 472 SkScalar radius1 = 0.f; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 487 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, | 489 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, |
| 488 colors, stops, colorCoun
t, tm); | 490 colors, stops, colorCoun
t, tm); |
| 489 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); | 491 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); |
| 490 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( | 492 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( |
| 491 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, | 493 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, |
| 492 SkSourceGammaTreatment::kRespect)); | 494 SkSourceGammaTreatment::kRespect)); |
| 493 GrAlwaysAssert(fp); | 495 GrAlwaysAssert(fp); |
| 494 return fp; | 496 return fp; |
| 495 } | 497 } |
| 496 | 498 |
| 497 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) | 499 FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GLSLFocalOuts
ide2PtConicalProcessor(const GrProcessor& processor) |
| 498 : fVSVaryingName(nullptr) | 500 : fVSVaryingName(nullptr) |
| 499 , fFSVaryingName(nullptr) | 501 , fFSVaryingName(nullptr) |
| 500 , fCachedFocal(SK_ScalarMax) { | 502 , fCachedFocal(SK_ScalarMax) { |
| 501 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 503 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
| 502 fIsFlipped = data.isFlipped(); | 504 fIsFlipped = data.isFlipped(); |
| 503 } | 505 } |
| 504 | 506 |
| 505 void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) { | 507 void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
(EmitArgs& args) { |
| 506 const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConica
lEffect>(); | 508 const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConica
lEffect>(); |
| 507 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 509 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 508 this->emitUniforms(uniformHandler, ge); | 510 this->emitUniforms(uniformHandler, ge); |
| 509 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 511 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 510 kVec2f_GrSLType, kDefault_GrSLPrecisi
on, | 512 kVec2f_GrSLType, kDefault_GrSLPrecisi
on, |
| 511 "Conical2FSParams"); | 513 "Conical2FSParams"); |
| 512 SkString tName("t"); | 514 SkString tName("t"); |
| 513 SkString p0; // focalX | 515 SkString p0; // focalX |
| 514 SkString p1; // 1 - focalX * focalX | 516 SkString p1; // 1 - focalX * focalX |
| 515 | 517 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 uniformHandler, | 549 uniformHandler, |
| 548 args.fGLSLCaps, | 550 args.fGLSLCaps, |
| 549 ge, | 551 ge, |
| 550 tName.c_str(), | 552 tName.c_str(), |
| 551 args.fOutputColor, | 553 args.fOutputColor, |
| 552 args.fInputColor, | 554 args.fInputColor, |
| 553 args.fTexSamplers); | 555 args.fTexSamplers); |
| 554 fragBuilder->codeAppend("\t}\n"); | 556 fragBuilder->codeAppend("\t}\n"); |
| 555 } | 557 } |
| 556 | 558 |
| 557 void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 559 void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::onSetDat
a(const GrGLSLProgramDataManager& pdman, |
| 558 const GrProcessor& processor) { | 560 const GrProcessor& processor) { |
| 559 INHERITED::onSetData(pdman, processor); | 561 INHERITED::onSetData(pdman, processor); |
| 560 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 562 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
| 561 SkASSERT(data.isFlipped() == fIsFlipped); | 563 SkASSERT(data.isFlipped() == fIsFlipped); |
| 562 SkScalar focal = data.focal(); | 564 SkScalar focal = data.focal(); |
| 563 | 565 |
| 564 if (fCachedFocal != focal) { | 566 if (fCachedFocal != focal) { |
| 565 SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal); | 567 SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal); |
| 566 | 568 |
| 567 pdman.set2f(fParamUni, SkScalarToFloat(focal), SkScalarToFloat(oneMinus2
F)); | 569 pdman.set2f(fParamUni, SkScalarToFloat(focal), SkScalarToFloat(oneMinus2
F)); |
| 568 fCachedFocal = focal; | 570 fCachedFocal = focal; |
| 569 } | 571 } |
| 570 } | 572 } |
| 571 | 573 |
| 572 void GLFocalOutside2PtConicalEffect::GenKey(const GrProcessor& processor, | 574 void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::GenKey(c
onst GrProcessor& processor, |
| 573 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { | 575 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
| 574 uint32_t* key = b->add32n(2); | 576 uint32_t* key = b->add32n(2); |
| 575 key[0] = GenBaseGradientKey(processor); | 577 key[0] = GenBaseGradientKey(processor); |
| 576 key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped(); | 578 key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped(); |
| 577 } | 579 } |
| 578 | 580 |
| 579 ////////////////////////////////////////////////////////////////////////////// | 581 ////////////////////////////////////////////////////////////////////////////// |
| 580 | 582 |
| 581 class GLFocalInside2PtConicalEffect; | |
| 582 | |
| 583 class FocalInside2PtConicalEffect : public GrGradientEffect { | 583 class FocalInside2PtConicalEffect : public GrGradientEffect { |
| 584 public: | 584 public: |
| 585 class GLSLFocalInside2PtConicalProcessor; |
| 585 | 586 |
| 586 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 587 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, |
| 587 const SkTwoPointConicalGradient& shad
er, | 588 const SkTwoPointConicalGradient& shad
er, |
| 588 const SkMatrix& matrix, | 589 const SkMatrix& matrix, |
| 589 SkShader::TileMode tm, | 590 SkShader::TileMode tm, |
| 590 SkScalar focalX) { | 591 SkScalar focalX) { |
| 591 return sk_sp<GrFragmentProcessor>( | 592 return sk_sp<GrFragmentProcessor>( |
| 592 new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); | 593 new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); |
| 593 } | 594 } |
| 594 | 595 |
| 595 virtual ~FocalInside2PtConicalEffect() {} | 596 virtual ~FocalInside2PtConicalEffect() {} |
| 596 | 597 |
| 597 const char* name() const override { | 598 const char* name() const override { |
| 598 return "Two-Point Conical Gradient Focal Inside"; | 599 return "Two-Point Conical Gradient Focal Inside"; |
| 599 } | 600 } |
| 600 | 601 |
| 601 SkScalar focal() const { return fFocalX; } | 602 SkScalar focal() const { return fFocalX; } |
| 602 | 603 |
| 603 typedef GLFocalInside2PtConicalEffect GLSLProcessor; | 604 typedef FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor GLSL
Processor; |
| 604 | 605 |
| 605 private: | 606 private: |
| 606 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 607 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 607 | 608 |
| 608 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 609 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
| 609 | 610 |
| 610 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 611 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
| 611 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE
ffect>(); | 612 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE
ffect>(); |
| 612 return (INHERITED::onIsEqual(sBase) && | 613 return (INHERITED::onIsEqual(sBase) && |
| 613 this->fFocalX == s.fFocalX); | 614 this->fFocalX == s.fFocalX); |
| 614 } | 615 } |
| 615 | 616 |
| 616 FocalInside2PtConicalEffect(GrContext* ctx, | 617 FocalInside2PtConicalEffect(GrContext* ctx, |
| 617 const SkTwoPointConicalGradient& shader, | 618 const SkTwoPointConicalGradient& shader, |
| 618 const SkMatrix& matrix, | 619 const SkMatrix& matrix, |
| 619 SkShader::TileMode tm, | 620 SkShader::TileMode tm, |
| 620 SkScalar focalX) | 621 SkScalar focalX) |
| 621 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) { | 622 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) { |
| 622 this->initClassID<FocalInside2PtConicalEffect>(); | 623 this->initClassID<FocalInside2PtConicalEffect>(); |
| 623 } | 624 } |
| 624 | 625 |
| 625 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 626 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 626 | 627 |
| 627 SkScalar fFocalX; | 628 SkScalar fFocalX; |
| 628 | 629 |
| 629 typedef GrGradientEffect INHERITED; | 630 typedef GrGradientEffect INHERITED; |
| 630 }; | 631 }; |
| 631 | 632 |
| 632 class GLFocalInside2PtConicalEffect : public GrGLGradientEffect { | 633 class FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor : public G
rGradientEffect::GLSLProcessor { |
| 633 public: | 634 public: |
| 634 GLFocalInside2PtConicalEffect(const GrProcessor&); | 635 GLSLFocalInside2PtConicalProcessor(const GrProcessor&); |
| 635 virtual ~GLFocalInside2PtConicalEffect() {} | 636 virtual ~GLSLFocalInside2PtConicalProcessor() {} |
| 636 | 637 |
| 637 virtual void emitCode(EmitArgs&) override; | 638 virtual void emitCode(EmitArgs&) override; |
| 638 | 639 |
| 639 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); | 640 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); |
| 640 | 641 |
| 641 protected: | 642 protected: |
| 642 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 643 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 643 | 644 |
| 644 UniformHandle fFocalUni; | 645 UniformHandle fFocalUni; |
| 645 | 646 |
| 646 const char* fVSVaryingName; | 647 const char* fVSVaryingName; |
| 647 const char* fFSVaryingName; | 648 const char* fFSVaryingName; |
| 648 | 649 |
| 649 // @{ | 650 // @{ |
| 650 /// Values last uploaded as uniforms | 651 /// Values last uploaded as uniforms |
| 651 | 652 |
| 652 SkScalar fCachedFocal; | 653 SkScalar fCachedFocal; |
| 653 | 654 |
| 654 // @} | 655 // @} |
| 655 | 656 |
| 656 private: | 657 private: |
| 657 typedef GrGLGradientEffect INHERITED; | 658 typedef GrGradientEffect::GLSLProcessor INHERITED; |
| 658 | 659 |
| 659 }; | 660 }; |
| 660 | 661 |
| 661 void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 662 void FocalInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 662 GrProcessorKeyBuilder* b
) const { | 663 GrProcessorKeyBuilder* b
) const { |
| 663 GLFocalInside2PtConicalEffect::GenKey(*this, caps, b); | 664 FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(*thi
s, caps, b); |
| 664 } | 665 } |
| 665 | 666 |
| 666 GrGLSLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLSLInstance() con
st { | 667 GrGLSLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLSLInstance() con
st { |
| 667 return new GLFocalInside2PtConicalEffect(*this); | 668 return new FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor(*
this); |
| 668 } | 669 } |
| 669 | 670 |
| 670 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); | 671 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); |
| 671 | 672 |
| 672 /* | 673 /* |
| 673 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 674 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
| 674 */ | 675 */ |
| 675 sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
stData* d) { | 676 sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
stData* d) { |
| 676 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 677 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
| 677 SkScalar radius1 = 0.f; | 678 SkScalar radius1 = 0.f; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 696 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, | 697 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, |
| 697 colors, stops, colorCoun
t, tm); | 698 colors, stops, colorCoun
t, tm); |
| 698 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); | 699 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); |
| 699 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( | 700 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( |
| 700 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, | 701 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, |
| 701 SkSourceGammaTreatment::kRespect)); | 702 SkSourceGammaTreatment::kRespect)); |
| 702 GrAlwaysAssert(fp); | 703 GrAlwaysAssert(fp); |
| 703 return fp; | 704 return fp; |
| 704 } | 705 } |
| 705 | 706 |
| 706 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) | 707 FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GLSLFocalInside
2PtConicalProcessor(const GrProcessor&) |
| 707 : fVSVaryingName(nullptr) | 708 : fVSVaryingName(nullptr) |
| 708 , fFSVaryingName(nullptr) | 709 , fFSVaryingName(nullptr) |
| 709 , fCachedFocal(SK_ScalarMax) {} | 710 , fCachedFocal(SK_ScalarMax) {} |
| 710 | 711 |
| 711 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { | 712 void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
mitArgs& args) { |
| 712 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); | 713 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); |
| 713 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 714 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 714 this->emitUniforms(uniformHandler, ge); | 715 this->emitUniforms(uniformHandler, ge); |
| 715 fFocalUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 716 fFocalUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 716 kFloat_GrSLType, kDefault_GrSLPrecisi
on, | 717 kFloat_GrSLType, kDefault_GrSLPrecisi
on, |
| 717 "Conical2FSParams"); | 718 "Conical2FSParams"); |
| 718 SkString tName("t"); | 719 SkString tName("t"); |
| 719 | 720 |
| 720 // this is the distance along x-axis from the end center to focal point in | 721 // this is the distance along x-axis from the end center to focal point in |
| 721 // transformed coordinates | 722 // transformed coordinates |
| (...skipping 11 matching lines...) Expand all Loading... |
| 733 this->emitColor(fragBuilder, | 734 this->emitColor(fragBuilder, |
| 734 uniformHandler, | 735 uniformHandler, |
| 735 args.fGLSLCaps, | 736 args.fGLSLCaps, |
| 736 ge, | 737 ge, |
| 737 tName.c_str(), | 738 tName.c_str(), |
| 738 args.fOutputColor, | 739 args.fOutputColor, |
| 739 args.fInputColor, | 740 args.fInputColor, |
| 740 args.fTexSamplers); | 741 args.fTexSamplers); |
| 741 } | 742 } |
| 742 | 743 |
| 743 void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
man, | 744 void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::onSetData(
const GrGLSLProgramDataManager& pdman, |
| 744 const GrProcessor& processor) { | 745 const GrProcessor& processor) { |
| 745 INHERITED::onSetData(pdman, processor); | 746 INHERITED::onSetData(pdman, processor); |
| 746 const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConic
alEffect>(); | 747 const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConic
alEffect>(); |
| 747 SkScalar focal = data.focal(); | 748 SkScalar focal = data.focal(); |
| 748 | 749 |
| 749 if (fCachedFocal != focal) { | 750 if (fCachedFocal != focal) { |
| 750 pdman.set1f(fFocalUni, SkScalarToFloat(focal)); | 751 pdman.set1f(fFocalUni, SkScalarToFloat(focal)); |
| 751 fCachedFocal = focal; | 752 fCachedFocal = focal; |
| 752 } | 753 } |
| 753 } | 754 } |
| 754 | 755 |
| 755 void GLFocalInside2PtConicalEffect::GenKey(const GrProcessor& processor, | 756 void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::GenKey(con
st GrProcessor& processor, |
| 756 const GrGLSLCaps&, GrProcessorKeyBuil
der* b) { | 757 const GrGLSLCaps&, GrProcessorKeyBuil
der* b) { |
| 757 b->add32(GenBaseGradientKey(processor)); | 758 b->add32(GenBaseGradientKey(processor)); |
| 758 } | 759 } |
| 759 | 760 |
| 760 ////////////////////////////////////////////////////////////////////////////// | 761 ////////////////////////////////////////////////////////////////////////////// |
| 761 // Circle Conical Gradients | 762 // Circle Conical Gradients |
| 762 ////////////////////////////////////////////////////////////////////////////// | 763 ////////////////////////////////////////////////////////////////////////////// |
| 763 | 764 |
| 764 struct CircleConicalInfo { | 765 struct CircleConicalInfo { |
| 765 SkPoint fCenterEnd; | 766 SkPoint fCenterEnd; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 | 817 |
| 817 // if A ends up being negative, the start circle is contained completely ins
ide the end cirlce | 818 // if A ends up being negative, the start circle is contained completely ins
ide the end cirlce |
| 818 if (A < 0.f) { | 819 if (A < 0.f) { |
| 819 return kInside_ConicalType; | 820 return kInside_ConicalType; |
| 820 } | 821 } |
| 821 return kOutside_ConicalType; | 822 return kOutside_ConicalType; |
| 822 } | 823 } |
| 823 | 824 |
| 824 class CircleInside2PtConicalEffect : public GrGradientEffect { | 825 class CircleInside2PtConicalEffect : public GrGradientEffect { |
| 825 public: | 826 public: |
| 827 class GLSLCircleInside2PtConicalProcessor; |
| 826 | 828 |
| 827 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 829 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, |
| 828 const SkTwoPointConicalGradient& shad
er, | 830 const SkTwoPointConicalGradient& shad
er, |
| 829 const SkMatrix& matrix, | 831 const SkMatrix& matrix, |
| 830 SkShader::TileMode tm, | 832 SkShader::TileMode tm, |
| 831 const CircleConicalInfo& info) { | 833 const CircleConicalInfo& info) { |
| 832 return sk_sp<GrFragmentProcessor>( | 834 return sk_sp<GrFragmentProcessor>( |
| 833 new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info)); | 835 new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info)); |
| 834 } | 836 } |
| 835 | 837 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 this->initClassID<CircleInside2PtConicalEffect>(); | 869 this->initClassID<CircleInside2PtConicalEffect>(); |
| 868 } | 870 } |
| 869 | 871 |
| 870 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 872 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 871 | 873 |
| 872 const CircleConicalInfo fInfo; | 874 const CircleConicalInfo fInfo; |
| 873 | 875 |
| 874 typedef GrGradientEffect INHERITED; | 876 typedef GrGradientEffect INHERITED; |
| 875 }; | 877 }; |
| 876 | 878 |
| 877 class GLCircleInside2PtConicalEffect : public GrGLGradientEffect { | 879 class CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor : public
GrGradientEffect::GLSLProcessor { |
| 878 public: | 880 public: |
| 879 GLCircleInside2PtConicalEffect(const GrProcessor&); | 881 GLSLCircleInside2PtConicalProcessor(const GrProcessor&); |
| 880 virtual ~GLCircleInside2PtConicalEffect() {} | 882 virtual ~GLSLCircleInside2PtConicalProcessor() {} |
| 881 | 883 |
| 882 virtual void emitCode(EmitArgs&) override; | 884 virtual void emitCode(EmitArgs&) override; |
| 883 | 885 |
| 884 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); | 886 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); |
| 885 | 887 |
| 886 protected: | 888 protected: |
| 887 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 889 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 888 | 890 |
| 889 UniformHandle fCenterUni; | 891 UniformHandle fCenterUni; |
| 890 UniformHandle fParamUni; | 892 UniformHandle fParamUni; |
| 891 | 893 |
| 892 const char* fVSVaryingName; | 894 const char* fVSVaryingName; |
| 893 const char* fFSVaryingName; | 895 const char* fFSVaryingName; |
| 894 | 896 |
| 895 // @{ | 897 // @{ |
| 896 /// Values last uploaded as uniforms | 898 /// Values last uploaded as uniforms |
| 897 | 899 |
| 898 SkScalar fCachedCenterX; | 900 SkScalar fCachedCenterX; |
| 899 SkScalar fCachedCenterY; | 901 SkScalar fCachedCenterY; |
| 900 SkScalar fCachedA; | 902 SkScalar fCachedA; |
| 901 SkScalar fCachedB; | 903 SkScalar fCachedB; |
| 902 SkScalar fCachedC; | 904 SkScalar fCachedC; |
| 903 | 905 |
| 904 // @} | 906 // @} |
| 905 | 907 |
| 906 private: | 908 private: |
| 907 typedef GrGLGradientEffect INHERITED; | 909 typedef GrGradientEffect::GLSLProcessor INHERITED; |
| 908 | 910 |
| 909 }; | 911 }; |
| 910 | 912 |
| 911 void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 913 void CircleInside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 912 GrProcessorKeyBuilder*
b) const { | 914 GrProcessorKeyBuilder*
b) const { |
| 913 GLCircleInside2PtConicalEffect::GenKey(*this, caps, b); | 915 CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(*t
his, caps, b); |
| 914 } | 916 } |
| 915 | 917 |
| 916 GrGLSLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLSLInstance() co
nst { | 918 GrGLSLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLSLInstance() co
nst { |
| 917 return new GLCircleInside2PtConicalEffect(*this); | 919 return new CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor
(*this); |
| 918 } | 920 } |
| 919 | 921 |
| 920 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); | 922 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); |
| 921 | 923 |
| 922 /* | 924 /* |
| 923 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 925 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
| 924 */ | 926 */ |
| 925 sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { | 927 sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { |
| 926 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 928 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
| 927 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 | 929 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 945 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, | 947 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, |
| 946 colors, stops, colorCoun
t, tm); | 948 colors, stops, colorCoun
t, tm); |
| 947 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); | 949 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); |
| 948 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( | 950 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( |
| 949 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, | 951 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, |
| 950 SkSourceGammaTreatment::kRespect)); | 952 SkSourceGammaTreatment::kRespect)); |
| 951 GrAlwaysAssert(fp); | 953 GrAlwaysAssert(fp); |
| 952 return fp; | 954 return fp; |
| 953 } | 955 } |
| 954 | 956 |
| 955 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) | 957 CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GLSLCircleIns
ide2PtConicalProcessor(const GrProcessor& processor) |
| 956 : fVSVaryingName(nullptr) | 958 : fVSVaryingName(nullptr) |
| 957 , fFSVaryingName(nullptr) | 959 , fFSVaryingName(nullptr) |
| 958 , fCachedCenterX(SK_ScalarMax) | 960 , fCachedCenterX(SK_ScalarMax) |
| 959 , fCachedCenterY(SK_ScalarMax) | 961 , fCachedCenterY(SK_ScalarMax) |
| 960 , fCachedA(SK_ScalarMax) | 962 , fCachedA(SK_ScalarMax) |
| 961 , fCachedB(SK_ScalarMax) | 963 , fCachedB(SK_ScalarMax) |
| 962 , fCachedC(SK_ScalarMax) {} | 964 , fCachedC(SK_ScalarMax) {} |
| 963 | 965 |
| 964 void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) { | 966 void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
(EmitArgs& args) { |
| 965 const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConica
lEffect>(); | 967 const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConica
lEffect>(); |
| 966 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 968 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 967 this->emitUniforms(uniformHandler, ge); | 969 this->emitUniforms(uniformHandler, ge); |
| 968 fCenterUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 970 fCenterUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 969 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, | 971 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, |
| 970 "Conical2FSCenter"); | 972 "Conical2FSCenter"); |
| 971 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 973 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 972 kVec3f_GrSLType, kDefault_GrSLPrecisi
on, | 974 kVec3f_GrSLType, kDefault_GrSLPrecisi
on, |
| 973 "Conical2FSParams"); | 975 "Conical2FSParams"); |
| 974 SkString tName("t"); | 976 SkString tName("t"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1001 this->emitColor(fragBuilder, | 1003 this->emitColor(fragBuilder, |
| 1002 uniformHandler, | 1004 uniformHandler, |
| 1003 args.fGLSLCaps, | 1005 args.fGLSLCaps, |
| 1004 ge, | 1006 ge, |
| 1005 tName.c_str(), | 1007 tName.c_str(), |
| 1006 args.fOutputColor, | 1008 args.fOutputColor, |
| 1007 args.fInputColor, | 1009 args.fInputColor, |
| 1008 args.fTexSamplers); | 1010 args.fTexSamplers); |
| 1009 } | 1011 } |
| 1010 | 1012 |
| 1011 void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 1013 void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::onSetDat
a(const GrGLSLProgramDataManager& pdman, |
| 1012 const GrProcessor& processor) { | 1014 const GrProcessor& processor) { |
| 1013 INHERITED::onSetData(pdman, processor); | 1015 INHERITED::onSetData(pdman, processor); |
| 1014 const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtCon
icalEffect>(); | 1016 const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtCon
icalEffect>(); |
| 1015 SkScalar centerX = data.centerX(); | 1017 SkScalar centerX = data.centerX(); |
| 1016 SkScalar centerY = data.centerY(); | 1018 SkScalar centerY = data.centerY(); |
| 1017 SkScalar A = data.A(); | 1019 SkScalar A = data.A(); |
| 1018 SkScalar B = data.B(); | 1020 SkScalar B = data.B(); |
| 1019 SkScalar C = data.C(); | 1021 SkScalar C = data.C(); |
| 1020 | 1022 |
| 1021 if (fCachedCenterX != centerX || fCachedCenterY != centerY || | 1023 if (fCachedCenterX != centerX || fCachedCenterY != centerY || |
| 1022 fCachedA != A || fCachedB != B || fCachedC != C) { | 1024 fCachedA != A || fCachedB != B || fCachedC != C) { |
| 1023 | 1025 |
| 1024 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); | 1026 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); |
| 1025 pdman.set3f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C)); | 1027 pdman.set3f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C)); |
| 1026 | 1028 |
| 1027 fCachedCenterX = centerX; | 1029 fCachedCenterX = centerX; |
| 1028 fCachedCenterY = centerY; | 1030 fCachedCenterY = centerY; |
| 1029 fCachedA = A; | 1031 fCachedA = A; |
| 1030 fCachedB = B; | 1032 fCachedB = B; |
| 1031 fCachedC = C; | 1033 fCachedC = C; |
| 1032 } | 1034 } |
| 1033 } | 1035 } |
| 1034 | 1036 |
| 1035 void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor, | 1037 void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::GenKey(c
onst GrProcessor& processor, |
| 1036 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { | 1038 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
| 1037 b->add32(GenBaseGradientKey(processor)); | 1039 b->add32(GenBaseGradientKey(processor)); |
| 1038 } | 1040 } |
| 1039 | 1041 |
| 1040 ////////////////////////////////////////////////////////////////////////////// | 1042 ////////////////////////////////////////////////////////////////////////////// |
| 1041 | 1043 |
| 1042 class CircleOutside2PtConicalEffect : public GrGradientEffect { | 1044 class CircleOutside2PtConicalEffect : public GrGradientEffect { |
| 1043 public: | 1045 public: |
| 1046 class GLSLCircleOutside2PtConicalProcessor; |
| 1044 | 1047 |
| 1045 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 1048 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, |
| 1046 const SkTwoPointConicalGradient& shad
er, | 1049 const SkTwoPointConicalGradient& shad
er, |
| 1047 const SkMatrix& matrix, | 1050 const SkMatrix& matrix, |
| 1048 SkShader::TileMode tm, | 1051 SkShader::TileMode tm, |
| 1049 const CircleConicalInfo& info) { | 1052 const CircleConicalInfo& info) { |
| 1050 return sk_sp<GrFragmentProcessor>( | 1053 return sk_sp<GrFragmentProcessor>( |
| 1051 new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info)); | 1054 new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info)); |
| 1052 } | 1055 } |
| 1053 | 1056 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 | 1100 |
| 1098 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 1101 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 1099 | 1102 |
| 1100 const CircleConicalInfo fInfo; | 1103 const CircleConicalInfo fInfo; |
| 1101 SkScalar fTLimit; | 1104 SkScalar fTLimit; |
| 1102 bool fIsFlipped; | 1105 bool fIsFlipped; |
| 1103 | 1106 |
| 1104 typedef GrGradientEffect INHERITED; | 1107 typedef GrGradientEffect INHERITED; |
| 1105 }; | 1108 }; |
| 1106 | 1109 |
| 1107 class GLCircleOutside2PtConicalEffect : public GrGLGradientEffect { | 1110 class CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor : publ
ic GrGradientEffect::GLSLProcessor { |
| 1108 public: | 1111 public: |
| 1109 GLCircleOutside2PtConicalEffect(const GrProcessor&); | 1112 GLSLCircleOutside2PtConicalProcessor(const GrProcessor&); |
| 1110 virtual ~GLCircleOutside2PtConicalEffect() {} | 1113 virtual ~GLSLCircleOutside2PtConicalProcessor() {} |
| 1111 | 1114 |
| 1112 virtual void emitCode(EmitArgs&) override; | 1115 virtual void emitCode(EmitArgs&) override; |
| 1113 | 1116 |
| 1114 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); | 1117 static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKe
yBuilder* b); |
| 1115 | 1118 |
| 1116 protected: | 1119 protected: |
| 1117 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 1120 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 1118 | 1121 |
| 1119 UniformHandle fCenterUni; | 1122 UniformHandle fCenterUni; |
| 1120 UniformHandle fParamUni; | 1123 UniformHandle fParamUni; |
| 1121 | 1124 |
| 1122 const char* fVSVaryingName; | 1125 const char* fVSVaryingName; |
| 1123 const char* fFSVaryingName; | 1126 const char* fFSVaryingName; |
| 1124 | 1127 |
| 1125 bool fIsFlipped; | 1128 bool fIsFlipped; |
| 1126 | 1129 |
| 1127 // @{ | 1130 // @{ |
| 1128 /// Values last uploaded as uniforms | 1131 /// Values last uploaded as uniforms |
| 1129 | 1132 |
| 1130 SkScalar fCachedCenterX; | 1133 SkScalar fCachedCenterX; |
| 1131 SkScalar fCachedCenterY; | 1134 SkScalar fCachedCenterY; |
| 1132 SkScalar fCachedA; | 1135 SkScalar fCachedA; |
| 1133 SkScalar fCachedB; | 1136 SkScalar fCachedB; |
| 1134 SkScalar fCachedC; | 1137 SkScalar fCachedC; |
| 1135 SkScalar fCachedTLimit; | 1138 SkScalar fCachedTLimit; |
| 1136 | 1139 |
| 1137 // @} | 1140 // @} |
| 1138 | 1141 |
| 1139 private: | 1142 private: |
| 1140 typedef GrGLGradientEffect INHERITED; | 1143 typedef GrGradientEffect::GLSLProcessor INHERITED; |
| 1141 | 1144 |
| 1142 }; | 1145 }; |
| 1143 | 1146 |
| 1144 void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps
, | 1147 void CircleOutside2PtConicalEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps
, |
| 1145 GrProcessorKeyBuilder*
b) const { | 1148 GrProcessorKeyBuilder*
b) const { |
| 1146 GLCircleOutside2PtConicalEffect::GenKey(*this, caps, b); | 1149 CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey(
*this, caps, b); |
| 1147 } | 1150 } |
| 1148 | 1151 |
| 1149 GrGLSLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLSLInstance() c
onst { | 1152 GrGLSLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLSLInstance() c
onst { |
| 1150 return new GLCircleOutside2PtConicalEffect(*this); | 1153 return new CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcess
or(*this); |
| 1151 } | 1154 } |
| 1152 | 1155 |
| 1153 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); | 1156 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); |
| 1154 | 1157 |
| 1155 /* | 1158 /* |
| 1156 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 1159 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
| 1157 */ | 1160 */ |
| 1158 sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
TestData* d) { | 1161 sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
TestData* d) { |
| 1159 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 1162 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
| 1160 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 | 1163 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1179 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, | 1182 auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center
2, radius2, |
| 1180 colors, stops, colorCoun
t, tm); | 1183 colors, stops, colorCoun
t, tm); |
| 1181 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); | 1184 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom); |
| 1182 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( | 1185 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr
gs( |
| 1183 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, | 1186 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr, |
| 1184 SkSourceGammaTreatment::kRespect)); | 1187 SkSourceGammaTreatment::kRespect)); |
| 1185 GrAlwaysAssert(fp); | 1188 GrAlwaysAssert(fp); |
| 1186 return fp; | 1189 return fp; |
| 1187 } | 1190 } |
| 1188 | 1191 |
| 1189 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) | 1192 CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GLSLCircleO
utside2PtConicalProcessor(const GrProcessor& processor) |
| 1190 : fVSVaryingName(nullptr) | 1193 : fVSVaryingName(nullptr) |
| 1191 , fFSVaryingName(nullptr) | 1194 , fFSVaryingName(nullptr) |
| 1192 , fCachedCenterX(SK_ScalarMax) | 1195 , fCachedCenterX(SK_ScalarMax) |
| 1193 , fCachedCenterY(SK_ScalarMax) | 1196 , fCachedCenterY(SK_ScalarMax) |
| 1194 , fCachedA(SK_ScalarMax) | 1197 , fCachedA(SK_ScalarMax) |
| 1195 , fCachedB(SK_ScalarMax) | 1198 , fCachedB(SK_ScalarMax) |
| 1196 , fCachedC(SK_ScalarMax) | 1199 , fCachedC(SK_ScalarMax) |
| 1197 , fCachedTLimit(SK_ScalarMax) { | 1200 , fCachedTLimit(SK_ScalarMax) { |
| 1198 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); | 1201 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); |
| 1199 fIsFlipped = data.isFlipped(); | 1202 fIsFlipped = data.isFlipped(); |
| 1200 } | 1203 } |
| 1201 | 1204 |
| 1202 void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) { | 1205 void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
de(EmitArgs& args) { |
| 1203 const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConi
calEffect>(); | 1206 const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConi
calEffect>(); |
| 1204 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 1207 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 1205 this->emitUniforms(uniformHandler, ge); | 1208 this->emitUniforms(uniformHandler, ge); |
| 1206 fCenterUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 1209 fCenterUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 1207 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, | 1210 kVec2f_GrSLType, kDefault_GrSLPrecis
ion, |
| 1208 "Conical2FSCenter"); | 1211 "Conical2FSCenter"); |
| 1209 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 1212 fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
| 1210 kVec4f_GrSLType, kDefault_GrSLPrecisi
on, | 1213 kVec4f_GrSLType, kDefault_GrSLPrecisi
on, |
| 1211 "Conical2FSParams"); | 1214 "Conical2FSParams"); |
| 1212 SkString tName("t"); | 1215 SkString tName("t"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 uniformHandler, | 1259 uniformHandler, |
| 1257 args.fGLSLCaps, | 1260 args.fGLSLCaps, |
| 1258 ge, | 1261 ge, |
| 1259 tName.c_str(), | 1262 tName.c_str(), |
| 1260 args.fOutputColor, | 1263 args.fOutputColor, |
| 1261 args.fInputColor, | 1264 args.fInputColor, |
| 1262 args.fTexSamplers); | 1265 args.fTexSamplers); |
| 1263 fragBuilder->codeAppend("\t}\n"); | 1266 fragBuilder->codeAppend("\t}\n"); |
| 1264 } | 1267 } |
| 1265 | 1268 |
| 1266 void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
pdman, | 1269 void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::onSetD
ata(const GrGLSLProgramDataManager& pdman, |
| 1267 const GrProcessor& processor) { | 1270 const GrProcessor& processor) { |
| 1268 INHERITED::onSetData(pdman, processor); | 1271 INHERITED::onSetData(pdman, processor); |
| 1269 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); | 1272 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); |
| 1270 SkASSERT(data.isFlipped() == fIsFlipped); | 1273 SkASSERT(data.isFlipped() == fIsFlipped); |
| 1271 SkScalar centerX = data.centerX(); | 1274 SkScalar centerX = data.centerX(); |
| 1272 SkScalar centerY = data.centerY(); | 1275 SkScalar centerY = data.centerY(); |
| 1273 SkScalar A = data.A(); | 1276 SkScalar A = data.A(); |
| 1274 SkScalar B = data.B(); | 1277 SkScalar B = data.B(); |
| 1275 SkScalar C = data.C(); | 1278 SkScalar C = data.C(); |
| 1276 SkScalar tLimit = data.tLimit(); | 1279 SkScalar tLimit = data.tLimit(); |
| 1277 | 1280 |
| 1278 if (fCachedCenterX != centerX || fCachedCenterY != centerY || | 1281 if (fCachedCenterX != centerX || fCachedCenterY != centerY || |
| 1279 fCachedA != A || fCachedB != B || fCachedC != C || fCachedTLimit != tLim
it) { | 1282 fCachedA != A || fCachedB != B || fCachedC != C || fCachedTLimit != tLim
it) { |
| 1280 | 1283 |
| 1281 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); | 1284 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); |
| 1282 pdman.set4f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C), | 1285 pdman.set4f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C), |
| 1283 SkScalarToFloat(tLimit)); | 1286 SkScalarToFloat(tLimit)); |
| 1284 | 1287 |
| 1285 fCachedCenterX = centerX; | 1288 fCachedCenterX = centerX; |
| 1286 fCachedCenterY = centerY; | 1289 fCachedCenterY = centerY; |
| 1287 fCachedA = A; | 1290 fCachedA = A; |
| 1288 fCachedB = B; | 1291 fCachedB = B; |
| 1289 fCachedC = C; | 1292 fCachedC = C; |
| 1290 fCachedTLimit = tLimit; | 1293 fCachedTLimit = tLimit; |
| 1291 } | 1294 } |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor, | 1297 void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey
(const GrProcessor& processor, |
| 1295 const GrGLSLCaps&, GrProcessorKeyBu
ilder* b) { | 1298 const GrGLSLCaps&, GrProcessorKeyBu
ilder* b) { |
| 1296 uint32_t* key = b->add32n(2); | 1299 uint32_t* key = b->add32n(2); |
| 1297 key[0] = GenBaseGradientKey(processor); | 1300 key[0] = GenBaseGradientKey(processor); |
| 1298 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); | 1301 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); |
| 1299 } | 1302 } |
| 1300 | 1303 |
| 1301 ////////////////////////////////////////////////////////////////////////////// | 1304 ////////////////////////////////////////////////////////////////////////////// |
| 1302 | 1305 |
| 1303 sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx, | 1306 sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx, |
| 1304 const SkTwoPointConi
calGradient& shader, | 1307 const SkTwoPointConi
calGradient& shader, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info)
; | 1339 return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info)
; |
| 1337 } else if (type == kEdge_ConicalType) { | 1340 } else if (type == kEdge_ConicalType) { |
| 1338 set_matrix_edge_conical(shader, &matrix); | 1341 set_matrix_edge_conical(shader, &matrix); |
| 1339 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm); | 1342 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm); |
| 1340 } else { | 1343 } else { |
| 1341 return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info
); | 1344 return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info
); |
| 1342 } | 1345 } |
| 1343 } | 1346 } |
| 1344 | 1347 |
| 1345 #endif | 1348 #endif |
| OLD | NEW |