OLD | NEW |
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 #ifndef SkPerlinNoiseShader_DEFINED | 8 #ifndef SkPerlinNoiseShader_DEFINED |
9 #define SkPerlinNoiseShader_DEFINED | 9 #define SkPerlinNoiseShader_DEFINED |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 * Create alias for CreateTurbulunce until all Skia users changed | 65 * Create alias for CreateTurbulunce until all Skia users changed |
66 * its code to use the new naming | 66 * its code to use the new naming |
67 */ | 67 */ |
68 static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequ
encyY, | 68 static SkShader* CreateTubulence(SkScalar baseFrequencyX, SkScalar baseFrequ
encyY, |
69 int numOctaves, SkScalar seed, | 69 int numOctaves, SkScalar seed, |
70 const SkISize* tileSize = NULL) { | 70 const SkISize* tileSize = NULL) { |
71 return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, ti
leSize); | 71 return CreateTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, ti
leSize); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 virtual size_t contextSize() const SK_OVERRIDE; | 75 size_t contextSize() const SK_OVERRIDE; |
76 | 76 |
77 class PerlinNoiseShaderContext : public SkShader::Context { | 77 class PerlinNoiseShaderContext : public SkShader::Context { |
78 public: | 78 public: |
79 PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const Contex
tRec&); | 79 PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const Contex
tRec&); |
80 virtual ~PerlinNoiseShaderContext(); | 80 virtual ~PerlinNoiseShaderContext(); |
81 | 81 |
82 virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE
; | 82 void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; |
83 virtual void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRID
E; | 83 void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRIDE; |
84 | 84 |
85 private: | 85 private: |
86 SkPMColor shade(const SkPoint& point, StitchData& stitchData) const; | 86 SkPMColor shade(const SkPoint& point, StitchData& stitchData) const; |
87 SkScalar calculateTurbulenceValueForPoint( | 87 SkScalar calculateTurbulenceValueForPoint( |
88 int channel, | 88 int channel, |
89 StitchData& stitchData, const SkPoint& point) const; | 89 StitchData& stitchData, const SkPoint& point) const; |
90 SkScalar noise2D(int channel, | 90 SkScalar noise2D(int channel, |
91 const StitchData& stitchData, const SkPoint& noiseVecto
r) const; | 91 const StitchData& stitchData, const SkPoint& noiseVecto
r) const; |
92 | 92 |
93 SkMatrix fMatrix; | 93 SkMatrix fMatrix; |
94 PaintingData* fPaintingData; | 94 PaintingData* fPaintingData; |
95 | 95 |
96 typedef SkShader::Context INHERITED; | 96 typedef SkShader::Context INHERITED; |
97 }; | 97 }; |
98 | 98 |
99 virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const S
kMatrix& viewM, | 99 virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const S
kMatrix& viewM, |
100 const SkMatrix*, GrColor*, | 100 const SkMatrix*, GrColor*, |
101 GrFragmentProcessor**) const SK_OVERRIDE; | 101 GrFragmentProcessor**) const SK_OVERRIDE; |
102 | 102 |
103 SK_TO_STRING_OVERRIDE() | 103 SK_TO_STRING_OVERRIDE() |
104 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader) | 104 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader) |
105 | 105 |
106 protected: | 106 protected: |
107 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 107 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
108 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; | 108 Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE
; |
109 | 109 |
110 private: | 110 private: |
111 SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, | 111 SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, |
112 SkScalar baseFrequencyY, int numOctaves, SkScalar seed, | 112 SkScalar baseFrequencyY, int numOctaves, SkScalar seed, |
113 const SkISize* tileSize); | 113 const SkISize* tileSize); |
114 virtual ~SkPerlinNoiseShader(); | 114 virtual ~SkPerlinNoiseShader(); |
115 | 115 |
116 const SkPerlinNoiseShader::Type fType; | 116 const SkPerlinNoiseShader::Type fType; |
117 const SkScalar fBaseFrequencyX; | 117 const SkScalar fBaseFrequencyX; |
118 const SkScalar fBaseFrequencyY; | 118 const SkScalar fBaseFrequencyY; |
119 const int fNumOctaves; | 119 const int fNumOctaves; |
120 const SkScalar fSeed; | 120 const SkScalar fSeed; |
121 const SkISize fTileSize; | 121 const SkISize fTileSize; |
122 const bool fStitchTiles; | 122 const bool fStitchTiles; |
123 | 123 |
124 typedef SkShader INHERITED; | 124 typedef SkShader INHERITED; |
125 }; | 125 }; |
126 | 126 |
127 #endif | 127 #endif |
OLD | NEW |