aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-18 11:54:13 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-18 11:54:14 -0800
commit341400ea7ba0f711ac4c6ead0b33c5c89b4ac55c (patch)
treedde081719c8f4fb45827157600860f21deca364d
parentcecb093334e5985d1e114e59cb1388428fef18b2 (diff)
I could create new GMs if you prefer.
-rw-r--r--expectations/gm/ignored-tests.txt2
-rw-r--r--gm/blurrect.cpp38
-rw-r--r--gm/blurroundrect.cpp66
3 files changed, 89 insertions, 17 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index b87402f9d5..5ee655fcb7 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -53,6 +53,8 @@ modecolorfilters
#joshualitt
bleed
+blurrects
+simpleblurroundrect
#humper skia:2049
dashcubics
diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp
index 768e798210..49ef856c64 100644
--- a/gm/blurrect.cpp
+++ b/gm/blurrect.cpp
@@ -55,6 +55,31 @@ static void draw_donut_skewed(SkCanvas* canvas, const SkRect& r, const SkPaint&
#include "SkGradientShader.h"
+/*
+ * Spits out a dummy gradient to test blur with shader on paint
+ */
+static SkShader* MakeRadial() {
+ SkPoint pts[2] = {
+ { 0, 0 },
+ { SkIntToScalar(100), SkIntToScalar(100) }
+ };
+ SkShader::TileMode tm = SkShader::kClamp_TileMode;
+ const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, };
+ const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
+ SkMatrix scale;
+ scale.setScale(0.5f, 0.5f);
+ scale.postTranslate(25.f, 25.f);
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointRadial(center1, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ colors, pos, SK_ARRAY_COUNT(colors), tm,
+ 0, &scale);
+}
+
typedef void (*PaintProc)(SkPaint*, SkScalar width);
class BlurRectGM : public skiagm::GM {
@@ -81,7 +106,7 @@ protected:
}
virtual SkISize onISize() {
- return SkISize::Make(440, 820);
+ return SkISize::Make(860, 820);
}
virtual void onDraw(SkCanvas* canvas) {
@@ -97,6 +122,9 @@ protected:
paint.setMaskFilter(fMaskFilters[f]);
paint.setAlpha(fAlpha);
+ SkPaint paintWithRadial = paint;
+ paintWithRadial.setShader(MakeRadial())->unref();
+
static const Proc procs[] = {
fill_rect, draw_donut, draw_donut_skewed
};
@@ -105,17 +133,21 @@ protected:
canvas->scale(scales[s], scales[s]);
this->drawProcs(canvas, r, paint, false, procs, SK_ARRAY_COUNT(procs));
canvas->translate(r.width() * 4/3, 0);
+ this->drawProcs(canvas, r, paintWithRadial, false, procs, SK_ARRAY_COUNT(procs));
+ canvas->translate(r.width() * 4/3, 0);
this->drawProcs(canvas, r, paint, true, procs, SK_ARRAY_COUNT(procs));
+ canvas->translate(r.width() * 4/3, 0);
+ this->drawProcs(canvas, r, paintWithRadial, true, procs, SK_ARRAY_COUNT(procs));
canvas->restore();
canvas->translate(0, SK_ARRAY_COUNT(procs) * r.height() * 4/3 * scales[s]);
}
canvas->restore();
- canvas->translate(2 * r.width() * 4/3 * scales[s], 0);
+ canvas->translate(4 * r.width() * 4/3 * scales[s], 0);
}
}
- virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; }
+ virtual uint32_t onGetFlags() const { return kSkipPipe_Flag | kSkipTiled_Flag; }
private:
void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint,
diff --git a/gm/blurroundrect.cpp b/gm/blurroundrect.cpp
index d78335f2a6..1819ac2edd 100644
--- a/gm/blurroundrect.cpp
+++ b/gm/blurroundrect.cpp
@@ -92,6 +92,32 @@ private:
typedef skiagm::GM INHERITED;
};
+#include "SkGradientShader.h"
+/*
+ * Spits out a dummy gradient to test blur with shader on paint
+ */
+static SkShader* MakeRadial() {
+ SkPoint pts[2] = {
+ { 0, 0 },
+ { SkIntToScalar(100), SkIntToScalar(100) }
+ };
+ SkShader::TileMode tm = SkShader::kClamp_TileMode;
+ const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, };
+ const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
+ SkMatrix scale;
+ scale.setScale(0.5f, 0.5f);
+ scale.postTranslate(5.f, 5.f);
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointRadial(center1, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ colors, pos, SK_ARRAY_COUNT(colors), tm,
+ 0, &scale);
+}
+
// Simpler blurred RR test cases where all the radii are the same.
class SimpleBlurRoundRectGM : public skiagm::GM {
public:
@@ -100,12 +126,16 @@ public:
}
protected:
+ virtual uint32_t onGetFlags() const SK_OVERRIDE {
+ return kSkipTiled_Flag;
+ }
+
virtual SkString onShortName() SK_OVERRIDE {
return fName;
}
virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(950, 950);
+ return SkISize::Make(1000, 500);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
@@ -114,23 +144,31 @@ protected:
const float blurRadii[] = { 1,5,10,20 };
const int cornerRadii[] = { 1,5,10,20 };
- const SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
+ const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25));
for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
SkAutoCanvasRestore autoRestore(canvas, true);
canvas->translate(0, (r.height() + SkIntToScalar(50)) * i);
for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) {
- SkMaskFilter* filter = SkBlurMaskFilter::Create(
- kNormal_SkBlurStyle,
- SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
- SkBlurMaskFilter::kHighQuality_BlurFlag);
- SkPaint paint;
- paint.setColor(SK_ColorBLACK);
- paint.setMaskFilter(filter)->unref();
-
- SkRRect rrect;
- rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), SkIntToScalar(cornerRadii[j]));
- canvas->drawRRect(rrect, paint);
- canvas->translate(r.width() + SkIntToScalar(50), 0);
+ for (int k = 0; k <= 1; k++) {
+ SkMaskFilter* filter = SkBlurMaskFilter::Create(
+ kNormal_SkBlurStyle,
+ SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
+ SkBlurMaskFilter::kHighQuality_BlurFlag);
+ SkPaint paint;
+ paint.setColor(SK_ColorBLACK);
+ paint.setMaskFilter(filter)->unref();
+
+ bool useRadial = SkToBool(k);
+ if (useRadial) {
+ paint.setShader(MakeRadial())->unref();
+ }
+
+ SkRRect rrect;
+ rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]),
+ SkIntToScalar(cornerRadii[j]));
+ canvas->drawRRect(rrect, paint);
+ canvas->translate(r.width() + SkIntToScalar(50), 0);
+ }
}
}
}