Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints"
This reverts commit c245574ba3
.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2396953002
TBR=
Review-Url: https://codereview.chromium.org/2396953002
This commit is contained in:
parent
61c21cdcc3
commit
374772bd61
@ -85,7 +85,7 @@ private:
|
||||
class SrcModeRectBench : public RectBench {
|
||||
public:
|
||||
SrcModeRectBench() : INHERITED(1, 0) {
|
||||
fMode = SkXfermode::Make(SkXfermode::kSrc_Mode);
|
||||
fMode = SkBlendMode::kSrc;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -93,7 +93,7 @@ protected:
|
||||
this->INHERITED::setupPaint(paint);
|
||||
// srcmode is most interesting when we're not opaque
|
||||
paint->setAlpha(0x80);
|
||||
paint->setXfermode(fMode);
|
||||
paint->setBlendMode(fMode);
|
||||
}
|
||||
|
||||
const char* onGetName() override {
|
||||
@ -103,8 +103,8 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SkString fName;
|
||||
sk_sp<SkXfermode> fMode;
|
||||
SkString fName;
|
||||
SkBlendMode fMode;
|
||||
|
||||
typedef RectBench INHERITED;
|
||||
};
|
||||
|
@ -67,7 +67,7 @@ static SkString to_lower(const char* str) {
|
||||
|
||||
class RotRectBench: public Benchmark {
|
||||
public:
|
||||
RotRectBench(bool aa, ColorType ct, SkXfermode::Mode mode)
|
||||
RotRectBench(bool aa, ColorType ct, SkBlendMode mode)
|
||||
: fAA(aa)
|
||||
, fColorType(ct)
|
||||
, fMode(mode) {
|
||||
@ -80,7 +80,7 @@ protected:
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(fAA);
|
||||
paint.setXfermodeMode(fMode);
|
||||
paint.setBlendMode(fMode);
|
||||
SkColor color = start_color(fColorType);
|
||||
|
||||
int w = this->getSize().x();
|
||||
@ -147,48 +147,48 @@ private:
|
||||
fName.appendf("_%s", to_lower(SkXfermode::ModeName(fMode)).c_str());
|
||||
}
|
||||
|
||||
bool fAA;
|
||||
ColorType fColorType;
|
||||
SkXfermode::Mode fMode;
|
||||
SkString fName;
|
||||
bool fAA;
|
||||
ColorType fColorType;
|
||||
SkBlendMode fMode;
|
||||
SkString fName;
|
||||
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
// Choose kSrcOver because it always allows coverage and alpha to be conflated. kSrc only allows
|
||||
// conflation when opaque, and kDarken because it isn't possilbe with standard GL blending.
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kSrcOver_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kSrcOver);)
|
||||
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kSrc_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kSrc);)
|
||||
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantOpaque_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(true, kConstantTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingOpaque_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(true, kChangingTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(true, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkXfermode::kDarken_Mode);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantOpaque_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(false, kConstantTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingOpaque_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(false, kChangingTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
DEF_BENCH(return new RotRectBench(false, kAlternatingOpaqueAndTransparent_ColorType, SkBlendMode::kDarken);)
|
||||
|
@ -15,10 +15,8 @@
|
||||
// Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
|
||||
class XfermodeBench : public Benchmark {
|
||||
public:
|
||||
XfermodeBench(SkXfermode::Mode mode, bool aa) {
|
||||
fXfermode = SkXfermode::Make(mode);
|
||||
XfermodeBench(SkBlendMode mode, bool aa) : fBlendMode(mode) {
|
||||
fAA = aa;
|
||||
SkASSERT(fXfermode.get() || SkXfermode::kSrcOver_Mode == mode);
|
||||
fName.printf("Xfermode_%s%s", SkXfermode::ModeName(mode), aa ? "_aa" : "");
|
||||
}
|
||||
|
||||
@ -32,7 +30,7 @@ protected:
|
||||
SkRandom random;
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
SkPaint paint;
|
||||
paint.setXfermode(fXfermode);
|
||||
paint.setBlendMode(fBlendMode);
|
||||
paint.setColor(random.nextU());
|
||||
if (fAA) {
|
||||
// Draw text to exercise AA code paths.
|
||||
@ -61,71 +59,48 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkXfermode> fXfermode;
|
||||
SkString fName;
|
||||
bool fAA;
|
||||
SkBlendMode fBlendMode;
|
||||
SkString fName;
|
||||
bool fAA;
|
||||
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
class XferCreateBench : public Benchmark {
|
||||
public:
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
return backend == kNonRendering_Backend;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override { return "xfermode_create"; }
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
for (int outer = 0; outer < loops * 10; ++outer) {
|
||||
for (int i = 0; i <= SkXfermode::kLastMode; ++i) {
|
||||
(void)SkXfermode::Make(SkXfermode::Mode(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BENCH(...) \
|
||||
DEF_BENCH( return new XfermodeBench(__VA_ARGS__, true); ) \
|
||||
DEF_BENCH( return new XfermodeBench(__VA_ARGS__, false); )
|
||||
|
||||
BENCH(SkXfermode::kClear_Mode)
|
||||
BENCH(SkXfermode::kSrc_Mode)
|
||||
BENCH(SkXfermode::kDst_Mode)
|
||||
BENCH(SkXfermode::kSrcOver_Mode)
|
||||
BENCH(SkXfermode::kDstOver_Mode)
|
||||
BENCH(SkXfermode::kSrcIn_Mode)
|
||||
BENCH(SkXfermode::kDstIn_Mode)
|
||||
BENCH(SkXfermode::kSrcOut_Mode)
|
||||
BENCH(SkXfermode::kDstOut_Mode)
|
||||
BENCH(SkXfermode::kSrcATop_Mode)
|
||||
BENCH(SkXfermode::kDstATop_Mode)
|
||||
BENCH(SkXfermode::kXor_Mode)
|
||||
BENCH(SkBlendMode::kClear)
|
||||
BENCH(SkBlendMode::kSrc)
|
||||
BENCH(SkBlendMode::kDst)
|
||||
BENCH(SkBlendMode::kSrcOver)
|
||||
BENCH(SkBlendMode::kDstOver)
|
||||
BENCH(SkBlendMode::kSrcIn)
|
||||
BENCH(SkBlendMode::kDstIn)
|
||||
BENCH(SkBlendMode::kSrcOut)
|
||||
BENCH(SkBlendMode::kDstOut)
|
||||
BENCH(SkBlendMode::kSrcATop)
|
||||
BENCH(SkBlendMode::kDstATop)
|
||||
BENCH(SkBlendMode::kXor)
|
||||
|
||||
BENCH(SkXfermode::kPlus_Mode)
|
||||
BENCH(SkXfermode::kModulate_Mode)
|
||||
BENCH(SkXfermode::kScreen_Mode)
|
||||
BENCH(SkBlendMode::kPlus)
|
||||
BENCH(SkBlendMode::kModulate)
|
||||
BENCH(SkBlendMode::kScreen)
|
||||
|
||||
BENCH(SkXfermode::kOverlay_Mode)
|
||||
BENCH(SkXfermode::kDarken_Mode)
|
||||
BENCH(SkXfermode::kLighten_Mode)
|
||||
BENCH(SkXfermode::kColorDodge_Mode)
|
||||
BENCH(SkXfermode::kColorBurn_Mode)
|
||||
BENCH(SkXfermode::kHardLight_Mode)
|
||||
BENCH(SkXfermode::kSoftLight_Mode)
|
||||
BENCH(SkXfermode::kDifference_Mode)
|
||||
BENCH(SkXfermode::kExclusion_Mode)
|
||||
BENCH(SkXfermode::kMultiply_Mode)
|
||||
BENCH(SkBlendMode::kOverlay)
|
||||
BENCH(SkBlendMode::kDarken)
|
||||
BENCH(SkBlendMode::kLighten)
|
||||
BENCH(SkBlendMode::kColorDodge)
|
||||
BENCH(SkBlendMode::kColorBurn)
|
||||
BENCH(SkBlendMode::kHardLight)
|
||||
BENCH(SkBlendMode::kSoftLight)
|
||||
BENCH(SkBlendMode::kDifference)
|
||||
BENCH(SkBlendMode::kExclusion)
|
||||
BENCH(SkBlendMode::kMultiply)
|
||||
|
||||
BENCH(SkXfermode::kHue_Mode)
|
||||
BENCH(SkXfermode::kSaturation_Mode)
|
||||
BENCH(SkXfermode::kColor_Mode)
|
||||
BENCH(SkXfermode::kLuminosity_Mode)
|
||||
|
||||
DEF_BENCH(return new XferCreateBench;)
|
||||
BENCH(SkBlendMode::kHue)
|
||||
BENCH(SkBlendMode::kSaturation)
|
||||
BENCH(SkBlendMode::kColor)
|
||||
BENCH(SkBlendMode::kLuminosity)
|
||||
|
@ -1454,7 +1454,7 @@ Error ViaUpright::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkSt
|
||||
SkCanvas canvas(uprighted);
|
||||
canvas.concat(upright);
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
canvas.drawBitmap(*bitmap, 0, 0, &paint);
|
||||
|
||||
*bitmap = uprighted;
|
||||
|
@ -154,8 +154,8 @@ static SkMatrix make_matrix() {
|
||||
return m;
|
||||
}
|
||||
|
||||
static SkXfermode::Mode make_xfermode() {
|
||||
return static_cast<SkXfermode::Mode>(R(SkXfermode::kLastMode+1));
|
||||
static SkBlendMode make_blendmode() {
|
||||
return static_cast<SkBlendMode>(R((int)SkBlendMode::kLastMode+1));
|
||||
}
|
||||
|
||||
static SkPaint::Align make_paint_align() {
|
||||
@ -369,7 +369,7 @@ static sk_sp<SkColorFilter> make_color_filter() {
|
||||
return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
|
||||
}
|
||||
case 3:
|
||||
return SkColorFilter::MakeModeFilter(make_color(), make_xfermode());
|
||||
return SkColorFilter::MakeModeFilter(make_color(), (SkXfermode::Mode)make_blendmode());
|
||||
case 4:
|
||||
return SkColorMatrixFilter::MakeLightingFilter(make_color(), make_color());
|
||||
case 5:
|
||||
@ -505,7 +505,7 @@ static SkPaint make_paint() {
|
||||
paint.setStrokeCap(make_paint_cap());
|
||||
paint.setStrokeJoin(make_paint_join());
|
||||
paint.setColorFilter(make_color_filter());
|
||||
paint.setXfermodeMode(make_xfermode());
|
||||
paint.setBlendMode(make_blendmode());
|
||||
paint.setPathEffect(make_path_effect());
|
||||
paint.setMaskFilter(make_mask_filter());
|
||||
|
||||
@ -540,7 +540,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
|
||||
}
|
||||
|
||||
enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER,
|
||||
XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE,
|
||||
BLENDMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE,
|
||||
DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
|
||||
MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS };
|
||||
|
||||
@ -554,7 +554,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
|
||||
case MERGE:
|
||||
filter = SkMergeImageFilter::Make(make_image_filter(),
|
||||
make_image_filter(),
|
||||
make_xfermode());
|
||||
(SkXfermode::Mode)make_blendmode());
|
||||
break;
|
||||
case COLOR: {
|
||||
sk_sp<SkColorFilter> cf(make_color_filter());
|
||||
@ -580,8 +580,8 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
|
||||
make_scalar(true),
|
||||
make_image_filter());
|
||||
break;
|
||||
case XFERMODE:
|
||||
filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()),
|
||||
case BLENDMODE:
|
||||
filter = SkXfermodeImageFilter::Make(make_blendmode(),
|
||||
make_image_filter(),
|
||||
make_image_filter(),
|
||||
nullptr);
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
static void do_draw(SkCanvas* canvas, const SkRect& r) {
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
paint.setColor(0x800000FF);
|
||||
canvas->drawRect(r, paint);
|
||||
}
|
||||
|
@ -59,21 +59,21 @@ static void test4(SkCanvas* canvas) {
|
||||
}
|
||||
|
||||
constexpr struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
};
|
||||
|
||||
const int gWidth = 64;
|
||||
@ -81,7 +81,7 @@ const int gHeight = 64;
|
||||
const SkScalar W = SkIntToScalar(gWidth);
|
||||
const SkScalar H = SkIntToScalar(gHeight);
|
||||
|
||||
static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) {
|
||||
static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
@ -95,7 +95,7 @@ static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, S
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setAlpha(a1);
|
||||
paint.setXfermode(std::move(mode));
|
||||
paint.setBlendMode(mode);
|
||||
|
||||
SkScalar offset = SK_Scalar1 / 3;
|
||||
SkRect rect = SkRect::MakeXYWH(W / 4 + offset,
|
||||
@ -155,7 +155,7 @@ namespace skiagm {
|
||||
}
|
||||
canvas->drawRect(bounds, fBGPaint);
|
||||
canvas->saveLayer(&bounds, nullptr);
|
||||
SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode),
|
||||
SkScalar dy = drawCell(canvas, gModes[i].fMode,
|
||||
gAlphaValue[alpha & 1],
|
||||
gAlphaValue[alpha & 2]);
|
||||
canvas->restore();
|
||||
|
@ -121,7 +121,7 @@ protected:
|
||||
if (firstMode + m > SkXfermode::kLastMode) {
|
||||
break;
|
||||
}
|
||||
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(firstMode + m);
|
||||
SkBlendMode mode = static_cast<SkBlendMode>(firstMode + m);
|
||||
canvas->save();
|
||||
|
||||
if (kShape_Pass == drawingPass) {
|
||||
@ -144,7 +144,7 @@ protected:
|
||||
10);
|
||||
} else {
|
||||
SkASSERT(kBackground_Pass == drawingPass);
|
||||
canvas->drawColor(kBGColor, SkXfermode::kSrc_Mode);
|
||||
canvas->drawColor(kBGColor, SkBlendMode::kSrc);
|
||||
}
|
||||
canvas->restore();
|
||||
} else {
|
||||
@ -190,18 +190,17 @@ protected:
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
void drawModeName(SkCanvas* canvas, SkXfermode::Mode mode) {
|
||||
const char* modeName = mode <= SkXfermode::kLastMode ? SkXfermode::ModeName(mode)
|
||||
: "Arithmetic";
|
||||
void drawModeName(SkCanvas* canvas, SkBlendMode mode) {
|
||||
const char* modeName = SkXfermode::ModeName(mode);
|
||||
fLabelPaint.setTextAlign(SkPaint::kRight_Align);
|
||||
canvas->drawText(modeName, strlen(modeName), kLabelSpacing - kShapeSize / 4,
|
||||
fLabelPaint.getTextSize() / 4, fLabelPaint);
|
||||
}
|
||||
|
||||
void setupShapePaint(SkCanvas* canvas, GrColor color, SkXfermode::Mode mode, SkPaint* paint) {
|
||||
void setupShapePaint(SkCanvas* canvas, GrColor color, SkBlendMode mode, SkPaint* paint) {
|
||||
paint->setColor(color);
|
||||
|
||||
if (mode == SkXfermode::kPlus_Mode) {
|
||||
if (mode == SkBlendMode::kPlus) {
|
||||
// Check for overflow, otherwise we might get confusing AA artifacts.
|
||||
int maxSum = SkTMax(SkTMax(SkColorGetA(kBGColor) + SkColorGetA(color),
|
||||
SkColorGetR(kBGColor) + SkColorGetR(color)),
|
||||
@ -211,7 +210,7 @@ protected:
|
||||
if (maxSum > 255) {
|
||||
SkPaint dimPaint;
|
||||
dimPaint.setAntiAlias(false);
|
||||
dimPaint.setXfermodeMode(SkXfermode::kDstIn_Mode);
|
||||
dimPaint.setBlendMode(SkBlendMode::kDstIn);
|
||||
if (255 != paint->getAlpha()) {
|
||||
// Dim the src and dst colors.
|
||||
dimPaint.setARGB(255 * 255 / maxSum, 0, 0, 0);
|
||||
@ -227,11 +226,11 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void drawShape(SkCanvas* canvas, Shape shape, const SkPaint& paint, SkXfermode::Mode mode) {
|
||||
SkASSERT(mode <= SkXfermode::kLastMode);
|
||||
void drawShape(SkCanvas* canvas, Shape shape, const SkPaint& paint, SkBlendMode mode) {
|
||||
SkASSERT(mode <= SkBlendMode::kLastMode);
|
||||
SkPaint shapePaint(paint);
|
||||
shapePaint.setAntiAlias(kSquare_Shape != shape);
|
||||
shapePaint.setXfermodeMode(mode);
|
||||
shapePaint.setBlendMode(mode);
|
||||
|
||||
switch (shape) {
|
||||
case kSquare_Shape:
|
||||
@ -249,7 +248,7 @@ protected:
|
||||
|
||||
case kOval_Shape:
|
||||
canvas->save();
|
||||
canvas->rotate(static_cast<SkScalar>((511 * mode + 257) % 360));
|
||||
canvas->rotate(static_cast<SkScalar>((511 * (int)mode + 257) % 360));
|
||||
canvas->drawPath(fOval, shapePaint);
|
||||
canvas->restore();
|
||||
break;
|
||||
|
@ -201,7 +201,7 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
paint.setAlpha(128);
|
||||
paint.setXfermode(SkXfermode::Make(SkXfermode::kXor_Mode));
|
||||
paint.setBlendMode(SkBlendMode::kXor);
|
||||
|
||||
SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f };
|
||||
SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f };
|
||||
|
@ -34,7 +34,7 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkPaint whitePaint;
|
||||
whitePaint.setColor(SK_ColorWHITE);
|
||||
whitePaint.setXfermode(SkXfermode::Make(SkXfermode::kSrc_Mode));
|
||||
whitePaint.setBlendMode(SkBlendMode::kSrc);
|
||||
whitePaint.setAntiAlias(true);
|
||||
|
||||
// This scale exercises precision limits in the circle blur effect (crbug.com/560651)
|
||||
|
@ -77,7 +77,7 @@ protected:
|
||||
SkPaint paint;
|
||||
SkColorMatrix matrix;
|
||||
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
const SkImage* bmps[] = { fSolidImg.get(), fTransparentImg.get() };
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(bmps); ++i) {
|
||||
|
@ -57,39 +57,39 @@ protected:
|
||||
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
||||
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkXfermode::kPlus_Mode, "Plus" },
|
||||
{ SkXfermode::kModulate_Mode, "Modulate" },
|
||||
{ SkXfermode::kScreen_Mode, "Screen" },
|
||||
{ SkXfermode::kOverlay_Mode, "Overlay" },
|
||||
{ SkXfermode::kDarken_Mode, "Darken" },
|
||||
{ SkXfermode::kLighten_Mode, "Lighten" },
|
||||
{ SkXfermode::kColorDodge_Mode, "ColorDodge" },
|
||||
{ SkXfermode::kColorBurn_Mode, "ColorBurn" },
|
||||
{ SkXfermode::kHardLight_Mode, "HardLight" },
|
||||
{ SkXfermode::kSoftLight_Mode, "SoftLight" },
|
||||
{ SkXfermode::kDifference_Mode, "Difference" },
|
||||
{ SkXfermode::kExclusion_Mode, "Exclusion" },
|
||||
{ SkXfermode::kMultiply_Mode, "Multiply" },
|
||||
{ SkXfermode::kHue_Mode, "Hue" },
|
||||
{ SkXfermode::kSaturation_Mode, "Saturation" },
|
||||
{ SkXfermode::kColor_Mode, "Color" },
|
||||
{ SkXfermode::kLuminosity_Mode, "Luminosity" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
{ SkBlendMode::kPlus, "Plus" },
|
||||
{ SkBlendMode::kModulate, "Modulate" },
|
||||
{ SkBlendMode::kScreen, "Screen" },
|
||||
{ SkBlendMode::kOverlay, "Overlay" },
|
||||
{ SkBlendMode::kDarken, "Darken" },
|
||||
{ SkBlendMode::kLighten, "Lighten" },
|
||||
{ SkBlendMode::kColorDodge, "ColorDodge" },
|
||||
{ SkBlendMode::kColorBurn, "ColorBurn" },
|
||||
{ SkBlendMode::kHardLight, "HardLight" },
|
||||
{ SkBlendMode::kSoftLight, "SoftLight" },
|
||||
{ SkBlendMode::kDifference, "Difference" },
|
||||
{ SkBlendMode::kExclusion, "Exclusion" },
|
||||
{ SkBlendMode::kMultiply, "Multiply" },
|
||||
{ SkBlendMode::kHue, "Hue" },
|
||||
{ SkBlendMode::kSaturation, "Saturation" },
|
||||
{ SkBlendMode::kColor, "Color" },
|
||||
{ SkBlendMode::kLuminosity, "Luminosity" },
|
||||
};
|
||||
|
||||
const SkScalar w = SkIntToScalar(W);
|
||||
@ -128,7 +128,7 @@ protected:
|
||||
p.setShader(nullptr);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
textP.setXfermode(SkXfermode::Make(gModes[i].fMode));
|
||||
textP.setBlendMode(gModes[i].fMode);
|
||||
canvas->drawText("H", 1, x+ w/10.f, y + 7.f*h/8.f, textP);
|
||||
#if 1
|
||||
canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
|
||||
|
@ -23,12 +23,12 @@ class DrawAtlasGM : public skiagm::GM {
|
||||
canvas->clear(SK_ColorRED);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kClear);
|
||||
SkRect r(target);
|
||||
r.inset(-1, -1);
|
||||
// zero out a place (with a 1-pixel border) to land our drawing.
|
||||
canvas->drawRect(r, paint);
|
||||
paint.setXfermode(nullptr);
|
||||
paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
paint.setAntiAlias(true);
|
||||
canvas->drawOval(target, paint);
|
||||
|
@ -26,7 +26,7 @@ static sk_sp<SkImage> make_atlas(SkCanvas* caller, int atlasSize) {
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermode(SkXfermode::Make(SkXfermode::kSrc_Mode));
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
SkRect r = SkRect::MakeXYWH(0, 0,
|
||||
|
@ -159,8 +159,8 @@ protected:
|
||||
p.setColor(color);
|
||||
// In order to get some batching on the GPU backend we do 2 src over for
|
||||
// each xfer mode which requires a dst read
|
||||
p.setXfermodeMode(r % 3 == 0 ? SkXfermode::kLighten_Mode :
|
||||
SkXfermode::kSrcOver_Mode);
|
||||
p.setBlendMode(r % 3 == 0 ? SkBlendMode::kLighten :
|
||||
SkBlendMode::kSrcOver);
|
||||
SetStyle(&p, style, width);
|
||||
canvas->save();
|
||||
canvas->translate(x, y);
|
||||
|
18
gm/gamma.cpp
18
gm/gamma.cpp
@ -75,11 +75,11 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) {
|
||||
advance();
|
||||
};
|
||||
|
||||
auto nextXferRect = [&](SkColor srcColor, SkXfermode::Mode mode, SkColor dstColor) {
|
||||
auto nextXferRect = [&](SkColor srcColor, SkBlendMode mode, SkColor dstColor) {
|
||||
p.setColor(dstColor);
|
||||
canvas->drawRect(r, p);
|
||||
p.setColor(srcColor);
|
||||
p.setXfermodeMode(mode);
|
||||
p.setBlendMode(mode);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
SkString srcText = SkStringPrintf("%08X", srcColor);
|
||||
@ -207,18 +207,18 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) {
|
||||
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
|
||||
nextXferRect(0x7fffffff, SkXfermode::kSrcOver_Mode, SK_ColorBLACK);
|
||||
nextXferRect(0x7f000000, SkXfermode::kSrcOver_Mode, SK_ColorWHITE);
|
||||
nextXferRect(0x7fffffff, SkBlendMode::kSrcOver, SK_ColorBLACK);
|
||||
nextXferRect(0x7f000000, SkBlendMode::kSrcOver, SK_ColorWHITE);
|
||||
|
||||
nextXferRect(SK_ColorBLACK, SkXfermode::kDstOver_Mode, 0x7fffffff);
|
||||
nextXferRect(SK_ColorWHITE, SkXfermode::kSrcIn_Mode, 0x7fff00ff);
|
||||
nextXferRect(0x7fff00ff, SkXfermode::kDstIn_Mode, SK_ColorWHITE);
|
||||
nextXferRect(SK_ColorBLACK, SkBlendMode::kDstOver, 0x7fffffff);
|
||||
nextXferRect(SK_ColorWHITE, SkBlendMode::kSrcIn, 0x7fff00ff);
|
||||
nextXferRect(0x7fff00ff, SkBlendMode::kDstIn, SK_ColorWHITE);
|
||||
|
||||
// 0x89 = 255 * linear_to_srgb(0.25)
|
||||
nextXferRect(0xff898989, SkXfermode::kPlus_Mode, 0xff898989);
|
||||
nextXferRect(0xff898989, SkBlendMode::kPlus, 0xff898989);
|
||||
|
||||
// 0xDB = 255 * linear_to_srgb(sqrt(0.5))
|
||||
nextXferRect(0xffdbdbdb, SkXfermode::kModulate_Mode, 0xffdbdbdb);
|
||||
nextXferRect(0xffdbdbdb, SkBlendMode::kModulate, 0xffdbdbdb);
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ bool GM::animate(const SkAnimTimer& timer) {
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GM::onDrawBackground(SkCanvas* canvas) {
|
||||
canvas->drawColor(fBGColor, SkXfermode::kSrc_Mode);
|
||||
canvas->drawColor(fBGColor, SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
|
||||
|
@ -11,21 +11,21 @@
|
||||
#include "SkShader.h"
|
||||
|
||||
constexpr struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
};
|
||||
|
||||
const int gWidth = 64;
|
||||
@ -33,7 +33,7 @@ const int gHeight = 64;
|
||||
const SkScalar W = SkIntToScalar(gWidth);
|
||||
const SkScalar H = SkIntToScalar(gHeight);
|
||||
|
||||
static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) {
|
||||
static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, S
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setAlpha(a1);
|
||||
paint.setXfermode(std::move(mode));
|
||||
paint.setBlendMode(mode);
|
||||
for (int angle = 0; angle < 24; ++angle) {
|
||||
SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth;
|
||||
SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight;
|
||||
@ -104,7 +104,7 @@ namespace skiagm {
|
||||
|
||||
canvas->drawRect(bounds, fBGPaint);
|
||||
canvas->saveLayer(&bounds, nullptr);
|
||||
SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode),
|
||||
SkScalar dy = drawCell(canvas, gModes[i].fMode,
|
||||
gAlphaValue[alpha & 1],
|
||||
gAlphaValue[alpha & 2]);
|
||||
canvas->restore();
|
||||
|
@ -19,7 +19,7 @@
|
||||
*
|
||||
* see https://bug.skia.org/3741
|
||||
*/
|
||||
static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, sk_sp<SkImageFilter> imf) {
|
||||
static void do_draw(SkCanvas* canvas, SkBlendMode mode, sk_sp<SkImageFilter> imf) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
canvas->clipRect(SkRect::MakeWH(220, 220));
|
||||
|
||||
@ -40,7 +40,7 @@ static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, sk_sp<SkImageFilter
|
||||
|
||||
paint.setColor(0x660000FF);
|
||||
paint.setImageFilter(std::move(imf));
|
||||
paint.setXfermodeMode(mode);
|
||||
paint.setBlendMode(mode);
|
||||
canvas->drawOval(r1, paint);
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ DEF_SIMPLE_GM(imagefilters_xfermodes, canvas, 480, 480) {
|
||||
kNone_SkFilterQuality,
|
||||
nullptr));
|
||||
|
||||
const SkXfermode::Mode modes[] = {
|
||||
SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode
|
||||
const SkBlendMode modes[] = {
|
||||
SkBlendMode::kSrcATop, SkBlendMode::kDstIn
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) {
|
||||
|
@ -69,9 +69,8 @@ protected:
|
||||
sk_sp<SkImageFilter> colorMorph(SkColorFilterImageFilter::Make(std::move(matrixFilter),
|
||||
std::move(morph)));
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(
|
||||
SkXfermode::Make(SkXfermode::kSrcOver_Mode),
|
||||
std::move(colorMorph)));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver,
|
||||
std::move(colorMorph)));
|
||||
|
||||
DrawClippedImage(canvas, fImage.get(), paint);
|
||||
canvas->translate(SkIntToScalar(100), 0);
|
||||
@ -105,9 +104,8 @@ protected:
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), SkIntToScalar(100)));
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(
|
||||
SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_Mode),
|
||||
std::move(blur),
|
||||
nullptr, &cropRect));
|
||||
SkXfermodeImageFilter::Make(SkBlendMode::kSrcIn, std::move(blur), nullptr,
|
||||
&cropRect));
|
||||
DrawClippedImage(canvas, fImage.get(), paint);
|
||||
canvas->translate(SkIntToScalar(100), 0);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ DEF_SIMPLE_GM(rotate_imagefilter, canvas, 500, 500) {
|
||||
sk_sp<SkImageFilter> filters[] = {
|
||||
nullptr,
|
||||
SkBlurImageFilter::Make(6, 0, nullptr),
|
||||
SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcOver_Mode), nullptr),
|
||||
SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver, nullptr),
|
||||
};
|
||||
|
||||
for (auto& filter : filters) {
|
||||
|
@ -76,44 +76,44 @@ protected:
|
||||
this->drawColumn(surfCanvas, SK_ColorCYAN, SK_ColorMAGENTA, true);
|
||||
|
||||
SkPaint surfPaint;
|
||||
surfPaint.setXfermode(SkXfermode::Make(SkXfermode::kSrcOver_Mode));
|
||||
surfPaint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
surface->draw(canvas, 0, 0, &surfPaint);
|
||||
}
|
||||
|
||||
void drawColumn(SkCanvas* canvas, SkColor backgroundColor, SkColor textColor, bool useGrad) {
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkXfermode::kPlus_Mode, "Plus" },
|
||||
{ SkXfermode::kModulate_Mode, "Modulate" },
|
||||
{ SkXfermode::kScreen_Mode, "Screen" },
|
||||
{ SkXfermode::kOverlay_Mode, "Overlay" },
|
||||
{ SkXfermode::kDarken_Mode, "Darken" },
|
||||
{ SkXfermode::kLighten_Mode, "Lighten" },
|
||||
{ SkXfermode::kColorDodge_Mode, "ColorDodge" },
|
||||
{ SkXfermode::kColorBurn_Mode, "ColorBurn" },
|
||||
{ SkXfermode::kHardLight_Mode, "HardLight" },
|
||||
{ SkXfermode::kSoftLight_Mode, "SoftLight" },
|
||||
{ SkXfermode::kDifference_Mode, "Difference" },
|
||||
{ SkXfermode::kExclusion_Mode, "Exclusion" },
|
||||
{ SkXfermode::kMultiply_Mode, "Multiply" },
|
||||
{ SkXfermode::kHue_Mode, "Hue" },
|
||||
{ SkXfermode::kSaturation_Mode, "Saturation" },
|
||||
{ SkXfermode::kColor_Mode, "Color" },
|
||||
{ SkXfermode::kLuminosity_Mode, "Luminosity" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
{ SkBlendMode::kPlus, "Plus" },
|
||||
{ SkBlendMode::kModulate, "Modulate" },
|
||||
{ SkBlendMode::kScreen, "Screen" },
|
||||
{ SkBlendMode::kOverlay, "Overlay" },
|
||||
{ SkBlendMode::kDarken, "Darken" },
|
||||
{ SkBlendMode::kLighten, "Lighten" },
|
||||
{ SkBlendMode::kColorDodge, "ColorDodge" },
|
||||
{ SkBlendMode::kColorBurn, "ColorBurn" },
|
||||
{ SkBlendMode::kHardLight, "HardLight" },
|
||||
{ SkBlendMode::kSoftLight, "SoftLight" },
|
||||
{ SkBlendMode::kDifference, "Difference" },
|
||||
{ SkBlendMode::kExclusion, "Exclusion" },
|
||||
{ SkBlendMode::kMultiply, "Multiply" },
|
||||
{ SkBlendMode::kHue, "Hue" },
|
||||
{ SkBlendMode::kSaturation, "Saturation" },
|
||||
{ SkBlendMode::kColor, "Color" },
|
||||
{ SkBlendMode::kLuminosity, "Luminosity" },
|
||||
};
|
||||
// Draw background rect
|
||||
SkPaint backgroundPaint;
|
||||
@ -128,7 +128,7 @@ protected:
|
||||
paint.setSubpixelText(true);
|
||||
paint.setLCDRenderText(true);
|
||||
paint.setTextSize(fTextHeight);
|
||||
paint.setXfermode(SkXfermode::Make(gModes[m].fMode));
|
||||
paint.setBlendMode(gModes[m].fMode);
|
||||
sk_tool_utils::set_portable_typeface(&paint);
|
||||
if (useGrad) {
|
||||
SkRect r;
|
||||
|
@ -49,8 +49,8 @@ protected:
|
||||
|
||||
SkISize onISize() override { return SkISize::Make(kWidth, kHeight); }
|
||||
|
||||
void drawTestCase(SkCanvas* canvas, SkScalar x, SkScalar y, SkXfermode::Mode mode,
|
||||
SkXfermode::Mode mode2) {
|
||||
void drawTestCase(SkCanvas* canvas, SkScalar x, SkScalar y, SkBlendMode mode,
|
||||
SkBlendMode mode2) {
|
||||
const SkColor colors[] {
|
||||
SK_ColorRED,
|
||||
SK_ColorGREEN,
|
||||
@ -60,8 +60,6 @@ protected:
|
||||
SK_ColorMAGENTA,
|
||||
};
|
||||
|
||||
sk_sp<SkXfermode> xfermode(SkXfermode::Make(mode));
|
||||
sk_sp<SkXfermode> xfermode2(SkXfermode::Make(mode2));
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); i++) {
|
||||
canvas->save();
|
||||
canvas->translate(x, y);
|
||||
@ -70,7 +68,7 @@ protected:
|
||||
|
||||
SkPaint textPaint;
|
||||
textPaint.setColor(colors[i]);
|
||||
textPaint.setXfermode(i % 2 == 0 ? xfermode : xfermode2);
|
||||
textPaint.setBlendMode(i % 2 == 0 ? mode : mode2);
|
||||
canvas->drawTextBlob(fBlob, 0, 0, textPaint);
|
||||
canvas->restore();
|
||||
}
|
||||
@ -79,13 +77,11 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkScalar offsetX = kWidth / 4.0f;
|
||||
SkScalar offsetY = kHeight / 4.0f;
|
||||
drawTestCase(canvas, offsetX, offsetY, SkXfermode::kSrc_Mode, SkXfermode::kSrc_Mode);
|
||||
drawTestCase(canvas, 3 * offsetX, offsetY, SkXfermode::kSrcOver_Mode,
|
||||
SkXfermode::kSrcOver_Mode);
|
||||
drawTestCase(canvas, offsetX, 3 * offsetY, SkXfermode::kHardLight_Mode,
|
||||
SkXfermode::kLuminosity_Mode);
|
||||
drawTestCase(canvas, 3 * offsetX, 3 * offsetY, SkXfermode::kSrcOver_Mode,
|
||||
SkXfermode::kSrc_Mode);
|
||||
drawTestCase(canvas, offsetX, offsetY, SkBlendMode::kSrc, SkBlendMode::kSrc);
|
||||
drawTestCase(canvas, 3 * offsetX, offsetY, SkBlendMode::kSrcOver, SkBlendMode::kSrcOver);
|
||||
drawTestCase(canvas, offsetX, 3 * offsetY, SkBlendMode::kHardLight,
|
||||
SkBlendMode::kLuminosity);
|
||||
drawTestCase(canvas, 3 * offsetX, 3 * offsetY, SkBlendMode::kSrcOver, SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -26,7 +26,7 @@ static void draw_label(SkCanvas* canvas, const char* label,
|
||||
paint);
|
||||
}
|
||||
|
||||
static void draw_scene(SkCanvas* canvas, const sk_sp<SkColorFilter>& filter, SkXfermode::Mode mode,
|
||||
static void draw_scene(SkCanvas* canvas, const sk_sp<SkColorFilter>& filter, SkBlendMode mode,
|
||||
const sk_sp<SkShader>& s1, const sk_sp<SkShader>& s2) {
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
@ -53,7 +53,7 @@ static void draw_scene(SkCanvas* canvas, const sk_sp<SkColorFilter>& filter, SkX
|
||||
}
|
||||
|
||||
SkPaint xferPaint;
|
||||
xferPaint.setXfermodeMode(mode);
|
||||
xferPaint.setBlendMode(mode);
|
||||
canvas->saveLayer(&bounds, &xferPaint);
|
||||
|
||||
r = bounds;
|
||||
@ -101,13 +101,14 @@ protected:
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkXfermode::Mode modes[] = { SkXfermode::kSrcOver_Mode,
|
||||
SkXfermode::kDstOver_Mode,
|
||||
SkXfermode::kSrcATop_Mode,
|
||||
SkXfermode::kDstATop_Mode,
|
||||
SkXfermode::kSrcIn_Mode,
|
||||
SkXfermode::kDstIn_Mode,
|
||||
};
|
||||
SkBlendMode modes[] = {
|
||||
SkBlendMode::kSrcOver,
|
||||
SkBlendMode::kDstOver,
|
||||
SkBlendMode::kSrcATop,
|
||||
SkBlendMode::kDstATop,
|
||||
SkBlendMode::kSrcIn,
|
||||
SkBlendMode::kDstIn,
|
||||
};
|
||||
struct {
|
||||
const sk_sp<SkShader>& fShader1;
|
||||
const sk_sp<SkShader>& fShader2;
|
||||
|
@ -78,7 +78,7 @@ protected:
|
||||
}
|
||||
SkPaint bgPaint;
|
||||
bgPaint.setShader(fBmpShader);
|
||||
bgPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
bgPaint.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
sk_sp<SkShader> shaders[] = {
|
||||
nullptr, // use a paint color instead of a shader
|
||||
|
@ -29,7 +29,7 @@ static sk_sp<SkPicture> make_picture() {
|
||||
canvas->drawPath(path, paint);
|
||||
|
||||
paint.setColor(0x80FFFFFF);
|
||||
paint.setXfermodeMode(SkXfermode::kPlus_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kPlus);
|
||||
canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint);
|
||||
|
||||
return rec.finishRecordingAsPicture();
|
||||
|
@ -37,7 +37,7 @@ DEF_SIMPLE_GM(PlusMergesAA, canvas, 256, 256) {
|
||||
|
||||
// Using Plus on the right should merge the AA of seam together completely covering the red.
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
p.setXfermodeMode(SkXfermode::kPlus_Mode);
|
||||
p.setBlendMode(SkBlendMode::kPlus);
|
||||
canvas->translate(150, 0);
|
||||
canvas->drawPath(upperLeft, p);
|
||||
canvas->drawPath(bottomRight, p);
|
||||
|
@ -82,8 +82,8 @@ protected:
|
||||
draw_hair, draw_thick, draw_rect, draw_oval, draw_text
|
||||
};
|
||||
|
||||
const SkXfermode::Mode modes[] = {
|
||||
SkXfermode::kSrcOver_Mode, SkXfermode::kSrc_Mode, SkXfermode::kClear_Mode
|
||||
const SkBlendMode modes[] = {
|
||||
SkBlendMode::kSrcOver, SkBlendMode::kSrc, SkBlendMode::kClear
|
||||
};
|
||||
|
||||
const PaintProc paintProcs[] = {
|
||||
@ -96,7 +96,7 @@ protected:
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(paintProcs); ++i) {
|
||||
paintProcs[i](&paint);
|
||||
for (size_t x = 0; x < SK_ARRAY_COUNT(modes); ++x) {
|
||||
paint.setXfermodeMode(modes[x]);
|
||||
paint.setBlendMode(modes[x]);
|
||||
canvas->save();
|
||||
for (size_t y = 0; y < SK_ARRAY_COUNT(procs); ++y) {
|
||||
procs[y](canvas, paint);
|
||||
|
@ -69,7 +69,7 @@ protected:
|
||||
redPaint.setColor(SK_ColorRED);
|
||||
canvas->drawRect(bounds, redPaint);
|
||||
SkPaint srcInPaint(paint);
|
||||
srcInPaint.setXfermodeMode(SkXfermode::kSrcIn_Mode);
|
||||
srcInPaint.setBlendMode(SkBlendMode::kSrcIn);
|
||||
canvas->drawTextBlob(fBlob, 0, 0, srcInPaint);
|
||||
|
||||
canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta));
|
||||
|
@ -51,7 +51,7 @@ static void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const
|
||||
typedef void (*LooperProc)(SkPaint*);
|
||||
|
||||
struct LooperSettings {
|
||||
SkXfermode::Mode fMode;
|
||||
SkBlendMode fMode;
|
||||
SkColor fColor;
|
||||
SkPaint::Style fStyle;
|
||||
SkScalar fWidth;
|
||||
@ -120,7 +120,7 @@ static sk_sp<SkDrawLooper> setupLooper(SkLayerDrawLooper::BitFlags bits,
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
info.fOffset.set(settings[i].fOffset, settings[i].fOffset);
|
||||
SkPaint* paint = looperBuilder.addLayer(info);
|
||||
paint->setXfermodeMode(settings[i].fMode);
|
||||
paint->setBlendMode(settings[i].fMode);
|
||||
paint->setColor(settings[i].fColor);
|
||||
paint->setStyle(settings[i].fStyle);
|
||||
paint->setStrokeWidth(settings[i].fWidth);
|
||||
@ -152,37 +152,37 @@ protected:
|
||||
|
||||
// create a looper which sandwhiches an effect in two normal draws
|
||||
LooperSettings looperSandwhich[] = {
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorMAGENTA, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkXfermode::kSrcOver_Mode, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0, true },
|
||||
{ SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorMAGENTA, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkBlendMode::kSrcOver, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0, true },
|
||||
{ SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0, false },
|
||||
};
|
||||
|
||||
LooperSettings compound[] = {
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorRED, SkPaint::kStroke_Style, 4.f, 0, 0, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkXfermode::kSrcOver_Mode, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0, true }
|
||||
{ SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorRED, SkPaint::kStroke_Style, 4.f, 0, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkBlendMode::kSrcOver, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0, true }
|
||||
};
|
||||
|
||||
LooperSettings xfermode[] = {
|
||||
{ SkXfermode::kDifference_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkXfermode::kSrcOver_Mode, 0xFF000000, SkPaint::kFill_Style, 0, 1.f, 0, true },
|
||||
{ SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 2.f, 0, false },
|
||||
{ SkBlendMode::kDifference, SK_ColorWHITE, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkBlendMode::kSrcOver, 0xFF000000, SkPaint::kFill_Style, 0, 1.f, 0, true },
|
||||
{ SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 2.f, 0, false },
|
||||
};
|
||||
|
||||
// NOTE, this should be ignored by textblobs
|
||||
LooperSettings skew[] = {
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorRED, SkPaint::kFill_Style, 0, 0, -1.f, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorGREEN, SkPaint::kFill_Style, 0, 10.f, -1.f, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorBLUE, SkPaint::kFill_Style, 0, 20.f, -1.f, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorRED, SkPaint::kFill_Style, 0, 0, -1.f, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorGREEN, SkPaint::kFill_Style, 0, 10.f, -1.f, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorBLUE, SkPaint::kFill_Style, 0, 20.f, -1.f, false },
|
||||
};
|
||||
|
||||
LooperSettings kitchenSink[] = {
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorBLACK, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkXfermode::kDifference_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 1.f, 10.f, 0, false },
|
||||
{ SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 0, 10.f, 0, true },
|
||||
{ SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorBLACK, SkPaint::kFill_Style, 0, 0, 0, false },
|
||||
{ SkBlendMode::kDifference, SK_ColorWHITE, SkPaint::kFill_Style, 1.f, 10.f, 0, false },
|
||||
{ SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kFill_Style, 0, 10.f, 0, true },
|
||||
{ SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0, false },
|
||||
};
|
||||
|
||||
fLoopers.push_back(setupLooper(SkLayerDrawLooper::kMaskFilter_Bit |
|
||||
|
@ -25,7 +25,7 @@ static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setAlpha(0x11);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setAlpha(0x40);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*2);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -46,7 +46,7 @@ static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*3/2);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setAlpha(0x20);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -66,10 +66,10 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
||||
p.setAlpha(0xFF);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
|
||||
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
|
||||
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrcOut);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
SkLayerRasterizer::Builder rastBuilder2;
|
||||
r5(&rastBuilder2, p);
|
||||
p.setRasterizer(rastBuilder2.detach());
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -117,11 +117,11 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
|
||||
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
|
||||
p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -134,11 +134,11 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
|
||||
lattice.postRotate(SkIntToScalar(30), 0, 0);
|
||||
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
|
@ -57,14 +57,14 @@ protected:
|
||||
SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW };
|
||||
paint.setShader(SkGradientShader::MakeSweep(45.f, 55.f, colors2, nullptr,
|
||||
SK_ARRAY_COUNT(colors2)));
|
||||
paint.setXfermodeMode(SkXfermode::kDarken_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kDarken);
|
||||
canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.height() + 10.f),
|
||||
paint);
|
||||
|
||||
SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN };
|
||||
paint.setShader(SkGradientShader::MakeSweep(25.f, 35.f, colors3, nullptr,
|
||||
SK_ARRAY_COUNT(colors3)));
|
||||
paint.setXfermodeMode(SkXfermode::kLighten_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kLighten);
|
||||
canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.height() + 10.f),
|
||||
paint);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) {
|
||||
SkPaint paint;
|
||||
paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr, 2,
|
||||
SkShader::kMirror_TileMode));
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
canvas->drawPaint(paint);
|
||||
}
|
||||
|
||||
|
@ -48,46 +48,45 @@ protected:
|
||||
SkPaint paint;
|
||||
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
|
||||
{ SkXfermode::kPlus_Mode, "Plus" },
|
||||
{ SkXfermode::kModulate_Mode, "Modulate" },
|
||||
{ SkXfermode::kScreen_Mode, "Screen" },
|
||||
{ SkXfermode::kOverlay_Mode, "Overlay" },
|
||||
{ SkXfermode::kDarken_Mode, "Darken" },
|
||||
{ SkXfermode::kLighten_Mode, "Lighten" },
|
||||
{ SkXfermode::kColorDodge_Mode, "ColorDodge" },
|
||||
{ SkXfermode::kColorBurn_Mode, "ColorBurn" },
|
||||
{ SkXfermode::kHardLight_Mode, "HardLight" },
|
||||
{ SkXfermode::kSoftLight_Mode, "SoftLight" },
|
||||
{ SkXfermode::kDifference_Mode, "Difference" },
|
||||
{ SkXfermode::kExclusion_Mode, "Exclusion" },
|
||||
{ SkXfermode::kMultiply_Mode, "Multiply" },
|
||||
{ SkXfermode::kHue_Mode, "Hue" },
|
||||
{ SkXfermode::kSaturation_Mode, "Saturation" },
|
||||
{ SkXfermode::kColor_Mode, "Color" },
|
||||
{ SkXfermode::kLuminosity_Mode, "Luminosity" },
|
||||
{ SkBlendMode::kPlus, "Plus" },
|
||||
{ SkBlendMode::kModulate, "Modulate" },
|
||||
{ SkBlendMode::kScreen, "Screen" },
|
||||
{ SkBlendMode::kOverlay, "Overlay" },
|
||||
{ SkBlendMode::kDarken, "Darken" },
|
||||
{ SkBlendMode::kLighten, "Lighten" },
|
||||
{ SkBlendMode::kColorDodge, "ColorDodge" },
|
||||
{ SkBlendMode::kColorBurn, "ColorBurn" },
|
||||
{ SkBlendMode::kHardLight, "HardLight" },
|
||||
{ SkBlendMode::kSoftLight, "SoftLight" },
|
||||
{ SkBlendMode::kDifference, "Difference" },
|
||||
{ SkBlendMode::kExclusion, "Exclusion" },
|
||||
{ SkBlendMode::kMultiply, "Multiply" },
|
||||
{ SkBlendMode::kHue, "Hue" },
|
||||
{ SkBlendMode::kSaturation, "Saturation" },
|
||||
{ SkBlendMode::kColor, "Color" },
|
||||
{ SkBlendMode::kLuminosity, "Luminosity" },
|
||||
};
|
||||
|
||||
int x = 0, y = 0;
|
||||
sk_sp<SkImageFilter> background(SkImageSource::Make(fCheckerboard));
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(gModes[i].fMode),
|
||||
background));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(gModes[i].fMode, background));
|
||||
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
|
||||
x += fBitmap.width() + MARGIN;
|
||||
if (x + fBitmap.width() > WIDTH) {
|
||||
@ -104,7 +103,7 @@ protected:
|
||||
y += fBitmap.height() + MARGIN;
|
||||
}
|
||||
// Test nullptr mode
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(nullptr, background));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver, background));
|
||||
DrawClippedBitmap(canvas, fBitmap, paint, x, y);
|
||||
x += fBitmap.width() + MARGIN;
|
||||
if (x + fBitmap.width() > WIDTH) {
|
||||
@ -122,11 +121,10 @@ protected:
|
||||
sk_sp<SkImageFilter> offsetBackground(SkOffsetImageFilter::Make(SkIntToScalar(4),
|
||||
SkIntToScalar(4),
|
||||
background));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(
|
||||
SkXfermode::Make(SkXfermode::kSrcOver_Mode),
|
||||
offsetBackground,
|
||||
offsetForeground,
|
||||
nullptr));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver,
|
||||
offsetBackground,
|
||||
offsetForeground,
|
||||
nullptr));
|
||||
DrawClippedPaint(canvas, clipRect, paint, x, y);
|
||||
x += fBitmap.width() + MARGIN;
|
||||
if (x + fBitmap.width() > WIDTH) {
|
||||
@ -134,7 +132,7 @@ protected:
|
||||
y += fBitmap.height() + MARGIN;
|
||||
}
|
||||
// Test offsets on Darken (uses shader blend)
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kDarken_Mode),
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkBlendMode::kDarken,
|
||||
offsetBackground,
|
||||
offsetForeground,
|
||||
nullptr));
|
||||
@ -146,9 +144,9 @@ protected:
|
||||
}
|
||||
// Test cropping
|
||||
constexpr size_t nbSamples = 3;
|
||||
SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode,
|
||||
SkXfermode::kSrcOver_Mode,
|
||||
SkXfermode::kPlus_Mode};
|
||||
const SkBlendMode sampledModes[nbSamples] = {
|
||||
SkBlendMode::kOverlay, SkBlendMode::kSrcOver, SkBlendMode::kPlus
|
||||
};
|
||||
int offsets[nbSamples][4] = {{ 10, 10, -16, -16},
|
||||
{ 10, 10, 10, 10},
|
||||
{-10, -10, -6, -6}};
|
||||
@ -158,7 +156,7 @@ protected:
|
||||
fBitmap.width() + offsets[i][2],
|
||||
fBitmap.height() + offsets[i][3]);
|
||||
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(SkXfermode::Make(sampledModes[i]),
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(sampledModes[i],
|
||||
offsetBackground,
|
||||
offsetForeground,
|
||||
&rect));
|
||||
@ -170,7 +168,7 @@ protected:
|
||||
}
|
||||
}
|
||||
// Test small bg, large fg with Screen (uses shader blend)
|
||||
auto mode = SkXfermode::Make(SkXfermode::kScreen_Mode);
|
||||
SkBlendMode mode = SkBlendMode::kScreen;
|
||||
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(10, 10, 60, 60));
|
||||
sk_sp<SkImageFilter> cropped(SkOffsetImageFilter::Make(0, 0, foreground, &cropRect));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(mode, cropped, background, nullptr));
|
||||
@ -191,7 +189,7 @@ protected:
|
||||
// Test small fg, large bg with SrcIn with a crop that forces it to full size.
|
||||
// This tests that SkXfermodeImageFilter correctly applies the compositing mode to
|
||||
// the region outside the foreground.
|
||||
mode = SkXfermode::Make(SkXfermode::kSrcIn_Mode);
|
||||
mode = SkBlendMode::kSrcIn;
|
||||
SkImageFilter::CropRect cropRectFull(SkRect::MakeXYWH(0, 0, 80, 80));
|
||||
paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background,
|
||||
cropped, &cropRectFull));
|
||||
|
@ -34,45 +34,45 @@ enum SrcType {
|
||||
};
|
||||
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
int fSourceTypeMask; // The source types to use this
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
int fSourceTypeMask; // The source types to use this
|
||||
// mode with. See draw_mode for
|
||||
// an explanation of each type.
|
||||
// PDF has to play some tricks
|
||||
// to support the base modes,
|
||||
// test those more extensively.
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear", kAll_SrcType },
|
||||
{ SkXfermode::kSrc_Mode, "Src", kAll_SrcType },
|
||||
{ SkXfermode::kDst_Mode, "Dst", kAll_SrcType },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver", kAll_SrcType },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver", kAll_SrcType },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn", kAll_SrcType },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn", kAll_SrcType },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut", kAll_SrcType },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut", kAll_SrcType },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop", kAll_SrcType },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop", kAll_SrcType },
|
||||
{ SkBlendMode::kClear, "Clear", kAll_SrcType },
|
||||
{ SkBlendMode::kSrc, "Src", kAll_SrcType },
|
||||
{ SkBlendMode::kDst, "Dst", kAll_SrcType },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver", kAll_SrcType },
|
||||
{ SkBlendMode::kDstOver, "DstOver", kAll_SrcType },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn", kAll_SrcType },
|
||||
{ SkBlendMode::kDstIn, "DstIn", kAll_SrcType },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut", kAll_SrcType },
|
||||
{ SkBlendMode::kDstOut, "DstOut", kAll_SrcType },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop", kAll_SrcType },
|
||||
{ SkBlendMode::kDstATop, "DstATop", kAll_SrcType },
|
||||
|
||||
{ SkXfermode::kXor_Mode, "Xor", kBasic_SrcType },
|
||||
{ SkXfermode::kPlus_Mode, "Plus", kBasic_SrcType },
|
||||
{ SkXfermode::kModulate_Mode, "Modulate", kAll_SrcType },
|
||||
{ SkXfermode::kScreen_Mode, "Screen", kBasic_SrcType },
|
||||
{ SkXfermode::kOverlay_Mode, "Overlay", kBasic_SrcType },
|
||||
{ SkXfermode::kDarken_Mode, "Darken", kBasic_SrcType },
|
||||
{ SkXfermode::kLighten_Mode, "Lighten", kBasic_SrcType },
|
||||
{ SkXfermode::kColorDodge_Mode, "ColorDodge", kBasic_SrcType },
|
||||
{ SkXfermode::kColorBurn_Mode, "ColorBurn", kBasic_SrcType },
|
||||
{ SkXfermode::kHardLight_Mode, "HardLight", kBasic_SrcType },
|
||||
{ SkXfermode::kSoftLight_Mode, "SoftLight", kBasic_SrcType },
|
||||
{ SkXfermode::kDifference_Mode, "Difference", kBasic_SrcType },
|
||||
{ SkXfermode::kExclusion_Mode, "Exclusion", kBasic_SrcType },
|
||||
{ SkXfermode::kMultiply_Mode, "Multiply", kAll_SrcType },
|
||||
{ SkXfermode::kHue_Mode, "Hue", kBasic_SrcType },
|
||||
{ SkXfermode::kSaturation_Mode, "Saturation", kBasic_SrcType },
|
||||
{ SkXfermode::kColor_Mode, "Color", kBasic_SrcType },
|
||||
{ SkXfermode::kLuminosity_Mode, "Luminosity", kBasic_SrcType },
|
||||
{ SkBlendMode::kXor, "Xor", kBasic_SrcType },
|
||||
{ SkBlendMode::kPlus, "Plus", kBasic_SrcType },
|
||||
{ SkBlendMode::kModulate, "Modulate", kAll_SrcType },
|
||||
{ SkBlendMode::kScreen, "Screen", kBasic_SrcType },
|
||||
{ SkBlendMode::kOverlay, "Overlay", kBasic_SrcType },
|
||||
{ SkBlendMode::kDarken, "Darken", kBasic_SrcType },
|
||||
{ SkBlendMode::kLighten, "Lighten", kBasic_SrcType },
|
||||
{ SkBlendMode::kColorDodge, "ColorDodge", kBasic_SrcType },
|
||||
{ SkBlendMode::kColorBurn, "ColorBurn", kBasic_SrcType },
|
||||
{ SkBlendMode::kHardLight, "HardLight", kBasic_SrcType },
|
||||
{ SkBlendMode::kSoftLight, "SoftLight", kBasic_SrcType },
|
||||
{ SkBlendMode::kDifference, "Difference", kBasic_SrcType },
|
||||
{ SkBlendMode::kExclusion, "Exclusion", kBasic_SrcType },
|
||||
{ SkBlendMode::kMultiply, "Multiply", kAll_SrcType },
|
||||
{ SkBlendMode::kHue, "Hue", kBasic_SrcType },
|
||||
{ SkBlendMode::kSaturation, "Saturation", kBasic_SrcType },
|
||||
{ SkBlendMode::kColor, "Color", kBasic_SrcType },
|
||||
{ SkBlendMode::kLuminosity, "Luminosity", kBasic_SrcType },
|
||||
};
|
||||
|
||||
static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst,
|
||||
@ -118,15 +118,14 @@ class XfermodesGM : public skiagm::GM {
|
||||
* uses the implied shape of the drawing command and these modes
|
||||
* demonstrate that.
|
||||
*/
|
||||
void draw_mode(SkCanvas* canvas, SkXfermode::Mode mode, SrcType srcType,
|
||||
SkScalar x, SkScalar y) {
|
||||
void draw_mode(SkCanvas* canvas, SkBlendMode mode, SrcType srcType, SkScalar x, SkScalar y) {
|
||||
SkPaint p;
|
||||
SkMatrix m;
|
||||
bool restoreNeeded = false;
|
||||
m.setTranslate(x, y);
|
||||
|
||||
canvas->drawBitmap(fSrcB, x, y, &p);
|
||||
p.setXfermodeMode(mode);
|
||||
p.setBlendMode(mode);
|
||||
switch (srcType) {
|
||||
case kSmallTransparentImage_SrcType: {
|
||||
m.postScale(SK_ScalarHalf, SK_ScalarHalf, x, y);
|
||||
@ -141,7 +140,7 @@ class XfermodesGM : public skiagm::GM {
|
||||
SkIntToScalar(H));
|
||||
canvas->saveLayer(&bounds, &p);
|
||||
restoreNeeded = true;
|
||||
p.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
// Fall through.
|
||||
}
|
||||
case kQuarterClear_SrcType: {
|
||||
|
@ -40,7 +40,7 @@ protected:
|
||||
|
||||
SkScalar x = 0, y = 0;
|
||||
for (size_t m = 0; m <= SkXfermode::kLastMode; m++) {
|
||||
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
|
||||
SkBlendMode mode = static_cast<SkBlendMode>(m);
|
||||
|
||||
canvas->save();
|
||||
|
||||
@ -57,7 +57,7 @@ protected:
|
||||
p.setShader(fDst);
|
||||
canvas->drawRect(r, p);
|
||||
p.setShader(fSrc);
|
||||
p.setXfermode(SkXfermode::Make(mode));
|
||||
p.setBlendMode(mode);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->restore();
|
||||
@ -65,7 +65,7 @@ protected:
|
||||
r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setShader(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->restore();
|
||||
|
@ -69,7 +69,7 @@ protected:
|
||||
};
|
||||
for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) {
|
||||
for (size_t m = 0; m <= SkXfermode::kLastMode; ++m) {
|
||||
SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
|
||||
SkBlendMode mode = static_cast<SkBlendMode>(m);
|
||||
canvas->drawText(SkXfermode::ModeName(mode),
|
||||
strlen(SkXfermode::ModeName(mode)),
|
||||
SkIntToScalar(x),
|
||||
@ -77,7 +77,7 @@ protected:
|
||||
labelP);
|
||||
for (size_t c = 0; c < SK_ARRAY_COUNT(kSolidColors); ++c) {
|
||||
SkPaint modePaint;
|
||||
modePaint.setXfermodeMode(mode);
|
||||
modePaint.setBlendMode(mode);
|
||||
modePaint.setColor(kSolidColors[c]);
|
||||
modePaint.setStyle(kStrokes[s].fStyle);
|
||||
modePaint.setStrokeWidth(kStrokes[s].fWidth);
|
||||
@ -93,7 +93,7 @@ protected:
|
||||
}
|
||||
for (size_t a = 0; a < SK_ARRAY_COUNT(kBmpAlphas); ++a) {
|
||||
SkPaint modePaint;
|
||||
modePaint.setXfermodeMode(mode);
|
||||
modePaint.setBlendMode(mode);
|
||||
modePaint.setAlpha(kBmpAlphas[a]);
|
||||
modePaint.setShader(fBmpShader);
|
||||
modePaint.setStyle(kStrokes[s].fStyle);
|
||||
|
@ -33,6 +33,7 @@
|
||||
'SK_SUPPORT_LEGACY_STREAM_DATA',
|
||||
'SK_SUPPORT_LEGACY_CLIP_REGIONOPS',
|
||||
'SK_SUPPORT_LEGACY_SHADER_ISABITMAP',
|
||||
'SK_SUPPORT_LEGACY_XFERMODE_OBJECT',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
51
include/core/SkBlendMode.h
Normal file
51
include/core/SkBlendMode.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlendMode_DEFINED
|
||||
#define SkBlendMode_DEFINED
|
||||
|
||||
enum class SkBlendMode {
|
||||
kClear, //!< [0, 0]
|
||||
kSrc, //!< [Sa, Sc]
|
||||
kDst, //!< [Da, Dc]
|
||||
kSrcOver, //!< [Sa + Da * (1 - Sa), Sc + Dc * (1 - Sa)]
|
||||
kDstOver, //!< [Da + Sa * (1 - Da), Dc + Sc * (1 - Da)]
|
||||
kSrcIn, //!< [Sa * Da, Sc * Da]
|
||||
kDstIn, //!< [Da * Sa, Dc * Sa]
|
||||
kSrcOut, //!< [Sa * (1 - Da), Sc * (1 - Da)]
|
||||
kDstOut, //!< [Da * (1 - Sa), Dc * (1 - Sa)]
|
||||
kSrcATop, //!< [Da, Sc * Da + Dc * (1 - Sa)]
|
||||
kDstATop, //!< [Sa, Dc * Sa + Sc * (1 - Da)]
|
||||
kXor, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + Dc * (1 - Sa)]
|
||||
kPlus, //!< [Sa + Da, Sc + Dc]
|
||||
kModulate, // multiplies all components (= alpha and color)
|
||||
|
||||
// Following blend modes are defined in the CSS Compositing standard:
|
||||
// https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending
|
||||
kScreen,
|
||||
kLastCoeffMode = kScreen,
|
||||
|
||||
kOverlay,
|
||||
kDarken,
|
||||
kLighten,
|
||||
kColorDodge,
|
||||
kColorBurn,
|
||||
kHardLight,
|
||||
kSoftLight,
|
||||
kDifference,
|
||||
kExclusion,
|
||||
kMultiply,
|
||||
kLastSeparableMode = kMultiply,
|
||||
|
||||
kHue,
|
||||
kSaturation,
|
||||
kColor,
|
||||
kLuminosity,
|
||||
kLastMode = kLuminosity
|
||||
};
|
||||
|
||||
#endif
|
@ -9,6 +9,7 @@
|
||||
#define SkCanvas_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkClipOp.h"
|
||||
#include "SkDeque.h"
|
||||
@ -595,22 +596,31 @@ public:
|
||||
@param b the blue component (0..255) of the color to fill the canvas
|
||||
@param mode the mode to apply the color in (defaults to SrcOver)
|
||||
*/
|
||||
void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b,
|
||||
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
|
||||
void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkBlendMode mode = SkBlendMode::kSrcOver);
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkXfermode::Mode mode) {
|
||||
this->drawARGB(a, r, g, b, (SkBlendMode)mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
|
||||
specified color and mode.
|
||||
@param color the color to draw with
|
||||
@param mode the mode to apply the color in (defaults to SrcOver)
|
||||
*/
|
||||
void drawColor(SkColor color, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode);
|
||||
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver);
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
void drawColor(SkColor color, SkXfermode::Mode mode) {
|
||||
this->drawColor(color, (SkBlendMode)mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Helper method for drawing a color in SRC mode, completely replacing all the pixels
|
||||
* in the current clip with this color.
|
||||
*/
|
||||
void clear(SkColor color) {
|
||||
this->drawColor(color, SkXfermode::kSrc_Mode);
|
||||
this->drawColor(color, SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,6 +115,9 @@ public:
|
||||
or NULL if the mode will have no effect.
|
||||
*/
|
||||
static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkXfermode::Mode mode);
|
||||
static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkBlendMode mode) {
|
||||
return MakeModeFilter(c, (SkXfermode::Mode)mode);
|
||||
}
|
||||
|
||||
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
||||
* the outer filter to the result of the inner's.
|
||||
|
@ -8,11 +8,14 @@
|
||||
#ifndef SkPaint_DEFINED
|
||||
#define SkPaint_DEFINED
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkFilterQuality.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
//#define SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
|
||||
class SkAutoDescriptor;
|
||||
class SkAutoGlyphCache;
|
||||
class SkColorFilter;
|
||||
@ -525,12 +528,13 @@ public:
|
||||
#endif
|
||||
void setColorFilter(sk_sp<SkColorFilter>);
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
/** Get the paint's xfermode object.
|
||||
<p />
|
||||
The xfermode's reference count is not affected.
|
||||
@return the paint's xfermode (or NULL)
|
||||
*/
|
||||
SkXfermode* getXfermode() const { return fXfermode.get(); }
|
||||
SkXfermode* getXfermode() const;
|
||||
|
||||
/** Set or clear the xfermode object.
|
||||
<p />
|
||||
@ -552,6 +556,11 @@ public:
|
||||
the paint's xfermode is set to null.
|
||||
*/
|
||||
SkXfermode* setXfermodeMode(SkXfermode::Mode);
|
||||
#endif
|
||||
|
||||
SkBlendMode getBlendMode() const { return (SkBlendMode)fBlendMode; }
|
||||
bool isSrcOver() const { return (SkBlendMode)fBlendMode == SkBlendMode::kSrcOver; }
|
||||
void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; }
|
||||
|
||||
/** Get the paint's patheffect object.
|
||||
<p />
|
||||
@ -1090,7 +1099,6 @@ private:
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
sk_sp<SkPathEffect> fPathEffect;
|
||||
sk_sp<SkShader> fShader;
|
||||
sk_sp<SkXfermode> fXfermode;
|
||||
sk_sp<SkMaskFilter> fMaskFilter;
|
||||
sk_sp<SkColorFilter> fColorFilter;
|
||||
sk_sp<SkRasterizer> fRasterizer;
|
||||
@ -1103,6 +1111,7 @@ private:
|
||||
SkColor fColor;
|
||||
SkScalar fWidth;
|
||||
SkScalar fMiterLimit;
|
||||
uint32_t fBlendMode; // just need 5-6 bits for SkXfermode::Mode
|
||||
union {
|
||||
struct {
|
||||
// all of these bitfields should add up to 32
|
||||
|
@ -224,10 +224,11 @@ private:
|
||||
// V47: Add occluder rect to SkBlurMaskFilter
|
||||
// V48: Read and write extended SkTextBlobs.
|
||||
// V49: Gradients serialized as SkColor4f + SkColorSpace
|
||||
// V50: SkXfermode -> SkBlendMode
|
||||
|
||||
// Only SKPs within the min/current picture version range (inclusive) can be read.
|
||||
static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39.
|
||||
static const uint32_t CURRENT_PICTURE_VERSION = 49;
|
||||
static const uint32_t CURRENT_PICTURE_VERSION = 50;
|
||||
|
||||
static_assert(MIN_PICTURE_VERSION <= 41,
|
||||
"Remove kFontFileName and related code from SkFontDescriptor.cpp.");
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef SkXfermode_DEFINED
|
||||
#define SkXfermode_DEFINED
|
||||
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrTexture;
|
||||
@ -17,6 +18,8 @@ class GrXPFactory;
|
||||
class SkRasterPipeline;
|
||||
class SkString;
|
||||
|
||||
struct SkArithmeticParams;
|
||||
|
||||
struct SkPM4f;
|
||||
typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
|
||||
|
||||
@ -112,6 +115,9 @@ public:
|
||||
* Gets the name of the Mode as a string.
|
||||
*/
|
||||
static const char* ModeName(Mode);
|
||||
static const char* ModeName(SkBlendMode mode) {
|
||||
return ModeName(Mode(mode));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the xfermode is one of the modes in the Mode enum, then asMode()
|
||||
@ -157,6 +163,31 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Skia maintains global xfermode objects corresponding to each BlendMode. This returns a
|
||||
* ptr to that global xfermode (or null if the mode is srcover). Thus the caller may use
|
||||
* the returned ptr, but it should leave its refcnt untouched.
|
||||
*/
|
||||
static SkXfermode* Peek(SkBlendMode mode) {
|
||||
sk_sp<SkXfermode> xfer = Make(mode);
|
||||
if (!xfer) {
|
||||
SkASSERT(SkBlendMode::kSrcOver == mode);
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT(!xfer->unique());
|
||||
return xfer.get();
|
||||
}
|
||||
|
||||
static sk_sp<SkXfermode> Make(SkBlendMode bm) {
|
||||
return Make((Mode)bm);
|
||||
}
|
||||
|
||||
SkBlendMode blend() const {
|
||||
Mode mode;
|
||||
SkAssertResult(this->asMode(&mode));
|
||||
return (SkBlendMode)mode;
|
||||
}
|
||||
|
||||
/** Return a function pointer to a routine that applies the specified
|
||||
porter-duff transfer mode.
|
||||
*/
|
||||
@ -215,6 +246,7 @@ public:
|
||||
static bool IsOpaque(const sk_sp<SkXfermode>& xfer, SrcColorOpacity opacityType) {
|
||||
return IsOpaque(xfer.get(), opacityType);
|
||||
}
|
||||
static bool IsOpaque(SkBlendMode, SrcColorOpacity);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor.
|
||||
@ -270,6 +302,8 @@ public:
|
||||
static LCD32Proc GetLCD32Proc(uint32_t flags);
|
||||
static LCDF16Proc GetLCDF16Proc(uint32_t) { return nullptr; }
|
||||
|
||||
virtual bool isArithmetic(SkArithmeticParams*) const { return false; }
|
||||
|
||||
protected:
|
||||
SkXfermode() {}
|
||||
/** The default implementation of xfer32/xfer16/xferA8 in turn call this
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef SkXfermodeImageFilter_DEFINED
|
||||
#define SkXfermodeImageFilter_DEFINED
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkImageFilter.h"
|
||||
|
||||
class SkXfermode;
|
||||
@ -19,11 +20,11 @@ class SkXfermode;
|
||||
*/
|
||||
class SK_API SkXfermodeImageFilter {
|
||||
public:
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background,
|
||||
static sk_sp<SkImageFilter> Make(SkBlendMode, sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* cropRect);
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background) {
|
||||
return Make(std::move(mode), std::move(background), nullptr, nullptr);
|
||||
static sk_sp<SkImageFilter> Make(SkBlendMode mode, sk_sp<SkImageFilter> background) {
|
||||
return Make(mode, std::move(background), nullptr, nullptr);
|
||||
}
|
||||
|
||||
static sk_sp<SkImageFilter> MakeArithmetic(float k1, float k2, float k3, float k4,
|
||||
@ -38,6 +39,16 @@ public:
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background,
|
||||
sk_sp<SkImageFilter> foreground,
|
||||
const SkImageFilter::CropRect* cropRect);
|
||||
static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background) {
|
||||
return Make(std::move(mode), std::move(background), nullptr, nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
|
||||
static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
|
||||
SkImageFilter* foreground = NULL,
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include "effects/GrPorterDuffXferProcessor.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkXfermode.h"
|
||||
|
||||
/**
|
||||
* The paint describes how color and coverage are computed at each pixel by GrContext draw
|
||||
@ -95,6 +95,10 @@ public:
|
||||
fXPFactory = std::move(xpFactory);
|
||||
}
|
||||
|
||||
void setPorterDuffXPFactory(SkBlendMode mode) {
|
||||
fXPFactory = GrPorterDuffXPFactory::Make((SkXfermode::Mode)mode);
|
||||
}
|
||||
|
||||
void setPorterDuffXPFactory(SkXfermode::Mode mode) {
|
||||
fXPFactory = GrPorterDuffXPFactory::Make(mode);
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ class GrProcOptInfo;
|
||||
class GrPorterDuffXPFactory : public GrXPFactory {
|
||||
public:
|
||||
static sk_sp<GrXPFactory> Make(SkXfermode::Mode mode);
|
||||
static sk_sp<GrXPFactory> Make(SkBlendMode mode) {
|
||||
return Make((SkXfermode::Mode)mode);
|
||||
}
|
||||
|
||||
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
|
||||
GrXPFactory::InvariantBlendedColor*) const override;
|
||||
|
@ -616,6 +616,7 @@ DEFINES_ALL = [
|
||||
"SK_SUPPORT_LEGACY_STREAM_DATA",
|
||||
"SK_SUPPORT_LEGACY_CLIP_REGIONOPS",
|
||||
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
|
||||
"SK_SUPPORT_LEGACY_XFERMODE_OBJECT",
|
||||
]
|
||||
|
||||
################################################################################
|
||||
|
@ -12,21 +12,21 @@
|
||||
#include "SkShader.h"
|
||||
|
||||
static const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
};
|
||||
|
||||
const int gWidth = 64;
|
||||
@ -34,7 +34,7 @@ const int gHeight = 64;
|
||||
const SkScalar W = SkIntToScalar(gWidth);
|
||||
const SkScalar H = SkIntToScalar(gHeight);
|
||||
|
||||
static SkScalar drawCell(SkCanvas* canvas, const sk_sp<SkXfermode>& mode, SkAlpha a0, SkAlpha a1) {
|
||||
static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) {
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, const sk_sp<SkXfermode>& mode, SkAlph
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setAlpha(a1);
|
||||
paint.setXfermode(mode);
|
||||
paint.setBlendMode(mode);
|
||||
|
||||
SkScalar offset = SK_Scalar1 / 3;
|
||||
SkRect rect = SkRect::MakeXYWH(W / 4 + offset,
|
||||
@ -106,11 +106,10 @@ protected:
|
||||
canvas->translate(W * 5, 0);
|
||||
canvas->save();
|
||||
}
|
||||
sk_sp<SkXfermode> mode = SkXfermode::Make(gModes[i].fMode);
|
||||
|
||||
canvas->drawRect(bounds, fBGPaint);
|
||||
canvas->saveLayer(&bounds, nullptr);
|
||||
SkScalar dy = drawCell(canvas, mode, gAlphaValue[alpha & 1],
|
||||
SkScalar dy = drawCell(canvas, gModes[i].fMode, gAlphaValue[alpha & 1],
|
||||
gAlphaValue[alpha & 2]);
|
||||
canvas->restore();
|
||||
|
||||
|
@ -89,7 +89,7 @@ static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setAlpha(0x11);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setAlpha(0x40);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*2);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -110,7 +110,7 @@ static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*3/2);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
|
||||
p.setAlpha(0x20);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -130,10 +130,10 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
||||
p.setAlpha(0xFF);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
|
||||
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
|
||||
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrcOut);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
SkLayerRasterizer::Builder rastBuilder2;
|
||||
r5(&rastBuilder2, p);
|
||||
p.setRasterizer(rastBuilder2.detach());
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -194,11 +194,11 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
|
||||
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
|
||||
p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -211,11 +211,11 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
|
||||
lattice.postRotate(SkIntToScalar(30), 0, 0);
|
||||
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -401,10 +401,10 @@ protected:
|
||||
paint.setColor(SK_ColorGREEN);
|
||||
paint.setStrokeWidth(SkIntToScalar(10));
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
paint.setXfermode(SkXfermode::Make(SkXfermode::kXor_Mode));
|
||||
paint.setBlendMode(SkBlendMode::kXor);
|
||||
paint.setColorFilter(lightingFilter);
|
||||
canvas->drawLine(start.fX, start.fY, stop.fX, stop.fY, paint); // should not be green
|
||||
paint.setXfermode(nullptr);
|
||||
paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
paint.setColorFilter(nullptr);
|
||||
|
||||
// rectangle
|
||||
|
@ -352,7 +352,7 @@ public:
|
||||
bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect(win->info());
|
||||
|
||||
SkPaint gammaPaint;
|
||||
gammaPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
gammaPaint.setBlendMode(SkBlendMode::kSrc);
|
||||
if (doGamma) {
|
||||
gammaPaint.setColorFilter(SkGammaColorFilter::Make(1.0f / 2.2f));
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ static SkBitmap createBitmap(int n) {
|
||||
canvas.drawOval(r, paint);
|
||||
|
||||
r.inset(SK_Scalar1*n/4, SK_Scalar1*n/4);
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
paint.setColor(0x800000FF);
|
||||
canvas.drawOval(r, paint);
|
||||
|
||||
|
@ -163,7 +163,7 @@ private:
|
||||
canvas->restore();
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kClear);
|
||||
for (int iy = 1; iy < fH; ++iy) {
|
||||
SkScalar y = SkIntToScalar(iy * fZoom);
|
||||
canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint);
|
||||
|
@ -157,8 +157,8 @@ static SkMatrix make_matrix() {
|
||||
return m;
|
||||
}
|
||||
|
||||
static SkXfermode::Mode make_xfermode() {
|
||||
return static_cast<SkXfermode::Mode>(R(SkXfermode::kLastMode+1));
|
||||
static SkBlendMode make_xfermode() {
|
||||
return static_cast<SkBlendMode>(R(SkXfermode::kLastMode+1));
|
||||
}
|
||||
|
||||
static SkPaint::Align make_paint_align() {
|
||||
@ -508,7 +508,7 @@ static SkPaint make_paint() {
|
||||
paint.setStrokeCap(make_paint_cap());
|
||||
paint.setStrokeJoin(make_paint_join());
|
||||
paint.setColorFilter(make_color_filter());
|
||||
paint.setXfermodeMode(make_xfermode());
|
||||
paint.setBlendMode(make_xfermode());
|
||||
paint.setPathEffect(make_path_effect());
|
||||
paint.setMaskFilter(make_mask_filter());
|
||||
|
||||
@ -558,7 +558,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
|
||||
case MERGE:
|
||||
filter = SkMergeImageFilter::Make(make_image_filter(),
|
||||
make_image_filter(),
|
||||
make_xfermode());
|
||||
(SkXfermode::Mode)make_xfermode());
|
||||
break;
|
||||
case COLOR: {
|
||||
sk_sp<SkColorFilter> cf(make_color_filter());
|
||||
@ -585,7 +585,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
|
||||
make_image_filter());
|
||||
break;
|
||||
case XFERMODE:
|
||||
filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()),
|
||||
filter = SkXfermodeImageFilter::Make(make_xfermode(),
|
||||
make_image_filter(),
|
||||
make_image_filter(),
|
||||
nullptr);
|
||||
|
@ -153,15 +153,15 @@ static void do_fuzz(SkCanvas* canvas) {
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
SkXfermode::Mode mode;
|
||||
SkBlendMode mode;
|
||||
switch (R(3)) {
|
||||
case 0: mode = SkXfermode::kSrc_Mode; break;
|
||||
case 1: mode = SkXfermode::kXor_Mode; break;
|
||||
case 0: mode = SkBlendMode::kSrc; break;
|
||||
case 1: mode = SkBlendMode::kXor; break;
|
||||
case 2:
|
||||
default: // silence warning
|
||||
mode = SkXfermode::kSrcOver_Mode; break;
|
||||
mode = SkBlendMode::kSrcOver; break;
|
||||
}
|
||||
paint.setXfermodeMode(mode);
|
||||
paint.setBlendMode(mode);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -12,21 +12,21 @@
|
||||
#include "SkShader.h"
|
||||
|
||||
static const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
};
|
||||
|
||||
const int gWidth = 64;
|
||||
@ -34,7 +34,7 @@ const int gHeight = 64;
|
||||
const SkScalar W = SkIntToScalar(gWidth);
|
||||
const SkScalar H = SkIntToScalar(gHeight);
|
||||
|
||||
static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) {
|
||||
static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) {
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, S
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setAlpha(a1);
|
||||
paint.setXfermode(mode);
|
||||
paint.setBlendMode(mode);
|
||||
for (int angle = 0; angle < 24; ++angle) {
|
||||
SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth;
|
||||
SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight;
|
||||
@ -105,7 +105,7 @@ protected:
|
||||
}
|
||||
canvas->drawRect(bounds, fBGPaint);
|
||||
canvas->saveLayer(&bounds, nullptr);
|
||||
SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode),
|
||||
SkScalar dy = drawCell(canvas, gModes[i].fMode,
|
||||
gAlphaValue[alpha & 1],
|
||||
gAlphaValue[alpha & 2]);
|
||||
canvas->restore();
|
||||
|
@ -44,13 +44,13 @@ protected:
|
||||
bounds.offset(-bounds.fLeft, -bounds.fTop);
|
||||
c.drawOval(bounds, paint);
|
||||
|
||||
paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kDstIn);
|
||||
canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint);
|
||||
} else {
|
||||
SkPath p;
|
||||
p.addOval(r);
|
||||
p.setFillType(SkPath::kInverseWinding_FillType);
|
||||
paint.setXfermodeMode(SkXfermode::kDstOut_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kDstOut);
|
||||
canvas->drawPath(p, paint);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) {
|
||||
SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
|
||||
paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
|
||||
SkShader::kClamp_TileMode, 0, &localMatrix));
|
||||
paint->setXfermodeMode(SkXfermode::kDstIn_Mode);
|
||||
paint->setBlendMode(SkBlendMode::kDstIn);
|
||||
}
|
||||
|
||||
// test drawing with strips of fading gradient above and below
|
||||
@ -141,7 +141,7 @@ protected:
|
||||
canvas->saveLayer(&r, &p);
|
||||
canvas->drawColor(0xFFFF0000);
|
||||
p.setAlpha(0); // or 0
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
canvas->drawOval(r, p);
|
||||
canvas->restore();
|
||||
return;
|
||||
|
@ -225,7 +225,7 @@ protected:
|
||||
// We use a layer, so we can PLUS the different edge-colors, showing where two edges
|
||||
// canceled each other out.
|
||||
canvas->saveLayer(nullptr, nullptr);
|
||||
p.setXfermodeMode(SkXfermode::kPlus_Mode);
|
||||
p.setBlendMode(SkBlendMode::kPlus);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
const int j = (i + 1) % N;
|
||||
p.setColor(fEdgeColor[i]);
|
||||
|
@ -248,7 +248,7 @@ protected:
|
||||
canvas->restore();
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kClear);
|
||||
for (int iy = 1; iy < fH; ++iy) {
|
||||
SkScalar y = SkIntToScalar(iy * fZoom);
|
||||
canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint);
|
||||
|
@ -80,7 +80,7 @@ static void drawFadingText(SkCanvas* canvas,
|
||||
|
||||
SkPaint p;
|
||||
p.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 3, SkShader::kClamp_TileMode));
|
||||
p.setXfermodeMode(SkXfermode::kDstIn_Mode);
|
||||
p.setBlendMode(SkBlendMode::kDstIn);
|
||||
canvas->drawRect(bounds, p);
|
||||
|
||||
canvas->restore();
|
||||
|
@ -472,7 +472,7 @@ static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
|
||||
p.setAlpha(0x11);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setAlpha(0x40);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*2);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -495,7 +495,7 @@ static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1*3/2);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
|
||||
p.setAlpha(0x20);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -517,10 +517,10 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
||||
p.setAlpha(0xFF);
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
|
||||
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
|
||||
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
|
||||
p.setBlendMode(SkBlendMode::kSrcOut);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -543,7 +543,7 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
SkLayerRasterizer::Builder rastBuilder2;
|
||||
r5(&rastBuilder2, p);
|
||||
p.setRasterizer(rastBuilder2.detach());
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
}
|
||||
|
||||
@ -572,11 +572,11 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
|
||||
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
|
||||
p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
@ -590,11 +590,11 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
|
||||
lattice.postRotate(SkIntToScalar(30), 0, 0);
|
||||
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
|
||||
p.setXfermodeMode(SkXfermode::kClear_Mode);
|
||||
p.setBlendMode(SkBlendMode::kClear);
|
||||
rastBuilder->addLayer(p);
|
||||
|
||||
p.setPathEffect(nullptr);
|
||||
p.setXfermode(nullptr);
|
||||
p.setBlendMode(SkBlendMode::kSrcOver);
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SK_Scalar1);
|
||||
rastBuilder->addLayer(p);
|
||||
|
@ -18,18 +18,18 @@
|
||||
#include "SkGradientShader.h"
|
||||
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fName;
|
||||
SkBlendMode fMode;
|
||||
const char* fName;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kSrcOver_Mode, "src-over" },
|
||||
{ SkXfermode::kSrc_Mode, "src" },
|
||||
{ SkXfermode::kSrcIn_Mode, "src-in" },
|
||||
{ SkXfermode::kSrcOut_Mode, "src-out" },
|
||||
{ SkXfermode::kSrcATop_Mode, "src-atop" },
|
||||
{ SkXfermode::kDstOver_Mode, "dst-over" },
|
||||
{ SkXfermode::kDstIn_Mode, "dst-in" },
|
||||
{ SkXfermode::kDstOut_Mode, "dst-out" },
|
||||
{ SkXfermode::kDstATop_Mode, "dst-atop" },
|
||||
{ SkBlendMode::kSrcOver, "src-over" },
|
||||
{ SkBlendMode::kSrc, "src" },
|
||||
{ SkBlendMode::kSrcIn, "src-in" },
|
||||
{ SkBlendMode::kSrcOut, "src-out" },
|
||||
{ SkBlendMode::kSrcATop, "src-atop" },
|
||||
{ SkBlendMode::kDstOver, "dst-over" },
|
||||
{ SkBlendMode::kDstIn, "dst-in" },
|
||||
{ SkBlendMode::kDstOut, "dst-out" },
|
||||
{ SkBlendMode::kDstATop, "dst-atop" },
|
||||
};
|
||||
const int N_Modes = SK_ARRAY_COUNT(gModes);
|
||||
|
||||
@ -109,10 +109,10 @@ private:
|
||||
|
||||
class ModeDrawable : public SkDrawable {
|
||||
public:
|
||||
ModeDrawable() : fMode(SkXfermode::kSrcOver_Mode), fLoc(SkPoint::Make(0, 0)) {}
|
||||
ModeDrawable() : fMode(SkBlendMode::kSrcOver), fLoc(SkPoint::Make(0, 0)) {}
|
||||
|
||||
SkXfermode::Mode fMode;
|
||||
SkPoint fLoc;
|
||||
SkBlendMode fMode;
|
||||
SkPoint fLoc;
|
||||
|
||||
bool hitTest(SkScalar x, SkScalar y) {
|
||||
SkRect target = SkRect::MakeXYWH(x - fLoc.x() - 1, y - fLoc.y() - 1, 3, 3);
|
||||
@ -139,7 +139,7 @@ protected:
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
fPaint.setXfermodeMode(fMode);
|
||||
fPaint.setBlendMode(fMode);
|
||||
canvas->save();
|
||||
canvas->translate(fLoc.x(), fLoc.y());
|
||||
canvas->drawOval(fBounds, fPaint);
|
||||
@ -160,7 +160,7 @@ class XferDemo : public SampleView {
|
||||
SkScalar x = 10;
|
||||
SkScalar y = 10;
|
||||
for (int i = 0; i < N_Modes; ++i) {
|
||||
SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, gModes[i].fMode));
|
||||
SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode));
|
||||
v->setSize(70, 25);
|
||||
v->setLoc(x, y);
|
||||
v->setVisibleP(true);
|
||||
@ -178,7 +178,7 @@ public:
|
||||
for (int i = 0; i < N; ++i) {
|
||||
fDrs[i].reset(new CircDrawable(200, colors[i]));
|
||||
fDrs[i]->fLoc.set(100.f + i * 100, 100.f + i * 100);
|
||||
fDrs[i]->fMode = SkXfermode::kSrcOver_Mode;
|
||||
fDrs[i]->fMode = SkBlendMode::kSrcOver;
|
||||
}
|
||||
fSelected = nullptr;
|
||||
|
||||
@ -189,7 +189,7 @@ protected:
|
||||
bool onEvent(const SkEvent& evt) override {
|
||||
if (evt.isType("push-button")) {
|
||||
if (fSelected) {
|
||||
fSelected->fMode = (SkXfermode::Mode)evt.getFast32();
|
||||
fSelected->fMode = (SkBlendMode)evt.getFast32();
|
||||
this->inval(nullptr);
|
||||
}
|
||||
return true;
|
||||
|
@ -37,8 +37,7 @@ class XfermodesBlurView : public SampleView {
|
||||
SkBitmap fBG;
|
||||
SkBitmap fSrcB, fDstB;
|
||||
|
||||
void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha,
|
||||
SkScalar x, SkScalar y) {
|
||||
void draw_mode(SkCanvas* canvas, SkBlendMode mode, int alpha, SkScalar x, SkScalar y) {
|
||||
SkPaint p;
|
||||
p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(5),
|
||||
@ -55,7 +54,7 @@ class XfermodesBlurView : public SampleView {
|
||||
r.offset(x, y);
|
||||
canvas->drawOval(r, p);
|
||||
|
||||
p.setXfermode(std::move(mode));
|
||||
p.setBlendMode(mode);
|
||||
|
||||
// draw a square overlapping the circle
|
||||
// in the lower right of the canvas
|
||||
@ -110,34 +109,23 @@ protected:
|
||||
}
|
||||
|
||||
const struct {
|
||||
SkXfermode::Mode fMode;
|
||||
const char* fLabel;
|
||||
SkBlendMode fMode;
|
||||
const char* fLabel;
|
||||
} gModes[] = {
|
||||
{ SkXfermode::kClear_Mode, "Clear" },
|
||||
{ SkXfermode::kSrc_Mode, "Src" },
|
||||
{ SkXfermode::kDst_Mode, "Dst" },
|
||||
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||
{ SkXfermode::kXor_Mode, "Xor" },
|
||||
{ SkBlendMode::kClear, "Clear" },
|
||||
{ SkBlendMode::kSrc, "Src" },
|
||||
{ SkBlendMode::kDst, "Dst" },
|
||||
{ SkBlendMode::kSrcOver, "SrcOver" },
|
||||
{ SkBlendMode::kDstOver, "DstOver" },
|
||||
{ SkBlendMode::kSrcIn, "SrcIn" },
|
||||
{ SkBlendMode::kDstIn, "DstIn" },
|
||||
{ SkBlendMode::kSrcOut, "SrcOut" },
|
||||
{ SkBlendMode::kDstOut, "DstOut" },
|
||||
{ SkBlendMode::kSrcATop, "SrcATop" },
|
||||
{ SkBlendMode::kDstATop, "DstATop" },
|
||||
{ SkBlendMode::kXor, "Xor" },
|
||||
|
||||
{ SkXfermode::kPlus_Mode, "Plus" },
|
||||
/*{ SkXfermode::kModulate_Mode, "Modulate" },
|
||||
{ SkXfermode::kScreen_Mode, "Screen" },
|
||||
{ SkXfermode::kOverlay_Mode, "Overlay" },
|
||||
{ SkXfermode::kDarken_Mode, "Darken" },
|
||||
{ SkXfermode::kLighten_Mode, "Lighten" },
|
||||
{ SkXfermode::kColorDodge_Mode, "ColorDodge" },
|
||||
{ SkXfermode::kColorBurn_Mode, "ColorBurn" },
|
||||
{ SkXfermode::kHardLight_Mode, "HardLight" },
|
||||
{ SkXfermode::kSoftLight_Mode, "SoftLight" },
|
||||
{ SkXfermode::kDifference_Mode, "Difference" },
|
||||
{ SkXfermode::kExclusion_Mode, "Exclusion" },*/
|
||||
{ SkBlendMode::kPlus, "Plus" },
|
||||
};
|
||||
|
||||
const SkScalar w = SkIntToScalar(W);
|
||||
@ -168,8 +156,7 @@ protected:
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->saveLayer(&r, nullptr);
|
||||
draw_mode(canvas, SkXfermode::Make(gModes[i].fMode),
|
||||
twice ? 0x88 : 0xFF, r.fLeft, r.fTop);
|
||||
draw_mode(canvas, gModes[i].fMode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop);
|
||||
canvas->restore();
|
||||
|
||||
r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
|
||||
|
@ -5,6 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkShader.h"
|
||||
@ -132,41 +133,41 @@ void sk_paint_set_stroke_join(sk_paint_t* cpaint, sk_stroke_join_t cjoin) {
|
||||
|
||||
void sk_paint_set_xfermode_mode(sk_paint_t* paint, sk_xfermode_mode_t mode) {
|
||||
SkASSERT(paint);
|
||||
SkXfermode::Mode skmode;
|
||||
SkBlendMode skmode;
|
||||
switch (mode) {
|
||||
#define MAP(X, Y) case (X): skmode = (Y); break
|
||||
MAP( CLEAR_SK_XFERMODE_MODE, SkXfermode::kClear_Mode );
|
||||
MAP( SRC_SK_XFERMODE_MODE, SkXfermode::kSrc_Mode );
|
||||
MAP( DST_SK_XFERMODE_MODE, SkXfermode::kDst_Mode );
|
||||
MAP( SRCOVER_SK_XFERMODE_MODE, SkXfermode::kSrcOver_Mode );
|
||||
MAP( DSTOVER_SK_XFERMODE_MODE, SkXfermode::kDstOver_Mode );
|
||||
MAP( SRCIN_SK_XFERMODE_MODE, SkXfermode::kSrcIn_Mode );
|
||||
MAP( DSTIN_SK_XFERMODE_MODE, SkXfermode::kDstIn_Mode );
|
||||
MAP( SRCOUT_SK_XFERMODE_MODE, SkXfermode::kSrcOut_Mode );
|
||||
MAP( DSTOUT_SK_XFERMODE_MODE, SkXfermode::kDstOut_Mode );
|
||||
MAP( SRCATOP_SK_XFERMODE_MODE, SkXfermode::kSrcATop_Mode );
|
||||
MAP( DSTATOP_SK_XFERMODE_MODE, SkXfermode::kDstATop_Mode );
|
||||
MAP( XOR_SK_XFERMODE_MODE, SkXfermode::kXor_Mode );
|
||||
MAP( PLUS_SK_XFERMODE_MODE, SkXfermode::kPlus_Mode );
|
||||
MAP( MODULATE_SK_XFERMODE_MODE, SkXfermode::kModulate_Mode );
|
||||
MAP( SCREEN_SK_XFERMODE_MODE, SkXfermode::kScreen_Mode );
|
||||
MAP( OVERLAY_SK_XFERMODE_MODE, SkXfermode::kOverlay_Mode );
|
||||
MAP( DARKEN_SK_XFERMODE_MODE, SkXfermode::kDarken_Mode );
|
||||
MAP( LIGHTEN_SK_XFERMODE_MODE, SkXfermode::kLighten_Mode );
|
||||
MAP( COLORDODGE_SK_XFERMODE_MODE, SkXfermode::kColorDodge_Mode );
|
||||
MAP( COLORBURN_SK_XFERMODE_MODE, SkXfermode::kColorBurn_Mode );
|
||||
MAP( HARDLIGHT_SK_XFERMODE_MODE, SkXfermode::kHardLight_Mode );
|
||||
MAP( SOFTLIGHT_SK_XFERMODE_MODE, SkXfermode::kSoftLight_Mode );
|
||||
MAP( DIFFERENCE_SK_XFERMODE_MODE, SkXfermode::kDifference_Mode );
|
||||
MAP( EXCLUSION_SK_XFERMODE_MODE, SkXfermode::kExclusion_Mode );
|
||||
MAP( MULTIPLY_SK_XFERMODE_MODE, SkXfermode::kMultiply_Mode );
|
||||
MAP( HUE_SK_XFERMODE_MODE, SkXfermode::kHue_Mode );
|
||||
MAP( SATURATION_SK_XFERMODE_MODE, SkXfermode::kSaturation_Mode );
|
||||
MAP( COLOR_SK_XFERMODE_MODE, SkXfermode::kColor_Mode );
|
||||
MAP( LUMINOSITY_SK_XFERMODE_MODE, SkXfermode::kLuminosity_Mode );
|
||||
MAP( CLEAR_SK_XFERMODE_MODE, SkBlendMode::kClear );
|
||||
MAP( SRC_SK_XFERMODE_MODE, SkBlendMode::kSrc );
|
||||
MAP( DST_SK_XFERMODE_MODE, SkBlendMode::kDst );
|
||||
MAP( SRCOVER_SK_XFERMODE_MODE, SkBlendMode::kSrcOver );
|
||||
MAP( DSTOVER_SK_XFERMODE_MODE, SkBlendMode::kDstOver );
|
||||
MAP( SRCIN_SK_XFERMODE_MODE, SkBlendMode::kSrcIn );
|
||||
MAP( DSTIN_SK_XFERMODE_MODE, SkBlendMode::kDstIn );
|
||||
MAP( SRCOUT_SK_XFERMODE_MODE, SkBlendMode::kSrcOut );
|
||||
MAP( DSTOUT_SK_XFERMODE_MODE, SkBlendMode::kDstOut );
|
||||
MAP( SRCATOP_SK_XFERMODE_MODE, SkBlendMode::kSrcATop );
|
||||
MAP( DSTATOP_SK_XFERMODE_MODE, SkBlendMode::kDstATop );
|
||||
MAP( XOR_SK_XFERMODE_MODE, SkBlendMode::kXor );
|
||||
MAP( PLUS_SK_XFERMODE_MODE, SkBlendMode::kPlus );
|
||||
MAP( MODULATE_SK_XFERMODE_MODE, SkBlendMode::kModulate );
|
||||
MAP( SCREEN_SK_XFERMODE_MODE, SkBlendMode::kScreen );
|
||||
MAP( OVERLAY_SK_XFERMODE_MODE, SkBlendMode::kOverlay );
|
||||
MAP( DARKEN_SK_XFERMODE_MODE, SkBlendMode::kDarken );
|
||||
MAP( LIGHTEN_SK_XFERMODE_MODE, SkBlendMode::kLighten );
|
||||
MAP( COLORDODGE_SK_XFERMODE_MODE, SkBlendMode::kColorDodge );
|
||||
MAP( COLORBURN_SK_XFERMODE_MODE, SkBlendMode::kColorBurn );
|
||||
MAP( HARDLIGHT_SK_XFERMODE_MODE, SkBlendMode::kHardLight );
|
||||
MAP( SOFTLIGHT_SK_XFERMODE_MODE, SkBlendMode::kSoftLight );
|
||||
MAP( DIFFERENCE_SK_XFERMODE_MODE, SkBlendMode::kDifference );
|
||||
MAP( EXCLUSION_SK_XFERMODE_MODE, SkBlendMode::kExclusion );
|
||||
MAP( MULTIPLY_SK_XFERMODE_MODE, SkBlendMode::kMultiply );
|
||||
MAP( HUE_SK_XFERMODE_MODE, SkBlendMode::kHue );
|
||||
MAP( SATURATION_SK_XFERMODE_MODE, SkBlendMode::kSaturation );
|
||||
MAP( COLOR_SK_XFERMODE_MODE, SkBlendMode::kColor );
|
||||
MAP( LUMINOSITY_SK_XFERMODE_MODE, SkBlendMode::kLuminosity );
|
||||
#undef MAP
|
||||
default:
|
||||
return;
|
||||
}
|
||||
AsPaint(paint)->setXfermodeMode(skmode);
|
||||
AsPaint(paint)->setBlendMode(skmode);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
|
||||
paint.getPathEffect() ||
|
||||
paint.isFakeBoldText() ||
|
||||
paint.getStyle() != SkPaint::kFill_Style ||
|
||||
!SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
|
||||
!paint.isSrcOver())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
19
src/core/SkBlendModePriv.h
Normal file
19
src/core/SkBlendModePriv.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlendModePriv_DEFINED
|
||||
#define SkBlendModePriv_DEFINED
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
|
||||
bool SkBlendMode_SupportsCoverageAsAlpha(SkBlendMode);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrXPFactory> SkBlendMode_AsXPFactory(SkBlendMode);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -815,7 +815,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
|
||||
SkShader* shader = origPaint.getShader();
|
||||
SkColorFilter* cf = origPaint.getColorFilter();
|
||||
SkXfermode* mode = origPaint.getXfermode();
|
||||
SkBlendMode mode = origPaint.getBlendMode();
|
||||
sk_sp<Sk3DShader> shader3D;
|
||||
|
||||
SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
|
||||
@ -828,12 +828,12 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
shader = shader3D.get();
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
if (mode != SkBlendMode::kSrcOver) {
|
||||
bool deviceIsOpaque = kRGB_565_SkColorType == device.colorType();
|
||||
switch (SkInterpretXfermode(*paint, deviceIsOpaque)) {
|
||||
case kSrcOver_SkXfermodeInterpretation:
|
||||
mode = nullptr;
|
||||
paint.writable()->setXfermode(nullptr);
|
||||
mode = SkBlendMode::kSrcOver;
|
||||
paint.writable()->setBlendMode(mode);
|
||||
break;
|
||||
case kSkipDrawing_SkXfermodeInterpretation:{
|
||||
return allocator->createT<SkNullBlitter>();
|
||||
@ -848,13 +848,13 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
* color/shader/colorfilter, and just pretend we're SRC + color==0. This
|
||||
* will fall into our optimizations for SRC mode.
|
||||
*/
|
||||
if (SkXfermode::IsMode(mode, SkXfermode::kClear_Mode)) {
|
||||
if (mode == SkBlendMode::kClear) {
|
||||
SkPaint* p = paint.writable();
|
||||
p->setShader(nullptr);
|
||||
shader = nullptr;
|
||||
p->setColorFilter(nullptr);
|
||||
cf = nullptr;
|
||||
mode = p->setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
p->setBlendMode(mode = SkBlendMode::kSrc);
|
||||
p->setColor(0);
|
||||
}
|
||||
|
||||
@ -863,7 +863,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
}
|
||||
|
||||
if (nullptr == shader) {
|
||||
if (mode) {
|
||||
if (mode != SkBlendMode::kSrcOver) {
|
||||
// xfermodes (and filters) require shaders for our current blitters
|
||||
paint.writable()->setShader(SkShader::MakeColorShader(paint->getColor()));
|
||||
paint.writable()->setAlpha(0xFF);
|
||||
@ -914,7 +914,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
||||
case kAlpha_8_SkColorType:
|
||||
if (drawCoverage) {
|
||||
SkASSERT(nullptr == shader);
|
||||
SkASSERT(nullptr == paint->getXfermode());
|
||||
SkASSERT(paint->isSrcOver());
|
||||
blitter = allocator->createT<SkA8_Coverage_Blitter>(device, *paint);
|
||||
} else if (shader) {
|
||||
blitter = allocator->createT<SkA8_Shader_Blitter>(device, *paint, shaderContext);
|
||||
|
@ -230,10 +230,8 @@ SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint&
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
if ((fXfermode = paint.getXfermode()) != nullptr) {
|
||||
fXfermode->ref();
|
||||
SkASSERT(fShaderContext);
|
||||
}
|
||||
fXfermode = SkXfermode::Peek(paint.getBlendMode());
|
||||
SkASSERT(!fXfermode || fShaderContext);
|
||||
|
||||
int width = device.width();
|
||||
fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4(width) >> 2)));
|
||||
@ -241,7 +239,6 @@ SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint&
|
||||
}
|
||||
|
||||
SkA8_Shader_Blitter::~SkA8_Shader_Blitter() {
|
||||
if (fXfermode) SkSafeUnref(fXfermode);
|
||||
sk_free(fBuffer);
|
||||
}
|
||||
|
||||
@ -355,7 +352,7 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||
SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device,
|
||||
const SkPaint& paint) : SkRasterBlitter(device) {
|
||||
SkASSERT(nullptr == paint.getShader());
|
||||
SkASSERT(nullptr == paint.getXfermode());
|
||||
SkASSERT(paint.isSrcOver());
|
||||
SkASSERT(nullptr == paint.getColorFilter());
|
||||
}
|
||||
|
||||
|
@ -339,8 +339,7 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
|
||||
{
|
||||
fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
|
||||
|
||||
fXfermode = paint.getXfermode();
|
||||
SkSafeRef(fXfermode);
|
||||
fXfermode = SkXfermode::Peek(paint.getBlendMode());
|
||||
|
||||
int flags = 0;
|
||||
if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) {
|
||||
@ -370,7 +369,6 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
|
||||
}
|
||||
|
||||
SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() {
|
||||
SkSafeUnref(fXfermode);
|
||||
sk_free(fBuffer);
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ static bool is_opaque(const SkPaint& paint, const SkShader::Context* shaderConte
|
||||
|
||||
struct State4f {
|
||||
State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext) {
|
||||
fXfer = paint.getXfermode();
|
||||
fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
if (shaderContext) {
|
||||
fBuffer.reset(info.width());
|
||||
} else {
|
||||
@ -410,7 +410,7 @@ template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain
|
||||
SkShader::Context::BlitState bstate;
|
||||
sk_bzero(&bstate, sizeof(bstate));
|
||||
bstate.fCtx = shaderContext;
|
||||
bstate.fXfer = paint.getXfermode();
|
||||
bstate.fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
|
||||
(void)shaderContext->chooseBlitProcs(device.info(), &bstate);
|
||||
return allocator->createT<SkState_Shader_Blitter<State>>(device, paint, bstate);
|
||||
|
@ -160,7 +160,7 @@ SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPai
|
||||
: INHERITED(device, paint) {
|
||||
SkASSERT(paint.getShader() == nullptr);
|
||||
SkASSERT(paint.getColorFilter() == nullptr);
|
||||
SkASSERT(paint.getXfermode() == nullptr);
|
||||
SkASSERT(paint.isSrcOver());
|
||||
SkASSERT(paint.getColor() == SK_ColorBLACK);
|
||||
}
|
||||
|
||||
@ -683,7 +683,7 @@ SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
SkASSERT(paint.getXfermode() == nullptr);
|
||||
SkASSERT(paint.isSrcOver());
|
||||
|
||||
fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
|
||||
|
||||
@ -809,9 +809,8 @@ SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
|
||||
SkShader::Context* shaderContext)
|
||||
: INHERITED(device, paint, shaderContext)
|
||||
{
|
||||
fXfermode = paint.getXfermode();
|
||||
fXfermode = SkXfermode::Peek(paint.getBlendMode());
|
||||
SkASSERT(fXfermode);
|
||||
fXfermode->ref();
|
||||
|
||||
int width = device.width();
|
||||
fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * sizeof(SkPMColor));
|
||||
@ -819,7 +818,6 @@ SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
|
||||
}
|
||||
|
||||
SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter() {
|
||||
fXfermode->unref();
|
||||
sk_free(fBuffer);
|
||||
}
|
||||
|
||||
@ -897,14 +895,14 @@ SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
|
||||
|
||||
SkBlitter* blitter;
|
||||
SkShader* shader = paint.getShader();
|
||||
SkXfermode* mode = paint.getXfermode();
|
||||
bool is_srcover = paint.isSrcOver();
|
||||
|
||||
// we require a shader if there is an xfermode, handled by our caller
|
||||
SkASSERT(nullptr == mode || shader);
|
||||
SkASSERT(is_srcover || shader);
|
||||
|
||||
if (shader) {
|
||||
SkASSERT(shaderContext != nullptr);
|
||||
if (mode) {
|
||||
if (!is_srcover) {
|
||||
blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device, paint,
|
||||
shaderContext);
|
||||
} else {
|
||||
|
@ -68,14 +68,11 @@ public:
|
||||
if (0xFF != paint.getAlpha()) {
|
||||
return false;
|
||||
}
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) {
|
||||
return false;
|
||||
}
|
||||
if (SkXfermode::kSrc_Mode == mode) {
|
||||
SkBlendMode mode = paint.getBlendMode();
|
||||
if (SkBlendMode::kSrc == mode) {
|
||||
return true;
|
||||
}
|
||||
if (SkXfermode::kSrcOver_Mode == mode && src.isOpaque()) {
|
||||
if (SkBlendMode::kSrcOver == mode && src.isOpaque()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,7 +82,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
return SkXfermode::kSrcOver_Mode == mode;
|
||||
return SkBlendMode::kSrcOver == mode;
|
||||
}
|
||||
|
||||
SkSpriteBlitter_Src_SrcOver(const SkPixmap& src)
|
||||
@ -94,14 +91,11 @@ public:
|
||||
void setup(const SkPixmap& dst, int left, int top, const SkPaint& paint) override {
|
||||
SkASSERT(Supports(dst, fSource, paint));
|
||||
this->INHERITED::setup(dst, left, top, paint);
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) {
|
||||
SkFAIL("Should never happen.");
|
||||
}
|
||||
SkBlendMode mode = paint.getBlendMode();
|
||||
|
||||
SkASSERT(mode == SkXfermode::kSrcOver_Mode || mode == SkXfermode::kSrc_Mode);
|
||||
SkASSERT(mode == SkBlendMode::kSrcOver || mode == SkBlendMode::kSrc);
|
||||
|
||||
if (mode == SkXfermode::kSrcOver_Mode && !fSource.isOpaque()) {
|
||||
if (mode == SkBlendMode::kSrcOver && !fSource.isOpaque()) {
|
||||
fUseMemcpy = false;
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ public:
|
||||
*/
|
||||
SkPaint tmp;
|
||||
tmp.setImageFilter(fPaint->getImageFilter());
|
||||
tmp.setXfermode(sk_ref_sp(fPaint->getXfermode()));
|
||||
tmp.setBlendMode(fPaint->getBlendMode());
|
||||
SkRect storage;
|
||||
if (rawBounds) {
|
||||
// Make rawBounds include all paint outsets except for those due to image filters.
|
||||
@ -558,7 +558,7 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
|
||||
|
||||
if (fTempLayerForImageFilter) {
|
||||
paint->setImageFilter(nullptr);
|
||||
paint->setXfermode(nullptr);
|
||||
paint->setBlendMode(SkBlendMode::kSrcOver);
|
||||
}
|
||||
|
||||
if (fLooperContext && !fLooperContext->next(fCanvas, paint)) {
|
||||
@ -2634,7 +2634,7 @@ void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
|
||||
// nothing to draw
|
||||
if (text == nullptr || byteLength == 0 ||
|
||||
draw.fRC->isEmpty() ||
|
||||
(paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) {
|
||||
(paint.getAlpha() == 0 && paint.isSrcOver())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2938,26 +2938,21 @@ void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* va
|
||||
// methods, rather than actually drawing themselves.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b,
|
||||
SkXfermode::Mode mode) {
|
||||
void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkBlendMode mode) {
|
||||
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawARGB()");
|
||||
SkPaint paint;
|
||||
|
||||
paint.setARGB(a, r, g, b);
|
||||
if (SkXfermode::kSrcOver_Mode != mode) {
|
||||
paint.setXfermodeMode(mode);
|
||||
}
|
||||
paint.setBlendMode(mode);
|
||||
this->drawPaint(paint);
|
||||
}
|
||||
|
||||
void SkCanvas::drawColor(SkColor c, SkXfermode::Mode mode) {
|
||||
void SkCanvas::drawColor(SkColor c, SkBlendMode mode) {
|
||||
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawColor()");
|
||||
SkPaint paint;
|
||||
|
||||
paint.setColor(c);
|
||||
if (SkXfermode::kSrcOver_Mode != mode) {
|
||||
paint.setXfermodeMode(mode);
|
||||
}
|
||||
paint.setBlendMode(mode);
|
||||
this->drawPaint(paint);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
||||
#include "SkDraw.h"
|
||||
#include "SkBlendModePriv.h"
|
||||
#include "SkBlitter.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -163,31 +164,27 @@ static BitmapXferProc ChooseBitmapXferProc(const SkPixmap& dst, const SkPaint& p
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkBlendMode mode = paint.getBlendMode();
|
||||
SkColor color = paint.getColor();
|
||||
|
||||
// collaps modes based on color...
|
||||
if (SkXfermode::kSrcOver_Mode == mode) {
|
||||
if (SkBlendMode::kSrcOver == mode) {
|
||||
unsigned alpha = SkColorGetA(color);
|
||||
if (0 == alpha) {
|
||||
mode = SkXfermode::kDst_Mode;
|
||||
mode = SkBlendMode::kDst;
|
||||
} else if (0xFF == alpha) {
|
||||
mode = SkXfermode::kSrc_Mode;
|
||||
mode = SkBlendMode::kSrc;
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case SkXfermode::kClear_Mode:
|
||||
case SkBlendMode::kClear:
|
||||
// SkDebugf("--- D_Clear_BitmapXferProc\n");
|
||||
return D_Clear_BitmapXferProc; // ignore data
|
||||
case SkXfermode::kDst_Mode:
|
||||
case SkBlendMode::kDst:
|
||||
// SkDebugf("--- D_Dst_BitmapXferProc\n");
|
||||
return D_Dst_BitmapXferProc; // ignore data
|
||||
case SkXfermode::kSrc_Mode: {
|
||||
case SkBlendMode::kSrc: {
|
||||
/*
|
||||
should I worry about dithering for the lower depths?
|
||||
*/
|
||||
@ -1143,7 +1140,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
|
||||
if (SkDrawTreatAsHairline(origPaint, *matrix, &coverage)) {
|
||||
if (SK_Scalar1 == coverage) {
|
||||
paint.writable()->setStrokeWidth(0);
|
||||
} else if (SkXfermode::SupportsCoverageAsAlpha(origPaint.getXfermode())) {
|
||||
} else if (SkBlendMode_SupportsCoverageAsAlpha(origPaint.getBlendMode())) {
|
||||
U8CPU newAlpha;
|
||||
#if 0
|
||||
newAlpha = SkToU8(SkScalarRoundToInt(coverage *
|
||||
|
@ -80,7 +80,7 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
|
||||
sk_sp<GrFragmentProcessor> conv(GrConvolutionEffect::MakeGaussian(
|
||||
texture, direction, radius, sigma, useBounds, bounds));
|
||||
paint.addColorFragmentProcessor(std::move(conv));
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
|
||||
-SkIntToScalar(srcOffset.y()));
|
||||
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
|
||||
@ -110,7 +110,7 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
|
||||
srcBounds ? GrTextureDomain::kDecal_Mode : GrTextureDomain::kIgnore_Mode,
|
||||
true, sigmaX, sigmaY));
|
||||
paint.addColorFragmentProcessor(std::move(conv));
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), localMatrix);
|
||||
}
|
||||
@ -285,7 +285,7 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
|
||||
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
|
||||
paint.addColorTextureProcessor(srcTexture.get(), nullptr, matrix, params);
|
||||
}
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
|
||||
|
||||
dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(),
|
||||
@ -361,7 +361,7 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
|
||||
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
|
||||
sk_sp<GrTexture> tex(srcDrawContext->asTexture());
|
||||
paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params);
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
SkIRect dstRect(srcRect);
|
||||
scale_irect(&dstRect, scaleFactorX, scaleFactorY);
|
||||
|
@ -281,7 +281,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
|
||||
const OutputProperties& outputProperties) {
|
||||
GrPaint paint;
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
|
||||
GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
|
||||
|
@ -85,7 +85,7 @@ sk_sp<SkSpecialImage> SkMatrixImageFilter::onFilterImage(SkSpecialImage* source,
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
paint.setFilterQuality(fFilterQuality);
|
||||
|
||||
input->draw(canvas, srcRect.x(), srcRect.y(), &paint);
|
||||
|
@ -52,6 +52,7 @@ SkPaint::SkPaint() {
|
||||
fColor = SK_ColorBLACK;
|
||||
fWidth = 0;
|
||||
fMiterLimit = SkPaintDefaults_MiterLimit;
|
||||
fBlendMode = (unsigned)SkBlendMode::kSrcOver;
|
||||
|
||||
// Zero all bitfields, then set some non-zero defaults.
|
||||
fBitfieldsUInt = 0;
|
||||
@ -69,7 +70,6 @@ SkPaint::SkPaint(const SkPaint& src)
|
||||
: COPY(fTypeface)
|
||||
, COPY(fPathEffect)
|
||||
, COPY(fShader)
|
||||
, COPY(fXfermode)
|
||||
, COPY(fMaskFilter)
|
||||
, COPY(fColorFilter)
|
||||
, COPY(fRasterizer)
|
||||
@ -81,6 +81,7 @@ SkPaint::SkPaint(const SkPaint& src)
|
||||
, COPY(fColor)
|
||||
, COPY(fWidth)
|
||||
, COPY(fMiterLimit)
|
||||
, COPY(fBlendMode)
|
||||
, COPY(fBitfields)
|
||||
#undef COPY
|
||||
{}
|
||||
@ -90,7 +91,6 @@ SkPaint::SkPaint(SkPaint&& src) {
|
||||
MOVE(fTypeface);
|
||||
MOVE(fPathEffect);
|
||||
MOVE(fShader);
|
||||
MOVE(fXfermode);
|
||||
MOVE(fMaskFilter);
|
||||
MOVE(fColorFilter);
|
||||
MOVE(fRasterizer);
|
||||
@ -102,6 +102,7 @@ SkPaint::SkPaint(SkPaint&& src) {
|
||||
MOVE(fColor);
|
||||
MOVE(fWidth);
|
||||
MOVE(fMiterLimit);
|
||||
MOVE(fBlendMode);
|
||||
MOVE(fBitfields);
|
||||
#undef MOVE
|
||||
}
|
||||
@ -117,7 +118,6 @@ SkPaint& SkPaint::operator=(const SkPaint& src) {
|
||||
ASSIGN(fTypeface);
|
||||
ASSIGN(fPathEffect);
|
||||
ASSIGN(fShader);
|
||||
ASSIGN(fXfermode);
|
||||
ASSIGN(fMaskFilter);
|
||||
ASSIGN(fColorFilter);
|
||||
ASSIGN(fRasterizer);
|
||||
@ -129,6 +129,7 @@ SkPaint& SkPaint::operator=(const SkPaint& src) {
|
||||
ASSIGN(fColor);
|
||||
ASSIGN(fWidth);
|
||||
ASSIGN(fMiterLimit);
|
||||
ASSIGN(fBlendMode);
|
||||
ASSIGN(fBitfields);
|
||||
#undef ASSIGN
|
||||
|
||||
@ -144,7 +145,6 @@ SkPaint& SkPaint::operator=(SkPaint&& src) {
|
||||
MOVE(fTypeface);
|
||||
MOVE(fPathEffect);
|
||||
MOVE(fShader);
|
||||
MOVE(fXfermode);
|
||||
MOVE(fMaskFilter);
|
||||
MOVE(fColorFilter);
|
||||
MOVE(fRasterizer);
|
||||
@ -156,6 +156,7 @@ SkPaint& SkPaint::operator=(SkPaint&& src) {
|
||||
MOVE(fColor);
|
||||
MOVE(fWidth);
|
||||
MOVE(fMiterLimit);
|
||||
MOVE(fBlendMode);
|
||||
MOVE(fBitfields);
|
||||
#undef MOVE
|
||||
|
||||
@ -167,7 +168,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
return EQUAL(fTypeface)
|
||||
&& EQUAL(fPathEffect)
|
||||
&& EQUAL(fShader)
|
||||
&& EQUAL(fXfermode)
|
||||
&& EQUAL(fMaskFilter)
|
||||
&& EQUAL(fColorFilter)
|
||||
&& EQUAL(fRasterizer)
|
||||
@ -179,6 +179,7 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
|
||||
&& EQUAL(fColor)
|
||||
&& EQUAL(fWidth)
|
||||
&& EQUAL(fMiterLimit)
|
||||
&& EQUAL(fBlendMode)
|
||||
&& EQUAL(fBitfieldsUInt)
|
||||
;
|
||||
#undef EQUAL
|
||||
@ -360,7 +361,6 @@ MOVE_FIELD(Rasterizer)
|
||||
MOVE_FIELD(ImageFilter)
|
||||
MOVE_FIELD(Shader)
|
||||
MOVE_FIELD(ColorFilter)
|
||||
MOVE_FIELD(Xfermode)
|
||||
MOVE_FIELD(PathEffect)
|
||||
MOVE_FIELD(MaskFilter)
|
||||
MOVE_FIELD(DrawLooper)
|
||||
@ -386,7 +386,10 @@ SET_PTR(Shader)
|
||||
SET_PTR(ColorFilter)
|
||||
#endif
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
|
||||
SET_PTR(Xfermode)
|
||||
SkXfermode* SkPaint::setXfermode(SkXfermode* xfer) {
|
||||
this->setBlendMode(xfer ? xfer->blend() : SkBlendMode::kSrcOver);
|
||||
return this->getXfermode();
|
||||
}
|
||||
#endif
|
||||
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
|
||||
SET_PTR(PathEffect)
|
||||
@ -403,10 +406,18 @@ SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) {
|
||||
}
|
||||
#endif
|
||||
|
||||
SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) {
|
||||
fXfermode = SkXfermode::Make(mode);
|
||||
return fXfermode.get(); // can/should we change this API to be void, like the other setters?
|
||||
#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
|
||||
void SkPaint::setXfermode(sk_sp<SkXfermode> mode) {
|
||||
this->setBlendMode(mode ? mode->blend() : SkBlendMode::kSrcOver);
|
||||
}
|
||||
SkXfermode* SkPaint::getXfermode() const {
|
||||
return SkXfermode::Peek((SkBlendMode)fBlendMode);
|
||||
}
|
||||
SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) {
|
||||
this->setBlendMode((SkBlendMode)mode);
|
||||
return SkXfermode::Peek((SkBlendMode)mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -1904,7 +1915,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
|
||||
}
|
||||
if (asint(this->getPathEffect()) |
|
||||
asint(this->getShader()) |
|
||||
asint(this->getXfermode()) |
|
||||
asint(this->getMaskFilter()) |
|
||||
asint(this->getColorFilter()) |
|
||||
asint(this->getRasterizer()) |
|
||||
@ -1923,7 +1933,8 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.writeUInt(pack_paint_flags(this->getFlags(), this->getHinting(), this->getTextAlign(),
|
||||
this->getFilterQuality(), flatFlags));
|
||||
buffer.writeUInt(pack_4(this->getStrokeCap(), this->getStrokeJoin(),
|
||||
this->getStyle(), this->getTextEncoding()));
|
||||
(this->getStyle() << 4) | this->getTextEncoding(),
|
||||
fBlendMode));
|
||||
|
||||
// now we're done with ptr and the (pre)reserved space. If we need to write
|
||||
// additional fields, use the buffer directly
|
||||
@ -1933,7 +1944,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
|
||||
if (flatFlags & kHasEffects_FlatFlag) {
|
||||
buffer.writeFlattenable(this->getPathEffect());
|
||||
buffer.writeFlattenable(this->getShader());
|
||||
buffer.writeFlattenable(this->getXfermode());
|
||||
buffer.writeFlattenable(this->getMaskFilter());
|
||||
buffer.writeFlattenable(this->getColorFilter());
|
||||
buffer.writeFlattenable(this->getRasterizer());
|
||||
@ -1955,8 +1965,14 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
uint32_t tmp = buffer.readUInt();
|
||||
this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
|
||||
this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
|
||||
this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
|
||||
this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
|
||||
if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) {
|
||||
this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
|
||||
this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
|
||||
} else {
|
||||
this->setStyle(static_cast<Style>((tmp >> 12) & 0xF));
|
||||
this->setTextEncoding(static_cast<TextEncoding>((tmp >> 8) & 0xF));
|
||||
this->setBlendMode((SkBlendMode)(tmp & 0xFF));
|
||||
}
|
||||
|
||||
if (flatFlags & kHasTypeface_FlatFlag) {
|
||||
this->setTypeface(buffer.readTypeface());
|
||||
@ -1967,7 +1983,10 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
if (flatFlags & kHasEffects_FlatFlag) {
|
||||
this->setPathEffect(buffer.readPathEffect());
|
||||
this->setShader(buffer.readShader());
|
||||
this->setXfermode(buffer.readXfermode());
|
||||
if (buffer.isVersionLT(SkReadBuffer::kXfermodeToBlendMode_Version)) {
|
||||
sk_sp<SkXfermode> xfer = buffer.readXfermode();
|
||||
this->setBlendMode(xfer ? xfer->blend() : SkBlendMode::kSrcOver);
|
||||
}
|
||||
this->setMaskFilter(buffer.readMaskFilter());
|
||||
this->setColorFilter(buffer.readColorFilter());
|
||||
this->setRasterizer(buffer.readRasterizer());
|
||||
@ -1986,7 +2005,6 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
|
||||
} else {
|
||||
this->setPathEffect(nullptr);
|
||||
this->setShader(nullptr);
|
||||
this->setXfermode(nullptr);
|
||||
this->setMaskFilter(nullptr);
|
||||
this->setColorFilter(nullptr);
|
||||
this->setRasterizer(nullptr);
|
||||
@ -2116,11 +2134,8 @@ void SkPaint::toString(SkString* str) const {
|
||||
str->append("</dd>");
|
||||
}
|
||||
|
||||
SkXfermode* xfer = this->getXfermode();
|
||||
if (xfer) {
|
||||
str->append("<dt>Xfermode:</dt><dd>");
|
||||
xfer->toString(str);
|
||||
str->append("</dd>");
|
||||
if (!this->isSrcOver()) {
|
||||
str->appendf("<dt>Xfermode:</dt><dd>%d</dd>", fBlendMode);
|
||||
}
|
||||
|
||||
SkMaskFilter* maskFilter = this->getMaskFilter();
|
||||
@ -2363,23 +2378,20 @@ bool SkPaint::nothingToDraw() const {
|
||||
if (fDrawLooper) {
|
||||
return false;
|
||||
}
|
||||
SkXfermode::Mode mode;
|
||||
if (SkXfermode::AsMode(fXfermode.get(), &mode)) {
|
||||
switch (mode) {
|
||||
case SkXfermode::kSrcOver_Mode:
|
||||
case SkXfermode::kSrcATop_Mode:
|
||||
case SkXfermode::kDstOut_Mode:
|
||||
case SkXfermode::kDstOver_Mode:
|
||||
case SkXfermode::kPlus_Mode:
|
||||
if (0 == this->getAlpha()) {
|
||||
return !affects_alpha(fColorFilter.get()) && !affects_alpha(fImageFilter.get());
|
||||
}
|
||||
break;
|
||||
case SkXfermode::kDst_Mode:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch ((SkBlendMode)fBlendMode) {
|
||||
case SkBlendMode::kSrcOver:
|
||||
case SkBlendMode::kSrcATop:
|
||||
case SkBlendMode::kDstOut:
|
||||
case SkBlendMode::kDstOver:
|
||||
case SkBlendMode::kPlus:
|
||||
if (0 == this->getAlpha()) {
|
||||
return !affects_alpha(fColorFilter.get()) && !affects_alpha(fImageFilter.get());
|
||||
}
|
||||
break;
|
||||
case SkBlendMode::kDst:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2387,7 +2399,7 @@ bool SkPaint::nothingToDraw() const {
|
||||
uint32_t SkPaint::getHash() const {
|
||||
// We're going to hash 10 pointers and 7 32-bit values, finishing up with fBitfields,
|
||||
// so fBitfields should be 10 pointers and 6 32-bit values from the start.
|
||||
static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeof(uint32_t),
|
||||
static_assert(offsetof(SkPaint, fBitfields) == 8 * sizeof(void*) + 7 * sizeof(uint32_t),
|
||||
"SkPaint_notPackedTightly");
|
||||
return SkOpts::hash(reinterpret_cast<const uint32_t*>(this),
|
||||
offsetof(SkPaint, fBitfields) + sizeof(fBitfields));
|
||||
|
@ -41,7 +41,7 @@ bool SkPaintPriv::Overwrites(const SkPaint* paint, ShaderOverrideOpacity overrid
|
||||
}
|
||||
}
|
||||
|
||||
return SkXfermode::IsOpaque(paint->getXfermode(), opacityType);
|
||||
return SkXfermode::IsOpaque(paint->getBlendMode(), opacityType);
|
||||
}
|
||||
|
||||
bool SkPaintPriv::Overwrites(const SkBitmap& bitmap, const SkPaint* paint) {
|
||||
|
@ -267,7 +267,7 @@ bool SkPixmap::scalePixels(const SkPixmap& dst, SkFilterQuality quality) const {
|
||||
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(quality);
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
surface->getCanvas()->drawBitmapRect(bitmap, SkRect::MakeIWH(dst.width(), dst.height()),
|
||||
&paint);
|
||||
return true;
|
||||
|
@ -82,8 +82,8 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
|
||||
}
|
||||
|
||||
SkRasterPipeline shader, colorFilter, xfermode;
|
||||
if (!append_effect_stages(paint.getColorFilter(), &colorFilter) ||
|
||||
!append_effect_stages(paint.getXfermode(), &xfermode )) {
|
||||
if (!append_effect_stages(paint.getColorFilter(), &colorFilter) ||
|
||||
!append_effect_stages(SkXfermode::Peek(paint.getBlendMode()), &xfermode )) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
|
||||
if (!paint.getShader()) {
|
||||
blitter->fShader.append(SkRasterPipeline::constant_color, &blitter->fPaintColor);
|
||||
}
|
||||
if (!paint.getXfermode()) {
|
||||
if (paint.isSrcOver()) {
|
||||
blitter->fXfermode.append(SkRasterPipeline::srcover);
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
kLightingShaderWritesInvNormRotation = 45,
|
||||
kBlurMaskFilterWritesOccluder = 47,
|
||||
kGradientShaderFloatColor_Version = 49,
|
||||
kXfermodeToBlendMode_Version = 50,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -341,34 +341,27 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unusual Xfermodes require us to process a saved layer
|
||||
// Unusual blendmodes require us to process a saved layer
|
||||
// even with operations outisde the clip.
|
||||
// For example, DstIn is used by masking layers.
|
||||
// https://code.google.com/p/skia/issues/detail?id=1291
|
||||
// https://crbug.com/401593
|
||||
SkXfermode* xfermode = paint->getXfermode();
|
||||
SkXfermode::Mode mode;
|
||||
// SrcOver is ok, and is also the common case with a nullptr xfermode.
|
||||
// So we should make that the fast path and bypass the mode extraction
|
||||
// and test.
|
||||
if (xfermode && xfermode->asMode(&mode)) {
|
||||
switch (mode) {
|
||||
// For each of the following transfer modes, if the source
|
||||
// alpha is zero (our transparent black), the resulting
|
||||
// blended alpha is not necessarily equal to the original
|
||||
// destination alpha.
|
||||
case SkXfermode::kClear_Mode:
|
||||
case SkXfermode::kSrc_Mode:
|
||||
case SkXfermode::kSrcIn_Mode:
|
||||
case SkXfermode::kDstIn_Mode:
|
||||
case SkXfermode::kSrcOut_Mode:
|
||||
case SkXfermode::kDstATop_Mode:
|
||||
case SkXfermode::kModulate_Mode:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (paint->getBlendMode()) {
|
||||
// For each of the following transfer modes, if the source
|
||||
// alpha is zero (our transparent black), the resulting
|
||||
// blended alpha is not necessarily equal to the original
|
||||
// destination alpha.
|
||||
case SkBlendMode::kClear:
|
||||
case SkBlendMode::kSrc:
|
||||
case SkBlendMode::kSrcIn:
|
||||
case SkBlendMode::kDstIn:
|
||||
case SkBlendMode::kSrcOut:
|
||||
case SkBlendMode::kDstATop:
|
||||
case SkBlendMode::kModulate:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -98,7 +98,7 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint,
|
||||
// looper drawing unmodulated filter layer twice and then modulating the result produces
|
||||
// different image to drawing modulated filter layer twice.
|
||||
// TODO: most likely the looper and only some xfer modes are the hard constraints
|
||||
if (paint->getXfermode() || paint->getLooper()) {
|
||||
if (!paint->isSrcOver() || paint->getLooper()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -129,9 +129,9 @@ static bool fold_opacity_layer_color_to_paint(const SkPaint* layerPaint,
|
||||
}
|
||||
|
||||
// The layer paint can not have any effects.
|
||||
if (layerPaint->getPathEffect() ||
|
||||
if (layerPaint->getPathEffect() ||
|
||||
layerPaint->getShader() ||
|
||||
layerPaint->getXfermode() ||
|
||||
!layerPaint->isSrcOver() ||
|
||||
layerPaint->getMaskFilter() ||
|
||||
layerPaint->getColorFilter() ||
|
||||
layerPaint->getRasterizer() ||
|
||||
@ -174,16 +174,12 @@ void SkRecordNoopSaveRestores(SkRecord* record) {
|
||||
}
|
||||
|
||||
static bool effectively_srcover(const SkPaint* paint) {
|
||||
if (!paint) {
|
||||
return true;
|
||||
}
|
||||
SkXfermode* mode = paint->getXfermode();
|
||||
if (SkXfermode::IsMode(mode, SkXfermode::kSrcOver_Mode)) {
|
||||
if (!paint || paint->isSrcOver()) {
|
||||
return true;
|
||||
}
|
||||
// src-mode with opaque and no effects (which might change opaqueness) is ok too.
|
||||
return !paint->getShader() && !paint->getColorFilter() && !paint->getImageFilter() &&
|
||||
0xFF == paint->getAlpha() && SkXfermode::IsMode(mode, SkXfermode::kSrc_Mode);
|
||||
0xFF == paint->getAlpha() && paint->getBlendMode() == SkBlendMode::kSrc;
|
||||
}
|
||||
|
||||
// For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's alpha into the
|
||||
|
@ -13,7 +13,7 @@
|
||||
class Sprite_4f : public SkSpriteBlitter {
|
||||
public:
|
||||
Sprite_4f(const SkPixmap& src, const SkPaint& paint) : INHERITED(src) {
|
||||
fXfer = paint.getXfermode();
|
||||
fXfer = SkXfermode::Peek(paint.getBlendMode());
|
||||
fLoader = SkLoadSpanProc_Choose(src.info());
|
||||
fFilter = SkFilterSpanProc_Choose(paint);
|
||||
fBuffer.reset(src.width());
|
||||
|
@ -63,8 +63,7 @@ public:
|
||||
fColorFilter = paint.getColorFilter();
|
||||
SkSafeRef(fColorFilter);
|
||||
|
||||
fXfermode = paint.getXfermode();
|
||||
SkSafeRef(fXfermode);
|
||||
fXfermode = SkXfermode::Peek(paint.getBlendMode());
|
||||
|
||||
fBufferSize = 0;
|
||||
fBuffer = nullptr;
|
||||
@ -83,7 +82,6 @@ public:
|
||||
|
||||
virtual ~Sprite_D32_XferFilter() {
|
||||
delete[] fBuffer;
|
||||
SkSafeUnref(fXfermode);
|
||||
SkSafeUnref(fColorFilter);
|
||||
}
|
||||
|
||||
@ -263,7 +261,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain
|
||||
}
|
||||
|
||||
U8CPU alpha = paint.getAlpha();
|
||||
SkXfermode* xfermode = paint.getXfermode();
|
||||
bool isSrcOver = paint.isSrcOver();
|
||||
SkColorFilter* filter = paint.getColorFilter();
|
||||
SkSpriteBlitter* blitter = nullptr;
|
||||
|
||||
@ -272,7 +270,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain
|
||||
if (alpha != 0xFF) {
|
||||
return nullptr; // we only have opaque sprites
|
||||
}
|
||||
if (xfermode || filter) {
|
||||
if (!isSrcOver || filter) {
|
||||
blitter = allocator->createT<Sprite_D32_S4444_XferFilter>(source, paint);
|
||||
} else if (source.isOpaque()) {
|
||||
blitter = allocator->createT<Sprite_D32_S4444_Opaque>(source);
|
||||
@ -281,7 +279,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain
|
||||
}
|
||||
break;
|
||||
case kN32_SkColorType:
|
||||
if (xfermode || filter) {
|
||||
if (!isSrcOver || filter) {
|
||||
if (255 == alpha) {
|
||||
// this can handle xfermode or filter, but not alpha
|
||||
blitter = allocator->createT<Sprite_D32_S32A_XferFilter>(source, paint);
|
||||
|
@ -307,7 +307,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkPixmap& source, const SkPain
|
||||
if (paint.getMaskFilter() != nullptr) { // may add cases for this
|
||||
return nullptr;
|
||||
}
|
||||
if (paint.getXfermode() != nullptr) { // may add cases for this
|
||||
if (!paint.isSrcOver()) { // may add cases for this
|
||||
return nullptr;
|
||||
}
|
||||
if (paint.getColorFilter() != nullptr) { // may add cases for this
|
||||
|
@ -1472,3 +1472,64 @@ bool SkProcCoeffXfermode::onAppendStages(SkRasterPipeline* p) const {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkBlendMode_SupportsCoverageAsAlpha(SkBlendMode mode) {
|
||||
switch (mode) {
|
||||
case SkBlendMode::kDst:
|
||||
case SkBlendMode::kSrcOver:
|
||||
case SkBlendMode::kDstOver:
|
||||
case SkBlendMode::kDstOut:
|
||||
case SkBlendMode::kSrcATop:
|
||||
case SkBlendMode::kXor:
|
||||
case SkBlendMode::kPlus:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkXfermode::IsOpaque(SkBlendMode mode, SrcColorOpacity opacityType) {
|
||||
const ProcCoeff rec = gProcCoeffs[(int)mode];
|
||||
|
||||
switch (rec.fSC) {
|
||||
case kDA_Coeff:
|
||||
case kDC_Coeff:
|
||||
case kIDA_Coeff:
|
||||
case kIDC_Coeff:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rec.fDC) {
|
||||
case kZero_Coeff:
|
||||
return true;
|
||||
case kISA_Coeff:
|
||||
return kOpaque_SrcColorOpacity == opacityType;
|
||||
case kSA_Coeff:
|
||||
return kTransparentBlack_SrcColorOpacity == opacityType ||
|
||||
kTransparentAlpha_SrcColorOpacity == opacityType;
|
||||
case kSC_Coeff:
|
||||
return kTransparentBlack_SrcColorOpacity == opacityType;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrXPFactory> SkBlendMode_AsXPFactory(SkBlendMode mode) {
|
||||
const ProcCoeff rec = gProcCoeffs[(int)mode];
|
||||
if (CANNOT_USE_COEFF != rec.fSC) {
|
||||
sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(mode));
|
||||
SkASSERT(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
SkASSERT(GrCustomXfermode::IsSupportedMode((SkXfermode::Mode)mode));
|
||||
return GrCustomXfermode::MakeXPFactory((SkXfermode::Mode)mode);
|
||||
}
|
||||
#endif
|
||||
|
@ -9,38 +9,31 @@
|
||||
#include "SkPaint.h"
|
||||
|
||||
static bool just_solid_color(const SkPaint& p) {
|
||||
return SK_AlphaOPAQUE == p.getAlpha()
|
||||
&& !p.getColorFilter() && !p.getShader();
|
||||
return SK_AlphaOPAQUE == p.getAlpha() && !p.getColorFilter() && !p.getShader();
|
||||
}
|
||||
|
||||
SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint,
|
||||
bool dstIsOpaque) {
|
||||
const SkXfermode* xfer = paint.getXfermode();
|
||||
SkXfermode::Mode mode;
|
||||
if (!SkXfermode::AsMode(xfer, &mode)) {
|
||||
return kNormal_SkXfermodeInterpretation;
|
||||
}
|
||||
switch (mode) {
|
||||
case SkXfermode::kSrcOver_Mode:
|
||||
SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint, bool dstIsOpaque) {
|
||||
switch (paint.getBlendMode()) {
|
||||
case SkBlendMode::kSrcOver:
|
||||
return kSrcOver_SkXfermodeInterpretation;
|
||||
case SkXfermode::kSrc_Mode:
|
||||
case SkBlendMode::kSrc:
|
||||
if (just_solid_color(paint)) {
|
||||
return kSrcOver_SkXfermodeInterpretation;
|
||||
}
|
||||
return kNormal_SkXfermodeInterpretation;
|
||||
case SkXfermode::kDst_Mode:
|
||||
case SkBlendMode::kDst:
|
||||
return kSkipDrawing_SkXfermodeInterpretation;
|
||||
case SkXfermode::kDstOver_Mode:
|
||||
case SkBlendMode::kDstOver:
|
||||
if (dstIsOpaque) {
|
||||
return kSkipDrawing_SkXfermodeInterpretation;
|
||||
}
|
||||
return kNormal_SkXfermodeInterpretation;
|
||||
case SkXfermode::kSrcIn_Mode:
|
||||
case SkBlendMode::kSrcIn:
|
||||
if (dstIsOpaque && just_solid_color(paint)) {
|
||||
return kSrcOver_SkXfermodeInterpretation;
|
||||
}
|
||||
return kNormal_SkXfermodeInterpretation;
|
||||
case SkXfermode::kDstIn_Mode:
|
||||
case SkBlendMode::kDstIn:
|
||||
if (just_solid_color(paint)) {
|
||||
return kSkipDrawing_SkXfermodeInterpretation;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex
|
||||
}
|
||||
|
||||
GrPaint grPaint;
|
||||
grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
grPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
SkRegion::Iterator iter(fRegion);
|
||||
drawContext->clear(nullptr, 0x0, true);
|
||||
|
||||
|
@ -39,6 +39,14 @@ public:
|
||||
sk_sp<GrXPFactory> asXPFactory() const override;
|
||||
#endif
|
||||
|
||||
bool isArithmetic(SkArithmeticParams* params) const override {
|
||||
if (params) {
|
||||
memcpy(params->fK, fK, 4 * sizeof(float));
|
||||
params->fEnforcePMColor = fEnforcePMColor;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void flatten(SkWriteBuffer& buffer) const override {
|
||||
buffer.writeScalar(fK[0]);
|
||||
|
@ -10,6 +10,11 @@
|
||||
|
||||
#include "SkArithmeticMode.h"
|
||||
|
||||
struct SkArithmeticParams {
|
||||
float fK[4];
|
||||
bool fEnforcePMColor;
|
||||
};
|
||||
|
||||
#ifndef SK_SUPPORT_LEGACY_ARITHMETICMODE
|
||||
|
||||
class SK_API SkArithmeticMode {
|
||||
|
@ -89,7 +89,7 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so
|
||||
|
||||
SkPaint paint;
|
||||
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
paint.setColorFilter(fColorFilter);
|
||||
|
||||
// TODO: it may not be necessary to clear or drawPaint inside the input bounds
|
||||
|
@ -343,7 +343,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
|
||||
offsetMatrix,
|
||||
colorTexture.get(),
|
||||
SkISize::Make(color->width(), color->height())));
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
SkMatrix matrix;
|
||||
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
|
||||
|
||||
|
@ -95,7 +95,6 @@ sk_sp<SkSpecialImage> SkDropShadowImageFilter::onFilterImage(SkSpecialImage* sou
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkBlurImageFilter::Make(sigma.fX, sigma.fY, nullptr));
|
||||
paint.setColorFilter(SkColorFilter::MakeModeFilter(fColor, SkXfermode::kSrcIn_Mode));
|
||||
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
|
||||
SkVector offsetVec = SkVector::Make(fDx, fDy);
|
||||
ctx.ctm().mapVectors(&offsetVec, 1);
|
||||
|
@ -108,7 +108,7 @@ sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const
|
||||
|
||||
// Subtract off the integer component of the translation (will be applied in offset, below).
|
||||
dstRect.offset(-SkIntToScalar(dstIRect.fLeft), -SkIntToScalar(dstIRect.fTop));
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
// FIXME: this probably shouldn't be necessary, but drawImageRect asserts
|
||||
// None filtering when it's translate-only
|
||||
paint.setFilterQuality(
|
||||
|
@ -104,7 +104,7 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo(
|
||||
dst->setColorFilter(sk_ref_sp(src.getColorFilter()));
|
||||
}
|
||||
if (bits & kXfermode_Bit) {
|
||||
dst->setXfermode(sk_ref_sp(src.getXfermode()));
|
||||
dst->setBlendMode(src.getBlendMode());
|
||||
}
|
||||
|
||||
// we don't override these
|
||||
|
@ -396,7 +396,7 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
|
||||
sk_sp<GrFragmentProcessor> fp(this->makeFragmentProcessor(src, matrix, srcBounds,
|
||||
boundaryMode));
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ sk_sp<SkSpecialImage> SkMergeImageFilter::onFilterImage(SkSpecialImage* source,
|
||||
|
||||
SkPaint paint;
|
||||
if (fModes) {
|
||||
paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
|
||||
paint.setBlendMode((SkBlendMode)fModes[i]);
|
||||
}
|
||||
|
||||
inputs[i]->draw(canvas,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user