skia2/gm/emboss.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

62 lines
1.5 KiB
C++

/*
* Copyright 2014 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 "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorFilter.h"
static SkBitmap make_bm() {
SkBitmap bm;
bm.allocN32Pixels(100, 100);
SkCanvas canvas(bm);
canvas.clear(0);
SkPaint paint;
paint.setAntiAlias(true);
canvas.drawCircle(50, 50, 50, paint);
return bm;
}
class EmbossGM : public skiagm::GM {
public:
EmbossGM() {
}
protected:
SkString onShortName() override {
return SkString("emboss");
}
SkISize onISize() override {
return SkISize::Make(600, 120);
}
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
SkBitmap bm = make_bm();
canvas->drawBitmap(bm, 10, 10, &paint);
const SkScalar dir[] = { 1, 1, 1 };
paint.setMaskFilter(SkBlurMaskFilter::CreateEmboss(3, dir, 0.3f, 0.1f))->unref();
canvas->translate(bm.width() + SkIntToScalar(10), 0);
canvas->drawBitmap(bm, 10, 10, &paint);
// this combination of emboss+colorfilter used to crash -- so we exercise it to
// confirm that we have a fix.
paint.setColorFilter(SkColorFilter::MakeModeFilter(0xFFFF0000, SkXfermode::kSrcATop_Mode));
canvas->translate(bm.width() + SkIntToScalar(10), 0);
canvas->drawBitmap(bm, 10, 10, &paint);
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM(return new EmbossGM;)