| 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" |
| 11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
| 12 #include "SkPatchUtils.h" | 12 #include "SkPatchUtils.h" |
| 13 #include "SkPerlinNoiseShader2/SkPerlinNoiseShader2.h" | 13 #include "SkPerlinNoiseShader2/SkPerlinNoiseShader2.h" |
| 14 #include "SkComposeShader.h" | |
| 15 | 14 |
| 16 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) { | 15 static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) { |
| 17 //draw control points | 16 //draw control points |
| 18 SkPaint paint; | 17 SkPaint paint; |
| 19 SkPoint bottom[SkPatchUtils::kNumPtsCubic]; | 18 SkPoint bottom[SkPatchUtils::kNumPtsCubic]; |
| 20 SkPatchUtils::getBottomCubic(cubics, bottom); | 19 SkPatchUtils::getBottomCubic(cubics, bottom); |
| 21 SkPoint top[SkPatchUtils::kNumPtsCubic]; | 20 SkPoint top[SkPatchUtils::kNumPtsCubic]; |
| 22 SkPatchUtils::getTopCubic(cubics, top); | 21 SkPatchUtils::getTopCubic(cubics, top); |
| 23 SkPoint left[SkPatchUtils::kNumPtsCubic]; | 22 SkPoint left[SkPatchUtils::kNumPtsCubic]; |
| 24 SkPatchUtils::getLeftCubic(cubics, left); | 23 SkPatchUtils::getLeftCubic(cubics, left); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 { fTexX + texWidth, fTexY - texHeight}, | 140 { fTexX + texWidth, fTexY - texHeight}, |
| 142 { fTexX + texWidth, fTexY + texHeight}, | 141 { fTexX + texWidth, fTexY + texHeight}, |
| 143 { fTexX - texWidth, fTexY + texHeight}} | 142 { fTexX - texWidth, fTexY + texHeight}} |
| 144 ; | 143 ; |
| 145 | 144 |
| 146 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode))
; | 145 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode))
; |
| 147 | 146 |
| 148 SkScalar scaleFreq = 2.0; | 147 SkScalar scaleFreq = 2.0; |
| 149 fShader1 = SkPerlinNoiseShader2::CreateImprovedNoise(fXFreq/scaleFreq, f
YFreq/scaleFreq, 4, | 148 fShader1 = SkPerlinNoiseShader2::CreateImprovedNoise(fXFreq/scaleFreq, f
YFreq/scaleFreq, 4, |
| 150 fSeed); | 149 fSeed); |
| 151 fShaderCompose = new SkComposeShader(fShader0, fShader1); | 150 fShaderCompose = SkShader::CreateComposeShader(fShader0, fShader1, nullp
tr); |
| 152 | 151 |
| 153 paint.setShader(fShaderCompose); | 152 paint.setShader(fShaderCompose); |
| 154 canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint); | 153 canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint); |
| 155 | 154 |
| 156 draw_control_points(canvas, fPts); | 155 draw_control_points(canvas, fPts); |
| 157 SkSafeUnref(fShader1); | 156 SkSafeUnref(fShader1); |
| 158 SkSafeUnref(fShaderCompose); | 157 SkSafeUnref(fShaderCompose); |
| 159 } | 158 } |
| 160 | 159 |
| 161 class PtClick : public Click { | 160 class PtClick : public Click { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 this->inval(nullptr); | 203 this->inval(nullptr); |
| 205 return true; | 204 return true; |
| 206 } | 205 } |
| 207 | 206 |
| 208 private: | 207 private: |
| 209 typedef SampleView INHERITED; | 208 typedef SampleView INHERITED; |
| 210 }; | 209 }; |
| 211 | 210 |
| 212 DEF_SAMPLE( return new PerlinPatchView(); ) | 211 DEF_SAMPLE( return new PerlinPatchView(); ) |
| 213 | 212 |
| OLD | NEW |