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

Unified Diff: samplecode/PerlinPatch.cpp

Issue 1410863006: Update sample to use new perlin noise shader, and make cloud like (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 1 month 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
« no previous file with comments | « gyp/SampleApp.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/PerlinPatch.cpp
diff --git a/samplecode/PerlinPatch.cpp b/samplecode/PerlinPatch.cpp
index 9f86f1f21764234bf3182a8f5b32686322410125..945b6921fe09b71c7a0dc40eff361d9595371f63 100644
--- a/samplecode/PerlinPatch.cpp
+++ b/samplecode/PerlinPatch.cpp
@@ -10,7 +10,7 @@
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkPatchUtils.h"
-#include "SkPerlinNoiseShader.h"
+#include "SkPerlinNoiseShader2/SkPerlinNoiseShader2.h"
#include "SkComposeShader.h"
static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) {
@@ -94,25 +94,21 @@ public:
fPts[11].set(150, 150);
const SkColor colors[SkPatchUtils::kNumCorners] = {
- SK_ColorBLUE, SK_ColorYELLOW
+ 0xFF5555FF, 0xFF8888FF, 0xFFCCCCFF
};
-
- fShader0 = SkGradientShader::CreateRadial(SkPoint::Make(128.0f, 128.0f),
- 180.0f,
+ const SkPoint points[2] = { SkPoint::Make(0.0f, 0.0f),
+ SkPoint::Make(100.0f, 100.0f) };
+ fShader0 = SkGradientShader::CreateLinear(points,
colors,
NULL,
- 2,
+ 3,
SkShader::kMirror_TileMode,
0,
NULL);
- fShader1 = SkPerlinNoiseShader::CreateTurbulence(fXFreq, fYFreq, 2, fSeed, NULL);
- fShaderCompose = new SkComposeShader(fShader0, fShader1);
}
virtual ~PerlinPatchView() {
SkSafeUnref(fShader0);
- SkSafeUnref(fShader1);
- SkSafeUnref(fShaderCompose);
}
protected:
// overrides from SkEventSink
@@ -125,6 +121,7 @@ protected:
}
bool onAnimate(const SkAnimTimer& timer) override {
+ fSeed += 0.005f;
return true;
}
@@ -147,10 +144,17 @@ protected:
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kSrc_Mode));
+ SkScalar scaleFreq = 2.0;
+ fShader1 = SkPerlinNoiseShader2::CreateImprovedNoise(fXFreq/scaleFreq, fYFreq/scaleFreq, 4,
+ fSeed);
+ fShaderCompose = new SkComposeShader(fShader0, fShader1);
+
paint.setShader(fShaderCompose);
canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint);
draw_control_points(canvas, fPts);
+ SkSafeUnref(fShader1);
+ SkSafeUnref(fShaderCompose);
}
class PtClick : public Click {
« no previous file with comments | « gyp/SampleApp.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698