diff options
author | Florin Malita <fmalita@chromium.org> | 2017-05-18 11:52:59 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-18 17:24:39 +0000 |
commit | 14d54c207d7a175d14d34f5527af7cbfd579f4d5 (patch) | |
tree | 9874290e610d098b7c55f2156c126d52eb360f93 /include/effects | |
parent | 94df1841ec695e01ba22c475c011a0a531a20262 (diff) |
Hide SkPerlinNoiseShader impl details
Move the shader impl to a private class, leave SkPerlinNoiseShader as
a factory class only (similar to e.g. SkLightingShader).
Change-Id: Ic1180db8f5dfd3d8f6fba133c6bf6bbdfa4f97a4
Reviewed-on: https://skia-review.googlesource.com/17318
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'include/effects')
-rw-r--r-- | include/effects/SkPerlinNoiseShader.h | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h index a86c89ba39..6c2d7ff5cf 100644 --- a/include/effects/SkPerlinNoiseShader.h +++ b/include/effects/SkPerlinNoiseShader.h @@ -10,6 +10,9 @@ #include "SkShader.h" +struct SkISize; +class SkShader; + /** \class SkPerlinNoiseShader SkPerlinNoiseShader creates an image using the Perlin turbulence function. @@ -22,25 +25,8 @@ The algorithm used is described here : http://www.w3.org/TR/SVG/filters.html#feTurbulenceElement */ -class SK_API SkPerlinNoiseShader : public SkShader { +class SK_API SkPerlinNoiseShader { public: - struct StitchData; - struct PaintingData; - - /** - * About the noise types : the difference between the 2 is just minor tweaks to the algorithm, - * they're not 2 entirely different noises. The output looks different, but once the noise is - * generated in the [1, -1] range, the output is brought back in the [0, 1] range by doing : - * kFractalNoise_Type : noise * 0.5 + 0.5 - * kTurbulence_Type : abs(noise) - * Very little differences between the 2 types, although you can tell the difference visually. - */ - enum Type { - kFractalNoise_Type, - kTurbulence_Type, - kFirstType = kFractalNoise_Type, - kLastType = kTurbulence_Type - }; /** * This will construct Perlin noise of the given type (Fractal Noise or Turbulence). * @@ -62,53 +48,10 @@ public: int numOctaves, SkScalar seed, const SkISize* tileSize = nullptr); - class PerlinNoiseShaderContext : public SkShader::Context { - public: - PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const ContextRec&); - ~PerlinNoiseShaderContext() override; - - void shadeSpan(int x, int y, SkPMColor[], int count) override; - - private: - SkPMColor shade(const SkPoint& point, StitchData& stitchData) const; - SkScalar calculateTurbulenceValueForPoint( - int channel, - StitchData& stitchData, const SkPoint& point) const; - SkScalar noise2D(int channel, - const StitchData& stitchData, const SkPoint& noiseVector) const; - - SkMatrix fMatrix; - PaintingData* fPaintingData; - - typedef SkShader::Context INHERITED; - }; - -#if SK_SUPPORT_GPU - sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override; -#endif - - SK_TO_STRING_OVERRIDE() - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader) - -protected: - void flatten(SkWriteBuffer&) const override; - Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override; + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() private: - SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, - SkScalar baseFrequencyY, int numOctaves, SkScalar seed, - const SkISize* tileSize); - ~SkPerlinNoiseShader() override; - - const SkPerlinNoiseShader::Type fType; - const SkScalar fBaseFrequencyX; - const SkScalar fBaseFrequencyY; - const int fNumOctaves; - const SkScalar fSeed; - const SkISize fTileSize; - const bool fStitchTiles; - - typedef SkShader INHERITED; + SkPerlinNoiseShader() = delete; }; #endif |