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

Side by Side Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 1228683002: rename GrShaderDataManager -> GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@grfixuptests
Patch Set: rebase onto origin/master Created 5 years, 5 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/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkTableColorFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkDither.h" 8 #include "SkDither.h"
9 #include "SkPerlinNoiseShader.h" 9 #include "SkPerlinNoiseShader.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 GrGLProgramDataManager::UniformHandle fAlphaUni; 508 GrGLProgramDataManager::UniformHandle fAlphaUni;
509 509
510 private: 510 private:
511 typedef GrGLFragmentProcessor INHERITED; 511 typedef GrGLFragmentProcessor INHERITED;
512 }; 512 };
513 513
514 ///////////////////////////////////////////////////////////////////// 514 /////////////////////////////////////////////////////////////////////
515 515
516 class GrPerlinNoiseEffect : public GrFragmentProcessor { 516 class GrPerlinNoiseEffect : public GrFragmentProcessor {
517 public: 517 public:
518 static GrFragmentProcessor* Create(GrShaderDataManager* shaderDataManager, 518 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
519 SkPerlinNoiseShader::Type type, 519 SkPerlinNoiseShader::Type type,
520 int numOctaves, bool stitchTiles, 520 int numOctaves, bool stitchTiles,
521 SkPerlinNoiseShader::PaintingData* painti ngData, 521 SkPerlinNoiseShader::PaintingData* painti ngData,
522 GrTexture* permutationsTexture, GrTexture * noiseTexture, 522 GrTexture* permutationsTexture, GrTexture * noiseTexture,
523 const SkMatrix& matrix, uint8_t alpha) { 523 const SkMatrix& matrix, uint8_t alpha) {
524 return SkNEW_ARGS(GrPerlinNoiseEffect, (shaderDataManager, type, numOcta ves, stitchTiles, 524 return SkNEW_ARGS(GrPerlinNoiseEffect, (procDataManager, type, numOctave s, stitchTiles,
525 paintingData, permutationsTextur e, noiseTexture, 525 paintingData, permutationsTextur e, noiseTexture,
526 matrix, alpha)); 526 matrix, alpha));
527 } 527 }
528 528
529 virtual ~GrPerlinNoiseEffect() { 529 virtual ~GrPerlinNoiseEffect() {
530 SkDELETE(fPaintingData); 530 SkDELETE(fPaintingData);
531 } 531 }
532 532
533 const char* name() const override { return "PerlinNoise"; } 533 const char* name() const override { return "PerlinNoise"; }
534 534
(...skipping 23 matching lines...) Expand all
558 fNumOctaves == s.fNumOctaves && 558 fNumOctaves == s.fNumOctaves &&
559 fStitchTiles == s.fStitchTiles && 559 fStitchTiles == s.fStitchTiles &&
560 fAlpha == s.fAlpha && 560 fAlpha == s.fAlpha &&
561 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni t; 561 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni t;
562 } 562 }
563 563
564 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 564 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
565 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); 565 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
566 } 566 }
567 567
568 GrPerlinNoiseEffect(GrShaderDataManager*, SkPerlinNoiseShader::Type type, 568 GrPerlinNoiseEffect(GrProcessorDataManager*, SkPerlinNoiseShader::Type type,
569 int numOctaves, bool stitchTiles, 569 int numOctaves, bool stitchTiles,
570 SkPerlinNoiseShader::PaintingData* paintingData, 570 SkPerlinNoiseShader::PaintingData* paintingData,
571 GrTexture* permutationsTexture, GrTexture* noiseTexture, 571 GrTexture* permutationsTexture, GrTexture* noiseTexture,
572 const SkMatrix& matrix, uint8_t alpha) 572 const SkMatrix& matrix, uint8_t alpha)
573 : fType(type) 573 : fType(type)
574 , fNumOctaves(numOctaves) 574 , fNumOctaves(numOctaves)
575 , fStitchTiles(stitchTiles) 575 , fStitchTiles(stitchTiles)
576 , fAlpha(alpha) 576 , fAlpha(alpha)
577 , fPermutationsAccess(permutationsTexture) 577 , fPermutationsAccess(permutationsTexture)
578 , fNoiseAccess(noiseTexture) 578 , fNoiseAccess(noiseTexture)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 stitchTiles ? &tileSize : NULL) : 618 stitchTiles ? &tileSize : NULL) :
619 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed, 619 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed,
620 stitchTiles ? &tileSize : NULL); 620 stitchTiles ? &tileSize : NULL);
621 621
622 SkPaint paint; 622 SkPaint paint;
623 GrColor paintColor; 623 GrColor paintColor;
624 GrFragmentProcessor* effect; 624 GrFragmentProcessor* effect;
625 GrPaint grPaint; 625 GrPaint grPaint;
626 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 626 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
627 GrTest::TestMatrix(d->fRandom), N ULL, 627 GrTest::TestMatrix(d->fRandom), N ULL,
628 &paintColor, grPaint.getShaderDat aManager(), 628 &paintColor, grPaint.getProcessor DataManager(),
629 &effect)); 629 &effect));
630 630
631 SkDELETE(shader); 631 SkDELETE(shader);
632 632
633 return effect; 633 return effect;
634 } 634 }
635 635
636 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) 636 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
637 : fType(processor.cast<GrPerlinNoiseEffect>().type()) 637 : fType(processor.cast<GrPerlinNoiseEffect>().type())
638 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) 638 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 SkIntToScalar(stitchData.fHeight)); 939 SkIntToScalar(stitchData.fHeight));
940 } 940 }
941 } 941 }
942 942
943 ///////////////////////////////////////////////////////////////////// 943 /////////////////////////////////////////////////////////////////////
944 944
945 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint, 945 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
946 const SkMatrix& viewM, 946 const SkMatrix& viewM,
947 const SkMatrix* externalLocalMatri x, 947 const SkMatrix* externalLocalMatri x,
948 GrColor* paintColor, 948 GrColor* paintColor,
949 GrShaderDataManager* shaderDataMan ager, 949 GrProcessorDataManager* procDataMa nager,
950 GrFragmentProcessor** fp) const { 950 GrFragmentProcessor** fp) const {
951 SkASSERT(context); 951 SkASSERT(context);
952 952
953 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 953 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
954 954
955 SkMatrix localMatrix = this->getLocalMatrix(); 955 SkMatrix localMatrix = this->getLocalMatrix();
956 if (externalLocalMatrix) { 956 if (externalLocalMatrix) {
957 localMatrix.preConcat(*externalLocalMatrix); 957 localMatrix.preConcat(*externalLocalMatrix);
958 } 958 }
959 959
(...skipping 18 matching lines...) Expand all
978 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix)); 978 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix));
979 SkAutoTUnref<GrTexture> permutationsTexture( 979 SkAutoTUnref<GrTexture> permutationsTexture(
980 GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL)); 980 GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL));
981 SkAutoTUnref<GrTexture> noiseTexture( 981 SkAutoTUnref<GrTexture> noiseTexture(
982 GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), NULL)) ; 982 GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), NULL)) ;
983 983
984 SkMatrix m = viewM; 984 SkMatrix m = viewM;
985 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1); 985 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
986 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); 986 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
987 if ((permutationsTexture) && (noiseTexture)) { 987 if ((permutationsTexture) && (noiseTexture)) {
988 *fp = GrPerlinNoiseEffect::Create(shaderDataManager, 988 *fp = GrPerlinNoiseEffect::Create(procDataManager,
989 fType, 989 fType,
990 fNumOctaves, 990 fNumOctaves,
991 fStitchTiles, 991 fStitchTiles,
992 paintingData, 992 paintingData,
993 permutationsTexture, noiseTexture, 993 permutationsTexture, noiseTexture,
994 m, paint.getAlpha()); 994 m, paint.getAlpha());
995 } else { 995 } else {
996 SkDELETE(paintingData); 996 SkDELETE(paintingData);
997 *fp = NULL; 997 *fp = NULL;
998 } 998 }
999 return true; 999 return true;
1000 } 1000 }
1001 1001
1002 #else 1002 #else
1003 1003
1004 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&, 1004 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
1005 const SkMatrix*, GrColor*, GrShade rDataManager*, 1005 const SkMatrix*, GrColor*, GrProce ssorDataManager*,
1006 GrFragmentProcessor**) const { 1006 GrFragmentProcessor**) const {
1007 SkDEBUGFAIL("Should not call in GPU-less build"); 1007 SkDEBUGFAIL("Should not call in GPU-less build");
1008 return false; 1008 return false;
1009 } 1009 }
1010 1010
1011 #endif 1011 #endif
1012 1012
1013 #ifndef SK_IGNORE_TO_STRING 1013 #ifndef SK_IGNORE_TO_STRING
1014 void SkPerlinNoiseShader::toString(SkString* str) const { 1014 void SkPerlinNoiseShader::toString(SkString* str) const {
1015 str->append("SkPerlinNoiseShader: ("); 1015 str->append("SkPerlinNoiseShader: (");
(...skipping 19 matching lines...) Expand all
1035 str->append(" seed: "); 1035 str->append(" seed: ");
1036 str->appendScalar(fSeed); 1036 str->appendScalar(fSeed);
1037 str->append(" stitch tiles: "); 1037 str->append(" stitch tiles: ");
1038 str->append(fStitchTiles ? "true " : "false "); 1038 str->append(fStitchTiles ? "true " : "false ");
1039 1039
1040 this->INHERITED::toString(str); 1040 this->INHERITED::toString(str);
1041 1041
1042 str->append(")"); 1042 str->append(")");
1043 } 1043 }
1044 #endif 1044 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698