skia2/gm/blurredclippedcircle.cpp
reed d053ce9c54 Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #1 id:1 of https://codereview.chromium.org/1821103004/ )
Reason for revert:
guard has now landed in chrome

Original issue's description:
> Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #3 id:40001 of https://codereview.chromium.org/1825073002/ )
>
> Reason for revert:
> CreateModeFilter not compiling
>
> Original issue's description:
> > Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.org/1822623002/ )"
> >
> > Fixed legacy withColorFilter to call new(er) make method
> >
> > This reverts commit 1eb81db650.
> >
> > BUG=skia:
> > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825073002
> >
> > TBR=
> >
> > Committed: https://skia.googlesource.com/skia/+/4c9776b046dd5e9e46e2d1ce35154855c8fcb381
>
> TBR=
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/d6889293dd0942f27f9593f679722c956831f2c4

TBR=
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:

Review URL: https://codereview.chromium.org/1827433002
2016-03-22 10:17:23 -07:00

93 lines
2.9 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkBlurMaskFilter.h"
#include "SkColorFilter.h"
#include "SkPaint.h"
#include "SkRRect.h"
namespace skiagm {
// This GM reproduces the precision artifacts seen in crbug.com/560651.
// It draws a largish blurred circle with its center clipped out.
class BlurredClippedCircleGM : public GM {
public:
BlurredClippedCircleGM() {
this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
}
protected:
SkString onShortName() override {
return SkString("blurredclippedcircle");
}
SkISize onISize() override {
return SkISize::Make(kWidth, kHeight);
}
void onDraw(SkCanvas* canvas) override {
SkPaint whitePaint;
whitePaint.setColor(SK_ColorWHITE);
whitePaint.setXfermode(SkXfermode::Create(SkXfermode::kSrc_Mode))->unref();
whitePaint.setAntiAlias(true);
// This scale exercises precision limits in the circle blur effect (crbug.com/560651)
static const float kScale = 2.0f;
canvas->scale(kScale, kScale);
canvas->save();
SkRect clipRect1 = SkRect::MakeLTRB(0, 0,
SkIntToScalar(kWidth), SkIntToScalar(kHeight));
canvas->clipRect(clipRect1, SkRegion::kIntersect_Op, false);
canvas->save();
canvas->clipRect(clipRect1, SkRegion::kIntersect_Op, false);
canvas->drawRect(clipRect1, whitePaint);
canvas->save();
SkRect clipRect2 = SkRect::MakeLTRB(8, 8, 288, 288);
SkRRect clipRRect = SkRRect::MakeOval(clipRect2);
canvas->clipRRect(clipRRect, SkRegion::kDifference_Op, true);
SkRect r = SkRect::MakeLTRB(4, 4, 292, 292);
SkRRect rr = SkRRect::MakeOval(r);
SkPaint paint;
paint.setMaskFilter(SkBlurMaskFilter::Create(
kNormal_SkBlurStyle,
1.366025f,
SkBlurMaskFilter::kHighQuality_BlurFlag))->unref();
paint.setColorFilter(SkColorFilter::MakeModeFilter(
SK_ColorRED,
SkXfermode::kSrcIn_Mode));
paint.setAntiAlias(true);
canvas->drawRRect(rr, paint);
canvas->restore();
canvas->restore();
canvas->restore();
}
private:
static const int kWidth = 1164;
static const int kHeight = 802;
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new BlurredClippedCircleGM;)
}