OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return true; | 122 return true; |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void onDrawContent(SkCanvas* canvas) override { | 126 void onDrawContent(SkCanvas* canvas) override { |
127 if (!canvas->getTotalMatrix().invert(&fInvMatrix)) { | 127 if (!canvas->getTotalMatrix().invert(&fInvMatrix)) { |
128 return; | 128 return; |
129 } | 129 } |
130 | 130 |
131 SkPaint paint; | 131 SkPaint paint; |
132 | 132 |
133 SkScalar texWidth = fTexScale * TexWidth; | 133 SkScalar texWidth = fTexScale * TexWidth; |
134 SkScalar texHeight = fTexScale * TexHeight; | 134 SkScalar texHeight = fTexScale * TexHeight; |
135 const SkPoint texCoords[SkPatchUtils::kNumCorners] = { | 135 const SkPoint texCoords[SkPatchUtils::kNumCorners] = { |
136 { fTexX - texWidth, fTexY - texHeight}, | 136 { fTexX - texWidth, fTexY - texHeight}, |
137 { fTexX + texWidth, fTexY - texHeight}, | 137 { fTexX + texWidth, fTexY - texHeight}, |
138 { fTexX + texWidth, fTexY + texHeight}, | 138 { fTexX + texWidth, fTexY + texHeight}, |
139 { fTexX - texWidth, fTexY + texHeight}} | 139 { fTexX - texWidth, fTexY + texHeight}} |
140 ; | 140 ; |
141 | 141 |
142 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode))
; | 142 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode))
; |
143 | 143 |
144 SkScalar scaleFreq = 2.0; | 144 SkScalar scaleFreq = 2.0; |
145 fShader1 = SkPerlinNoiseShader2::MakeImprovedNoise(fXFreq/scaleFreq, fYF
req/scaleFreq, 4, | 145 fShader1 = SkPerlinNoiseShader2::MakeImprovedNoise(fXFreq/scaleFreq, fYF
req/scaleFreq, 4, |
146 fSeed); | 146 fSeed); |
147 fShaderCompose = SkShader::MakeComposeShader(fShader0, fShader1, nullptr
); | 147 fShaderCompose = SkShader::MakeComposeShader(fShader0, fShader1, nullptr
); |
148 | 148 |
149 paint.setShader(fShaderCompose); | 149 paint.setShader(fShaderCompose); |
150 canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint); | 150 canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint); |
151 | 151 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 this->inval(nullptr); | 198 this->inval(nullptr); |
199 return true; | 199 return true; |
200 } | 200 } |
201 | 201 |
202 private: | 202 private: |
203 typedef SampleView INHERITED; | 203 typedef SampleView INHERITED; |
204 }; | 204 }; |
205 | 205 |
206 DEF_SAMPLE( return new PerlinPatchView(); ) | 206 DEF_SAMPLE( return new PerlinPatchView(); ) |
207 | |
OLD | NEW |