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

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

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 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/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPictureImageFilter.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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), 959 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth),
960 SkIntToScalar(stitchData.fHeight)); 960 SkIntToScalar(stitchData.fHeight));
961 } 961 }
962 } 962 }
963 963
964 ///////////////////////////////////////////////////////////////////// 964 /////////////////////////////////////////////////////////////////////
965 965
966 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint, 966 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
967 const SkMatrix* externalLocalMatrix, GrCol or* paintColor, 967 const SkMatrix* externalLocalMatrix, GrCol or* paintColor,
968 GrEffect** effect) const { 968 GrEffect** effect) const {
969 SkASSERT(NULL != context); 969 SkASSERT(context);
970 970
971 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); 971 *paintColor = SkColor2GrColorJustAlpha(paint.getColor());
972 972
973 SkMatrix localMatrix = this->getLocalMatrix(); 973 SkMatrix localMatrix = this->getLocalMatrix();
974 if (externalLocalMatrix) { 974 if (externalLocalMatrix) {
975 localMatrix.preConcat(*externalLocalMatrix); 975 localMatrix.preConcat(*externalLocalMatrix);
976 } 976 }
977 977
978 SkMatrix matrix = context->getMatrix(); 978 SkMatrix matrix = context->getMatrix();
979 matrix.preConcat(localMatrix); 979 matrix.preConcat(localMatrix);
(...skipping 14 matching lines...) Expand all
994 994
995 SkPerlinNoiseShader::PaintingData* paintingData = SkNEW_ARGS(PaintingData, ( fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix)); 995 SkPerlinNoiseShader::PaintingData* paintingData = SkNEW_ARGS(PaintingData, ( fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix));
996 GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture( 996 GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture(
997 context, paintingData->getPermutationsBitmap(), NULL); 997 context, paintingData->getPermutationsBitmap(), NULL);
998 GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture( 998 GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture(
999 context, paintingData->getNoiseBitmap(), NULL); 999 context, paintingData->getNoiseBitmap(), NULL);
1000 1000
1001 SkMatrix m = context->getMatrix(); 1001 SkMatrix m = context->getMatrix();
1002 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1); 1002 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
1003 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); 1003 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
1004 if ((NULL != permutationsTexture) && (NULL != noiseTexture)) { 1004 if ((permutationsTexture) && (noiseTexture)) {
1005 *effect = GrPerlinNoiseEffect::Create(fType, 1005 *effect = GrPerlinNoiseEffect::Create(fType,
1006 fNumOctaves, 1006 fNumOctaves,
1007 fStitchTiles, 1007 fStitchTiles,
1008 paintingData, 1008 paintingData,
1009 permutationsTexture, noiseTextur e, 1009 permutationsTexture, noiseTextur e,
1010 m, paint.getAlpha()); 1010 m, paint.getAlpha());
1011 } else { 1011 } else {
1012 SkDELETE(paintingData); 1012 SkDELETE(paintingData);
1013 *effect = NULL; 1013 *effect = NULL;
1014 } 1014 }
1015 1015
1016 // Unlock immediately, this is not great, but we don't have a way of 1016 // Unlock immediately, this is not great, but we don't have a way of
1017 // knowing when else to unlock it currently. TODO: Remove this when 1017 // knowing when else to unlock it currently. TODO: Remove this when
1018 // unref becomes the unlock replacement for all types of textures. 1018 // unref becomes the unlock replacement for all types of textures.
1019 if (NULL != permutationsTexture) { 1019 if (permutationsTexture) {
1020 GrUnlockAndUnrefCachedBitmapTexture(permutationsTexture); 1020 GrUnlockAndUnrefCachedBitmapTexture(permutationsTexture);
1021 } 1021 }
1022 if (NULL != noiseTexture) { 1022 if (noiseTexture) {
1023 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture); 1023 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture);
1024 } 1024 }
1025 1025
1026 return true; 1026 return true;
1027 } 1027 }
1028 1028
1029 #else 1029 #else
1030 1030
1031 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint, 1031 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
1032 const SkMatrix* externalLocalMatrix, GrCol or* paintColor, 1032 const SkMatrix* externalLocalMatrix, GrCol or* paintColor,
(...skipping 29 matching lines...) Expand all
1062 str->append(" seed: "); 1062 str->append(" seed: ");
1063 str->appendScalar(fSeed); 1063 str->appendScalar(fSeed);
1064 str->append(" stitch tiles: "); 1064 str->append(" stitch tiles: ");
1065 str->append(fStitchTiles ? "true " : "false "); 1065 str->append(fStitchTiles ? "true " : "false ");
1066 1066
1067 this->INHERITED::toString(str); 1067 this->INHERITED::toString(str);
1068 1068
1069 str->append(")"); 1069 str->append(")");
1070 } 1070 }
1071 #endif 1071 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698