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

Unified Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 169973002: Begin making SkPerlinNoiseShader const. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make methods const and simplify const comments. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: src/effects/SkPerlinNoiseShader.cpp
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 47de924b997e41b34bf902ee1174f7313e514cfe..209993bd13a95eb112cacbe43fc76cbc20ff9b36 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -22,8 +22,8 @@
#include "SkGr.h"
#endif
-static const int kBlockSize = 256;
-static const int kBlockMask = kBlockSize - 1;
+const int SkPerlinNoiseShader::kBlockSize;
+const int SkPerlinNoiseShader::kBlockMask;
static const int kPerlinNoise = 4096;
static const int kRandMaximum = SK_MaxS32; // 2**31 - 1
@@ -59,207 +59,150 @@ bool perlin_noise_type_is_valid(SkPerlinNoiseShader::Type type) {
} // end namespace
-struct SkPerlinNoiseShader::StitchData {
- StitchData()
- : fWidth(0)
- , fWrapX(0)
- , fHeight(0)
- , fWrapY(0)
- {}
-
- bool operator==(const StitchData& other) const {
- return fWidth == other.fWidth &&
- fWrapX == other.fWrapX &&
- fHeight == other.fHeight &&
- fWrapY == other.fWrapY;
- }
-
- int fWidth; // How much to subtract to wrap for stitching.
- int fWrapX; // Minimum value to wrap.
- int fHeight;
- int fWrapY;
-};
-
-struct SkPerlinNoiseShader::PaintingData {
- PaintingData(const SkISize& tileSize)
- : fSeed(0)
- , fTileSize(tileSize)
- , fPermutationsBitmap(NULL)
- , fNoiseBitmap(NULL)
- {}
+inline int random(int* seed) {
+ static const int gRandAmplitude = 16807; // 7**5; primitive root of m
+ static const int gRandQ = 127773; // m / a
+ static const int gRandR = 2836; // m % a
- ~PaintingData()
- {
- SkDELETE(fPermutationsBitmap);
- SkDELETE(fNoiseBitmap);
+ int result = gRandAmplitude * (*seed % gRandQ) - gRandR * (*seed / gRandQ);
+ if (result <= 0) {
+ result += kRandMaximum;
}
+ *seed = result;
+ return result;
+}
- int fSeed;
- uint8_t fLatticeSelector[kBlockSize];
- uint16_t fNoise[4][kBlockSize][2];
- SkPoint fGradient[4][kBlockSize];
- SkISize fTileSize;
- SkVector fBaseFrequency;
- StitchData fStitchDataInit;
-
-private:
-
- SkBitmap* fPermutationsBitmap;
- SkBitmap* fNoiseBitmap;
-
-public:
-
- inline int random() {
- static const int gRandAmplitude = 16807; // 7**5; primitive root of m
- static const int gRandQ = 127773; // m / a
- static const int gRandR = 2836; // m % a
+// Only called once. Could be part of the constructor.
+void SkPerlinNoiseShader::init()
+{
+ static const SkScalar gInvBlockSizef = SkScalarInvert(SkIntToScalar(kBlockSize));
- int result = gRandAmplitude * (fSeed % gRandQ) - gRandR * (fSeed / gRandQ);
- if (result <= 0)
- result += kRandMaximum;
- fSeed = result;
- return result;
+ // The seed value clamp to the range [1, kRandMaximum - 1].
+ if (fSeed <= 0) {
+ fSeed = -(fSeed % (kRandMaximum - 1)) + 1;
}
-
- void init(SkScalar seed)
- {
- static const SkScalar gInvBlockSizef = SkScalarInvert(SkIntToScalar(kBlockSize));
-
- // According to the SVG spec, we must truncate (not round) the seed value.
- fSeed = SkScalarTruncToInt(seed);
- // The seed value clamp to the range [1, kRandMaximum - 1].
- if (fSeed <= 0) {
- fSeed = -(fSeed % (kRandMaximum - 1)) + 1;
- }
- if (fSeed > kRandMaximum - 1) {
- fSeed = kRandMaximum - 1;
- }
- for (int channel = 0; channel < 4; ++channel) {
- for (int i = 0; i < kBlockSize; ++i) {
- fLatticeSelector[i] = i;
- fNoise[channel][i][0] = (random() % (2 * kBlockSize));
- fNoise[channel][i][1] = (random() % (2 * kBlockSize));
- }
- }
- for (int i = kBlockSize - 1; i > 0; --i) {
- int k = fLatticeSelector[i];
- int j = random() % kBlockSize;
- SkASSERT(j >= 0);
- SkASSERT(j < kBlockSize);
- fLatticeSelector[i] = fLatticeSelector[j];
- fLatticeSelector[j] = k;
+ if (fSeed > kRandMaximum - 1) {
+ fSeed = kRandMaximum - 1;
+ }
+ for (int channel = 0; channel < 4; ++channel) {
+ for (int i = 0; i < kBlockSize; ++i) {
+ fLatticeSelector[i] = i;
+ fNoise[channel][i][0] = (random(&fSeed) % (2 * kBlockSize));
+ fNoise[channel][i][1] = (random(&fSeed) % (2 * kBlockSize));
}
+ }
+ for (int i = kBlockSize - 1; i > 0; --i) {
+ int k = fLatticeSelector[i];
+ int j = random(&fSeed) % kBlockSize;
+ SkASSERT(j >= 0);
+ SkASSERT(j < kBlockSize);
+ fLatticeSelector[i] = fLatticeSelector[j];
+ fLatticeSelector[j] = k;
+ }
- // Perform the permutations now
- {
- // Copy noise data
- uint16_t noise[4][kBlockSize][2];
- for (int i = 0; i < kBlockSize; ++i) {
- for (int channel = 0; channel < 4; ++channel) {
- for (int j = 0; j < 2; ++j) {
- noise[channel][i][j] = fNoise[channel][i][j];
- }
+ // Perform the permutations now
+ {
+ // Copy noise data
+ uint16_t noise[4][kBlockSize][2];
+ for (int i = 0; i < kBlockSize; ++i) {
+ for (int channel = 0; channel < 4; ++channel) {
+ for (int j = 0; j < 2; ++j) {
+ noise[channel][i][j] = fNoise[channel][i][j];
}
}
- // Do permutations on noise data
- for (int i = 0; i < kBlockSize; ++i) {
- for (int channel = 0; channel < 4; ++channel) {
- for (int j = 0; j < 2; ++j) {
+ }
+ // Do permutations on noise data
+ for (int i = 0; i < kBlockSize; ++i) {
+ for (int channel = 0; channel < 4; ++channel) {
+ for (int j = 0; j < 2; ++j) {
fNoise[channel][i][j] = noise[channel][fLatticeSelector[i]][j];
- }
}
}
}
+ }
- // Half of the largest possible value for 16 bit unsigned int
- static const SkScalar gHalfMax16bits = 32767.5f;
+ // Half of the largest possible value for 16 bit unsigned int
+ static const SkScalar gHalfMax16bits = 32767.5f;
- // Compute gradients from permutated noise data
- for (int channel = 0; channel < 4; ++channel) {
- for (int i = 0; i < kBlockSize; ++i) {
- fGradient[channel][i] = SkPoint::Make(
+ // Compute gradients from permutated noise data
+ for (int channel = 0; channel < 4; ++channel) {
+ for (int i = 0; i < kBlockSize; ++i) {
+ fGradient[channel][i] = SkPoint::Make(
SkScalarMul(SkIntToScalar(fNoise[channel][i][0] - kBlockSize),
gInvBlockSizef),
SkScalarMul(SkIntToScalar(fNoise[channel][i][1] - kBlockSize),
gInvBlockSizef));
- fGradient[channel][i].normalize();
+ fGradient[channel][i].normalize();
// Put the normalized gradient back into the noise data
- fNoise[channel][i][0] = SkScalarRoundToInt(SkScalarMul(
+ fNoise[channel][i][0] = SkScalarRoundToInt(SkScalarMul(
fGradient[channel][i].fX + SK_Scalar1, gHalfMax16bits));
- fNoise[channel][i][1] = SkScalarRoundToInt(SkScalarMul(
+ fNoise[channel][i][1] = SkScalarRoundToInt(SkScalarMul(
fGradient[channel][i].fY + SK_Scalar1, gHalfMax16bits));
- }
}
+ }
- // Invalidate bitmaps
- SkDELETE(fPermutationsBitmap);
- fPermutationsBitmap = NULL;
- SkDELETE(fNoiseBitmap);
- fNoiseBitmap = NULL;
+ if (fTileSize.isEmpty()) {
scroggo 2014/03/04 22:26:34 stitch() is now part of init.
+ return;
}
- void stitch() {
- SkScalar tileWidth = SkIntToScalar(fTileSize.width());
- SkScalar tileHeight = SkIntToScalar(fTileSize.height());
- SkASSERT(tileWidth > 0 && tileHeight > 0);
- // When stitching tiled turbulence, the frequencies must be adjusted
- // so that the tile borders will be continuous.
- if (fBaseFrequency.fX) {
- SkScalar lowFrequencx =
+ SkScalar tileWidth = SkIntToScalar(fTileSize.width());
+ SkScalar tileHeight = SkIntToScalar(fTileSize.height());
+ SkASSERT(tileWidth > 0 && tileHeight > 0);
+ // When stitching tiled turbulence, the frequencies must be adjusted
+ // so that the tile borders will be continuous.
+ if (fBaseFrequency.fX) {
+ SkScalar lowFrequencx =
SkScalarFloorToScalar(tileWidth * fBaseFrequency.fX) / tileWidth;
- SkScalar highFrequencx =
+ SkScalar highFrequencx =
SkScalarCeilToScalar(tileWidth * fBaseFrequency.fX) / tileWidth;
- // BaseFrequency should be non-negative according to the standard.
- if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) <
+ // BaseFrequency should be non-negative according to the standard.
+ if (SkScalarDiv(fBaseFrequency.fX, lowFrequencx) <
SkScalarDiv(highFrequencx, fBaseFrequency.fX)) {
- fBaseFrequency.fX = lowFrequencx;
- } else {
- fBaseFrequency.fX = highFrequencx;
- }
+ fBaseFrequency.fX = lowFrequencx;
+ } else {
+ fBaseFrequency.fX = highFrequencx;
}
- if (fBaseFrequency.fY) {
- SkScalar lowFrequency =
+ }
+ if (fBaseFrequency.fY) {
+ SkScalar lowFrequency =
SkScalarFloorToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
- SkScalar highFrequency =
+ SkScalar highFrequency =
SkScalarCeilToScalar(tileHeight * fBaseFrequency.fY) / tileHeight;
- if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
+ if (SkScalarDiv(fBaseFrequency.fY, lowFrequency) <
SkScalarDiv(highFrequency, fBaseFrequency.fY)) {
- fBaseFrequency.fY = lowFrequency;
- } else {
- fBaseFrequency.fY = highFrequency;
- }
+ fBaseFrequency.fY = lowFrequency;
+ } else {
+ fBaseFrequency.fY = highFrequency;
}
- // Set up TurbulenceInitial stitch values.
- fStitchDataInit.fWidth =
+ }
+ // Set up TurbulenceInitial stitch values.
+ fStitchDataInit.fWidth =
SkScalarRoundToInt(tileWidth * fBaseFrequency.fX);
- fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
- fStitchDataInit.fHeight =
+ fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
+ fStitchDataInit.fHeight =
SkScalarRoundToInt(tileHeight * fBaseFrequency.fY);
- fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
- }
+ fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
+}
- SkBitmap* getPermutationsBitmap()
- {
- if (!fPermutationsBitmap) {
- fPermutationsBitmap = SkNEW(SkBitmap);
- fPermutationsBitmap->allocPixels(SkImageInfo::MakeA8(kBlockSize, 1));
- uint8_t* bitmapPixels = fPermutationsBitmap->getAddr8(0, 0);
- memcpy(bitmapPixels, fLatticeSelector, sizeof(uint8_t) * kBlockSize);
- }
- return fPermutationsBitmap;
+const SkBitmap& SkPerlinNoiseShader::getPermutationsBitmap() const {
+ if (kUnknown_SkColorType == fPermutationsBitmap.colorType()) {
+ // initialize the cache.
+ fPermutationsBitmap.allocPixels(SkImageInfo::MakeA8(kBlockSize, 1));
+ uint8_t* bitmapPixels = fPermutationsBitmap.getAddr8(0, 0);
+ memcpy(bitmapPixels, fLatticeSelector, sizeof(uint8_t) * kBlockSize);
}
+ return fPermutationsBitmap;
+}
- SkBitmap* getNoiseBitmap()
- {
- if (!fNoiseBitmap) {
- fNoiseBitmap = SkNEW(SkBitmap);
- fNoiseBitmap->allocPixels(SkImageInfo::MakeN32Premul(kBlockSize, 4));
- uint32_t* bitmapPixels = fNoiseBitmap->getAddr32(0, 0);
- memcpy(bitmapPixels, fNoise[0][0], sizeof(uint16_t) * kBlockSize * 4 * 2);
- }
- return fNoiseBitmap;
+const SkBitmap& SkPerlinNoiseShader::getNoiseBitmap() const {
+ if (kUnknown_SkColorType == fNoiseBitmap.colorType()) {
+ // initialize the cache.
+ fNoiseBitmap.allocPixels(SkImageInfo::MakeN32Premul(kBlockSize, 4));
+ uint32_t* bitmapPixels = fNoiseBitmap.getAddr32(0, 0);
+ memcpy(bitmapPixels, fNoise[0][0], sizeof(uint16_t) * kBlockSize * 4 * 2);
}
-};
+ return fNoiseBitmap;
+}
SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkScalar baseFrequencyY,
int numOctaves, SkScalar seed,
@@ -282,84 +225,48 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type,
SkScalar seed,
const SkISize* tileSize)
: fType(type)
- , fBaseFrequencyX(baseFrequencyX)
- , fBaseFrequencyY(baseFrequencyY)
+ , fBaseFrequency(SkPoint::Make(baseFrequencyX, baseFrequencyY))
, fNumOctaves(numOctaves > 255 ? 255 : numOctaves/*[0,255] octaves allowed*/)
- , fSeed(seed)
- , fStitchTiles((tileSize != NULL) && !tileSize->isEmpty())
- , fPaintingData(NULL)
+ // According to the SVG spec, we must truncate (not round) the seed value.
+ , fSeed(SkScalarTruncToInt(seed))
+ , fTileSize(NULL == tileSize ? SkISize::Make(0, 0) : *tileSize)
+ , fStitchTiles(!fTileSize.isEmpty())
{
SkASSERT(numOctaves >= 0 && numOctaves < 256);
- setTileSize(fStitchTiles ? *tileSize : SkISize::Make(0,0));
fMatrix.reset();
+ this->init();
}
-SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer) :
- INHERITED(buffer), fPaintingData(NULL) {
+SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer)
+ : INHERITED(buffer)
+{
fType = (SkPerlinNoiseShader::Type) buffer.readInt();
- fBaseFrequencyX = buffer.readScalar();
- fBaseFrequencyY = buffer.readScalar();
+ buffer.readPoint(&fBaseFrequency);
fNumOctaves = buffer.readInt();
- fSeed = buffer.readScalar();
+ fSeed = buffer.readInt();
Stephen White 2014/03/05 14:32:58 Hmmm. Isn't this going to require an SkPicture ver
sugoi 2014/03/05 16:50:33 Hmmm... In this const shader world, is there no wa
scroggo 2014/03/05 18:24:05 What do you mean by "later on during processing?"
scroggo 2014/03/05 18:24:05 Yes, this would require a picture version bump. In
fStitchTiles = buffer.readBool();
fTileSize.fWidth = buffer.readInt();
fTileSize.fHeight = buffer.readInt();
- setTileSize(fTileSize);
fMatrix.reset();
+ this->init();
buffer.validate(perlin_noise_type_is_valid(fType) &&
- (fNumOctaves >= 0) && (fNumOctaves <= 255));
-}
-
-SkPerlinNoiseShader::~SkPerlinNoiseShader() {
- // Safety, should have been done in endContext()
- SkDELETE(fPaintingData);
+ (fNumOctaves >= 0) && (fNumOctaves <= 255) &&
+ (fStitchTiles != fTileSize.isEmpty()));
}
void SkPerlinNoiseShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeInt((int) fType);
- buffer.writeScalar(fBaseFrequencyX);
- buffer.writeScalar(fBaseFrequencyY);
+ buffer.writePoint(fBaseFrequency);
buffer.writeInt(fNumOctaves);
- buffer.writeScalar(fSeed);
+ buffer.writeInt(fSeed);
buffer.writeBool(fStitchTiles);
buffer.writeInt(fTileSize.fWidth);
buffer.writeInt(fTileSize.fHeight);
}
-void SkPerlinNoiseShader::initPaint(PaintingData& paintingData)
-{
- paintingData.init(fSeed);
-
- // Set frequencies to original values
- paintingData.fBaseFrequency.set(fBaseFrequencyX, fBaseFrequencyY);
- // Adjust frequecies based on size if stitching is enabled
- if (fStitchTiles) {
- paintingData.stitch();
- }
-}
-
-void SkPerlinNoiseShader::setTileSize(const SkISize& tileSize) {
- fTileSize = tileSize;
-
- if (NULL == fPaintingData) {
- fPaintingData = SkNEW_ARGS(PaintingData, (fTileSize));
- initPaint(*fPaintingData);
- } else {
- // Set Size
- fPaintingData->fTileSize = fTileSize;
- // Set frequencies to original values
- fPaintingData->fBaseFrequency.set(fBaseFrequencyX, fBaseFrequencyY);
- // Adjust frequecies based on size if stitching is enabled
- if (fStitchTiles) {
- fPaintingData->stitch();
- }
- }
-}
-
-SkScalar SkPerlinNoiseShader::noise2D(int channel, const PaintingData& paintingData,
- const StitchData& stitchData, const SkPoint& noiseVector)
-{
+SkScalar SkPerlinNoiseShader::noise2D(int channel, const StitchData& stitchData,
+ const SkPoint& noiseVector) const {
struct Noise {
int noisePositionIntegerValue;
SkScalar noisePositionFractionValue;
@@ -382,42 +289,39 @@ SkScalar SkPerlinNoiseShader::noise2D(int channel, const PaintingData& paintingD
}
noiseX.noisePositionIntegerValue &= kBlockMask;
noiseY.noisePositionIntegerValue &= kBlockMask;
- int latticeIndex =
- paintingData.fLatticeSelector[noiseX.noisePositionIntegerValue] +
- noiseY.noisePositionIntegerValue;
- int nextLatticeIndex =
- paintingData.fLatticeSelector[(noiseX.noisePositionIntegerValue + 1) & kBlockMask] +
- noiseY.noisePositionIntegerValue;
+ int latticeIndex = fLatticeSelector[noiseX.noisePositionIntegerValue] +
+ noiseY.noisePositionIntegerValue;
+ int nextLatticeIndex = fLatticeSelector[(noiseX.noisePositionIntegerValue + 1) & kBlockMask] +
+ noiseY.noisePositionIntegerValue;
SkScalar sx = smoothCurve(noiseX.noisePositionFractionValue);
SkScalar sy = smoothCurve(noiseY.noisePositionFractionValue);
// This is taken 1:1 from SVG spec: http://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement
SkPoint fractionValue = SkPoint::Make(noiseX.noisePositionFractionValue,
noiseY.noisePositionFractionValue); // Offset (0,0)
- u = paintingData.fGradient[channel][latticeIndex & kBlockMask].dot(fractionValue);
+ u = fGradient[channel][latticeIndex & kBlockMask].dot(fractionValue);
fractionValue.fX -= SK_Scalar1; // Offset (-1,0)
- v = paintingData.fGradient[channel][nextLatticeIndex & kBlockMask].dot(fractionValue);
+ v = fGradient[channel][nextLatticeIndex & kBlockMask].dot(fractionValue);
SkScalar a = SkScalarInterp(u, v, sx);
fractionValue.fY -= SK_Scalar1; // Offset (-1,-1)
- v = paintingData.fGradient[channel][(nextLatticeIndex + 1) & kBlockMask].dot(fractionValue);
+ v = fGradient[channel][(nextLatticeIndex + 1) & kBlockMask].dot(fractionValue);
fractionValue.fX = noiseX.noisePositionFractionValue; // Offset (0,-1)
- u = paintingData.fGradient[channel][(latticeIndex + 1) & kBlockMask].dot(fractionValue);
+ u = fGradient[channel][(latticeIndex + 1) & kBlockMask].dot(fractionValue);
SkScalar b = SkScalarInterp(u, v, sx);
return SkScalarInterp(a, b, sy);
}
-SkScalar SkPerlinNoiseShader::calculateTurbulenceValueForPoint(
- int channel, const PaintingData& paintingData, StitchData& stitchData, const SkPoint& point)
-{
+SkScalar SkPerlinNoiseShader::calculateTurbulenceValueForPoint(int channel, StitchData& stitchData,
+ const SkPoint& point) const {
if (fStitchTiles) {
// Set up TurbulenceInitial stitch values.
- stitchData = paintingData.fStitchDataInit;
+ stitchData = fStitchDataInit;
}
SkScalar turbulenceFunctionResult = 0;
- SkPoint noiseVector(SkPoint::Make(SkScalarMul(point.x(), paintingData.fBaseFrequency.fX),
- SkScalarMul(point.y(), paintingData.fBaseFrequency.fY)));
+ SkPoint noiseVector(SkPoint::Make(SkScalarMul(point.x(), fBaseFrequency.fX),
+ SkScalarMul(point.y(), fBaseFrequency.fY)));
SkScalar ratio = SK_Scalar1;
for (int octave = 0; octave < fNumOctaves; ++octave) {
- SkScalar noise = noise2D(channel, paintingData, stitchData, noiseVector);
+ SkScalar noise = noise2D(channel, stitchData, noiseVector);
turbulenceFunctionResult += SkScalarDiv(
(fType == kFractalNoise_Type) ? noise : SkScalarAbs(noise), ratio);
noiseVector.fX *= 2;
@@ -448,7 +352,7 @@ SkScalar SkPerlinNoiseShader::calculateTurbulenceValueForPoint(
return SkScalarPin(turbulenceFunctionResult, 0, SK_Scalar1);
}
-SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchData) {
+SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchData) const {
SkMatrix matrix = fMatrix;
matrix.postConcat(getLocalMatrix());
SkMatrix invMatrix;
@@ -469,7 +373,7 @@ SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchDat
U8CPU rgba[4];
for (int channel = 3; channel >= 0; --channel) {
rgba[channel] = SkScalarFloorToInt(255 *
- calculateTurbulenceValueForPoint(channel, *fPaintingData, stitchData, newPoint));
+ calculateTurbulenceValueForPoint(channel, stitchData, newPoint));
}
return SkPreMultiplyARGB(rgba[3], rgba[0], rgba[1], rgba[2]);
}
@@ -1321,19 +1225,19 @@ GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint&
// Simplex noise is currently disabled but can be enabled by defining SK_USE_SIMPLEX_NOISE
sk_ignore_unused_variable(context);
GrEffectRef* effect =
- GrSimplexNoiseEffect::Create(fType, fPaintingData->fBaseFrequency,
+ GrSimplexNoiseEffect::Create(fType, fBaseFrequency,
fNumOctaves, fStitchTiles, fSeed,
this->getLocalMatrix(), paint.getAlpha());
#else
GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture(
- context, *fPaintingData->getPermutationsBitmap(), NULL);
+ context, this->getPermutationsBitmap(), NULL);
GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture(
- context, *fPaintingData->getNoiseBitmap(), NULL);
+ context, this->getNoiseBitmap(), NULL);
GrEffectRef* effect = (NULL != permutationsTexture) && (NULL != noiseTexture) ?
- GrPerlinNoiseEffect::Create(fType, fPaintingData->fBaseFrequency,
+ GrPerlinNoiseEffect::Create(fType, fBaseFrequency,
fNumOctaves, fStitchTiles,
- fPaintingData->fStitchDataInit,
+ fStitchDataInit,
permutationsTexture, noiseTexture,
this->getLocalMatrix(), paint.getAlpha()) :
NULL;
@@ -1378,13 +1282,13 @@ void SkPerlinNoiseShader::toString(SkString* str) const {
break;
}
str->append(" base frequency: (");
- str->appendScalar(fBaseFrequencyX);
+ str->appendScalar(fBaseFrequency.fX);
str->append(", ");
- str->appendScalar(fBaseFrequencyY);
+ str->appendScalar(fBaseFrequency.fY);
str->append(") number of octaves: ");
str->appendS32(fNumOctaves);
str->append(" seed: ");
- str->appendScalar(fSeed);
+ str->appendS32(fSeed);
str->append(" stitch tiles: ");
str->append(fStitchTiles ? "true " : "false ");
« include/effects/SkPerlinNoiseShader.h ('K') | « include/effects/SkPerlinNoiseShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698