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

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

Issue 1215643006: more threading of GrShaderDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@GrShaderDataManager3
Patch Set: tweaks 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
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(SkPerlinNoiseShader::Type type, 518 static GrFragmentProcessor* Create(GrShaderDataManager* shaderDataManager,
519 SkPerlinNoiseShader::Type type,
519 int numOctaves, bool stitchTiles, 520 int numOctaves, bool stitchTiles,
520 SkPerlinNoiseShader::PaintingData* painti ngData, 521 SkPerlinNoiseShader::PaintingData* painti ngData,
521 GrTexture* permutationsTexture, GrTexture * noiseTexture, 522 GrTexture* permutationsTexture, GrTexture * noiseTexture,
522 const SkMatrix& matrix, uint8_t alpha) { 523 const SkMatrix& matrix, uint8_t alpha) {
523 return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, p aintingData, 524 return SkNEW_ARGS(GrPerlinNoiseEffect, (shaderDataManager, type, numOcta ves, stitchTiles,
524 permutationsTexture, noiseTextur e, matrix, alpha)); 525 paintingData, permutationsTextur e, noiseTexture,
526 matrix, alpha));
525 } 527 }
526 528
527 virtual ~GrPerlinNoiseEffect() { 529 virtual ~GrPerlinNoiseEffect() {
528 SkDELETE(fPaintingData); 530 SkDELETE(fPaintingData);
529 } 531 }
530 532
531 const char* name() const override { return "PerlinNoise"; } 533 const char* name() const override { return "PerlinNoise"; }
532 534
533 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 535 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
534 GrProcessorKeyBuilder* b) const override { 536 GrProcessorKeyBuilder* b) const override {
(...skipping 21 matching lines...) Expand all
556 fNumOctaves == s.fNumOctaves && 558 fNumOctaves == s.fNumOctaves &&
557 fStitchTiles == s.fStitchTiles && 559 fStitchTiles == s.fStitchTiles &&
558 fAlpha == s.fAlpha && 560 fAlpha == s.fAlpha &&
559 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni t; 561 fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataIni t;
560 } 562 }
561 563
562 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 564 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
563 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); 565 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
564 } 566 }
565 567
566 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, 568 GrPerlinNoiseEffect(GrShaderDataManager*, SkPerlinNoiseShader::Type type,
567 int numOctaves, bool stitchTiles, 569 int numOctaves, bool stitchTiles,
568 SkPerlinNoiseShader::PaintingData* paintingData, 570 SkPerlinNoiseShader::PaintingData* paintingData,
569 GrTexture* permutationsTexture, GrTexture* noiseTexture, 571 GrTexture* permutationsTexture, GrTexture* noiseTexture,
570 const SkMatrix& matrix, uint8_t alpha) 572 const SkMatrix& matrix, uint8_t alpha)
571 : fType(type) 573 : fType(type)
572 , fNumOctaves(numOctaves) 574 , fNumOctaves(numOctaves)
573 , fStitchTiles(stitchTiles) 575 , fStitchTiles(stitchTiles)
574 , fAlpha(alpha) 576 , fAlpha(alpha)
575 , fPermutationsAccess(permutationsTexture) 577 , fPermutationsAccess(permutationsTexture)
576 , fNoiseAccess(noiseTexture) 578 , fNoiseAccess(noiseTexture)
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), 938 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth),
937 SkIntToScalar(stitchData.fHeight)); 939 SkIntToScalar(stitchData.fHeight));
938 } 940 }
939 } 941 }
940 942
941 ///////////////////////////////////////////////////////////////////// 943 /////////////////////////////////////////////////////////////////////
942 944
943 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint, 945 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
944 const SkMatrix& viewM, 946 const SkMatrix& viewM,
945 const SkMatrix* externalLocalMatri x, 947 const SkMatrix* externalLocalMatri x,
946 GrColor* paintColor, GrFragmentPro cessor** fp) const { 948 GrColor* paintColor,
949 GrShaderDataManager* shaderDataMan ager,
950 GrFragmentProcessor** fp) const {
947 SkASSERT(context); 951 SkASSERT(context);
948 952
949 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 953 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
950 954
951 SkMatrix localMatrix = this->getLocalMatrix(); 955 SkMatrix localMatrix = this->getLocalMatrix();
952 if (externalLocalMatrix) { 956 if (externalLocalMatrix) {
953 localMatrix.preConcat(*externalLocalMatrix); 957 localMatrix.preConcat(*externalLocalMatrix);
954 } 958 }
955 959
956 SkMatrix matrix = viewM; 960 SkMatrix matrix = viewM;
(...skipping 17 matching lines...) Expand all
974 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix)); 978 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix));
975 SkAutoTUnref<GrTexture> permutationsTexture( 979 SkAutoTUnref<GrTexture> permutationsTexture(
976 GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL)); 980 GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL));
977 SkAutoTUnref<GrTexture> noiseTexture( 981 SkAutoTUnref<GrTexture> noiseTexture(
978 GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), NULL)) ; 982 GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), NULL)) ;
979 983
980 SkMatrix m = viewM; 984 SkMatrix m = viewM;
981 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1); 985 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
982 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); 986 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
983 if ((permutationsTexture) && (noiseTexture)) { 987 if ((permutationsTexture) && (noiseTexture)) {
984 *fp = GrPerlinNoiseEffect::Create(fType, 988 *fp = GrPerlinNoiseEffect::Create(shaderDataManager,
989 fType,
985 fNumOctaves, 990 fNumOctaves,
986 fStitchTiles, 991 fStitchTiles,
987 paintingData, 992 paintingData,
988 permutationsTexture, noiseTexture, 993 permutationsTexture, noiseTexture,
989 m, paint.getAlpha()); 994 m, paint.getAlpha());
990 } else { 995 } else {
991 SkDELETE(paintingData); 996 SkDELETE(paintingData);
992 *fp = NULL; 997 *fp = NULL;
993 } 998 }
994 return true; 999 return true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 str->append(" seed: "); 1035 str->append(" seed: ");
1031 str->appendScalar(fSeed); 1036 str->appendScalar(fSeed);
1032 str->append(" stitch tiles: "); 1037 str->append(" stitch tiles: ");
1033 str->append(fStitchTiles ? "true " : "false "); 1038 str->append(fStitchTiles ? "true " : "false ");
1034 1039
1035 this->INHERITED::toString(str); 1040 this->INHERITED::toString(str);
1036 1041
1037 str->append(")"); 1042 str->append(")");
1038 } 1043 }
1039 #endif 1044 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698