Perlin issue fixed

BUG=skia:1799
R=sugoi@chromium.org, sugoi@google.com, senorblanco@chromium.org

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/59173005

git-svn-id: http://skia.googlecode.com/svn/trunk@12150 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-11-06 10:08:38 +00:00
parent 6e3e42296b
commit c2a0ea6418
3 changed files with 27 additions and 9 deletions

View File

@ -71,3 +71,6 @@ imagefilterscropped
imagefiltersbase
imageblur
colorfilterimagefilter
# Added by sugoi in https://codereview.chromium.org/59173005
perlinnoise

View File

@ -23,7 +23,7 @@ protected:
}
virtual SkISize onISize() {
return make_isize(200, 400);
return make_isize(200, 500);
}
void drawClippedRect(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
@ -52,27 +52,31 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
canvas->clear(0x00000000);
test(canvas, 0, 0, SkPerlinNoiseShader::kFractalNoise_Type,
0.1f, 0.1f, 0, 0, false);
test(canvas, 100, 0, SkPerlinNoiseShader::kTurbulence_Type,
0.1f, 0.1f, 0, 0, false);
test(canvas, 0, 0, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 0, 100, SkPerlinNoiseShader::kFractalNoise_Type,
0.1f, 0.1f, 2, 0, false);
test(canvas, 100, 0, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 100, 100, SkPerlinNoiseShader::kFractalNoise_Type,
0.2f, 0.4f, 5, 0, true);
test(canvas, 0, 100, SkPerlinNoiseShader::kTurbulence_Type,
test(canvas, 0, 200, SkPerlinNoiseShader::kTurbulence_Type,
0.1f, 0.1f, 2, 0, true);
test(canvas, 100, 100, SkPerlinNoiseShader::kTurbulence_Type,
test(canvas, 100, 200, SkPerlinNoiseShader::kTurbulence_Type,
0.2f, 0.4f, 5, 0, false);
test(canvas, 0, 200, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 0, 300, SkPerlinNoiseShader::kFractalNoise_Type,
0.1f, 0.1f, 3, 1, false);
test(canvas, 100, 200, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 100, 300, SkPerlinNoiseShader::kFractalNoise_Type,
0.1f, 0.1f, 3, 4, false);
canvas->scale(SkFloatToScalar(0.75f), SkFloatToScalar(1.0f));
test(canvas, 0, 300, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 0, 400, SkPerlinNoiseShader::kFractalNoise_Type,
0.1f, 0.1f, 2, 0, false);
test(canvas, 100, 300, SkPerlinNoiseShader::kFractalNoise_Type,
test(canvas, 100, 400, SkPerlinNoiseShader::kFractalNoise_Type,
0.2f, 0.4f, 5, 0, true);
}

View File

@ -7,6 +7,7 @@
#include "SkDither.h"
#include "SkPerlinNoiseShader.h"
#include "SkColorFilter.h"
#include "SkFlattenableBuffers.h"
#include "SkShader.h"
#include "SkUnPreMultiply.h"
@ -1295,6 +1296,16 @@ void GrGLSimplexNoise::setData(const GrGLUniformManager& uman, const GrDrawEffec
GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint) const {
SkASSERT(NULL != context);
if (0 == fNumOctaves) {
SkColor clearColor = 0;
if (kFractalNoise_Type == fType) {
clearColor = SkColorSetARGB(paint.getAlpha() / 2, 127, 127, 127);
}
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(
clearColor, SkXfermode::kSrc_Mode));
return cf->asNewEffect(context);
}
// Either we don't stitch tiles, either we have a valid tile size
SkASSERT(!fStitchTiles || !fTileSize.isEmpty());