update with tests for blur

git-svn-id: http://skia.googlecode.com/svn/trunk@357 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@android.com 2009-09-18 20:57:05 +00:00
parent 0e3c664250
commit da449a38a2
2 changed files with 56 additions and 5 deletions

View File

@ -64,13 +64,32 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
drawBG(canvas);
SkMaskFilter* mf = SkBlurMaskFilter::Create(20, SkBlurMaskFilter::kOuter_BlurStyle);
SkBlurMaskFilter::BlurStyle NONE = SkBlurMaskFilter::BlurStyle(-999);
static const struct {
SkBlurMaskFilter::BlurStyle fStyle;
int fCx, fCy;
} gRecs[] = {
{ NONE, 0, 0 },
{ SkBlurMaskFilter::kInner_BlurStyle, -1, 0 },
{ SkBlurMaskFilter::kNormal_BlurStyle, 0, 1 },
{ SkBlurMaskFilter::kSolid_BlurStyle, 0, -1 },
{ SkBlurMaskFilter::kOuter_BlurStyle, 1, 0 },
};
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorBLUE);
canvas->drawCircle(100, 100, 50, paint);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
if (gRecs[i].fStyle != NONE) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(20, gRecs[i].fStyle);
paint.setMaskFilter(mf)->unref();
canvas->drawCircle(200, 100, 50, paint);
} else {
paint.setMaskFilter(NULL);
}
canvas->drawCircle(200 + gRecs[i].fCx*100,
200 + gRecs[i].fCy*100, 50, paint);
}
}
private:

View File

@ -5,6 +5,8 @@
#include "SkRandom.h"
#include "SkView.h"
#include "SkBlurMaskFilter.h"
static void scale_to_width(SkPath* path, SkScalar dstWidth) {
const SkRect& bounds = path->getBounds();
SkScalar scale = dstWidth / bounds.width();
@ -83,6 +85,36 @@ protected:
SkPaint paint;
paint.setAntiAlias(true);
if (true) {
canvas->drawColor(SK_ColorBLACK);
paint.setTextSize(24);
paint.setColor(SK_ColorWHITE);
canvas->translate(10, 30);
static const SkBlurMaskFilter::BlurStyle gStyle[] = {
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMaskFilter::kInner_BlurStyle,
SkBlurMaskFilter::kOuter_BlurStyle,
SkBlurMaskFilter::kSolid_BlurStyle,
};
for (int x = 0; x < 5; x++) {
SkMaskFilter* mf;
SkScalar radius = 4;
for (int y = 0; y < 10; y++) {
if (x) {
mf = SkBlurMaskFilter::Create(radius, gStyle[x - 1]);
paint.setMaskFilter(mf)->unref();
}
canvas->drawText("Title Bar", 9, x*100, y*30, paint);
radius *= 0.75f;
}
}
return;
}
paint.setColor(SK_ColorBLUE);
#if 1