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

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

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo Created 6 years, 2 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/core/SkImageFilter.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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 clearColor, SkXfermode::kSrc_Mod e)); 990 clearColor, SkXfermode::kSrc_Mod e));
991 *fp = cf->asFragmentProcessor(context); 991 *fp = cf->asFragmentProcessor(context);
992 return true; 992 return true;
993 } 993 }
994 994
995 // Either we don't stitch tiles, either we have a valid tile size 995 // Either we don't stitch tiles, either we have a valid tile size
996 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); 996 SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
997 997
998 SkPerlinNoiseShader::PaintingData* paintingData = 998 SkPerlinNoiseShader::PaintingData* paintingData =
999 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix)); 999 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix));
1000 GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture( 1000 SkAutoTUnref<GrTexture> permutationsTexture(
1001 context, paintingData->getPermutationsBitmap(), NULL); 1001 GrRefCachedBitmapTexture(context, paintingData->getPermutationsBitmap(), NULL));
1002 GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture( 1002 SkAutoTUnref<GrTexture> noiseTexture(
1003 context, paintingData->getNoiseBitmap(), NULL); 1003 GrRefCachedBitmapTexture(context, paintingData->getNoiseBitmap(), NULL)) ;
1004 1004
1005 SkMatrix m = context->getMatrix(); 1005 SkMatrix m = context->getMatrix();
1006 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1); 1006 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
1007 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); 1007 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
1008 if ((permutationsTexture) && (noiseTexture)) { 1008 if ((permutationsTexture) && (noiseTexture)) {
1009 *fp = GrPerlinNoiseEffect::Create(fType, 1009 *fp = GrPerlinNoiseEffect::Create(fType,
1010 fNumOctaves, 1010 fNumOctaves,
1011 fStitchTiles, 1011 fStitchTiles,
1012 paintingData, 1012 paintingData,
1013 permutationsTexture, noiseTexture, 1013 permutationsTexture, noiseTexture,
1014 m, paint.getAlpha()); 1014 m, paint.getAlpha());
1015 } else { 1015 } else {
1016 SkDELETE(paintingData); 1016 SkDELETE(paintingData);
1017 *fp = NULL; 1017 *fp = NULL;
1018 } 1018 }
1019
1020 // Unlock immediately, this is not great, but we don't have a way of
1021 // knowing when else to unlock it currently. TODO: Remove this when
1022 // unref becomes the unlock replacement for all types of textures.
1023 if (permutationsTexture) {
1024 GrUnlockAndUnrefCachedBitmapTexture(permutationsTexture);
1025 }
1026 if (noiseTexture) {
1027 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture);
1028 }
1029
1030 return true; 1019 return true;
1031 } 1020 }
1032 1021
1033 #else 1022 #else
1034 1023
1035 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, 1024 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
1036 GrFragmentProcessor**) const { 1025 GrFragmentProcessor**) const {
1037 SkDEBUGFAIL("Should not call in GPU-less build"); 1026 SkDEBUGFAIL("Should not call in GPU-less build");
1038 return false; 1027 return false;
1039 } 1028 }
(...skipping 25 matching lines...) Expand all
1065 str->append(" seed: "); 1054 str->append(" seed: ");
1066 str->appendScalar(fSeed); 1055 str->appendScalar(fSeed);
1067 str->append(" stitch tiles: "); 1056 str->append(" stitch tiles: ");
1068 str->append(fStitchTiles ? "true " : "false "); 1057 str->append(fStitchTiles ? "true " : "false ");
1069 1058
1070 this->INHERITED::toString(str); 1059 this->INHERITED::toString(str);
1071 1060
1072 str->append(")"); 1061 str->append(")");
1073 } 1062 }
1074 #endif 1063 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698