update to use new xfermodes
git-svn-id: http://skia.googlecode.com/svn/trunk@234 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
8ede49268d
commit
c9c6422903
@ -67,7 +67,7 @@ protected:
|
|||||||
return SkString("xfermodes");
|
return SkString("xfermodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
SkISize onISize() { return make_isize(640, 380); }
|
SkISize onISize() { return make_isize(790, 480); }
|
||||||
|
|
||||||
void drawBG(SkCanvas* canvas) {
|
void drawBG(SkCanvas* canvas) {
|
||||||
canvas->drawColor(SK_ColorWHITE);
|
canvas->drawColor(SK_ColorWHITE);
|
||||||
@ -88,25 +88,34 @@ protected:
|
|||||||
this->drawBG(canvas);
|
this->drawBG(canvas);
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
SkPorterDuff::Mode fMode;
|
SkXfermode::Mode fMode;
|
||||||
const char* fLabel;
|
const char* fLabel;
|
||||||
} gModes[] = {
|
} gModes[] = {
|
||||||
{ SkPorterDuff::kClear_Mode, "Clear" },
|
{ SkXfermode::kClear_Mode, "Clear" },
|
||||||
{ SkPorterDuff::kSrc_Mode, "Src" },
|
{ SkXfermode::kSrc_Mode, "Src" },
|
||||||
{ SkPorterDuff::kDst_Mode, "Dst" },
|
{ SkXfermode::kDst_Mode, "Dst" },
|
||||||
{ SkPorterDuff::kSrcOver_Mode, "SrcOver" },
|
{ SkXfermode::kSrcOver_Mode, "SrcOver" },
|
||||||
{ SkPorterDuff::kDstOver_Mode, "DstOver" },
|
{ SkXfermode::kDstOver_Mode, "DstOver" },
|
||||||
{ SkPorterDuff::kSrcIn_Mode, "SrcIn" },
|
{ SkXfermode::kSrcIn_Mode, "SrcIn" },
|
||||||
{ SkPorterDuff::kDstIn_Mode, "DstIn" },
|
{ SkXfermode::kDstIn_Mode, "DstIn" },
|
||||||
{ SkPorterDuff::kSrcOut_Mode, "SrcOut" },
|
{ SkXfermode::kSrcOut_Mode, "SrcOut" },
|
||||||
{ SkPorterDuff::kDstOut_Mode, "DstOut" },
|
{ SkXfermode::kDstOut_Mode, "DstOut" },
|
||||||
{ SkPorterDuff::kSrcATop_Mode, "SrcATop" },
|
{ SkXfermode::kSrcATop_Mode, "SrcATop" },
|
||||||
{ SkPorterDuff::kDstATop_Mode, "DstATop" },
|
{ SkXfermode::kDstATop_Mode, "DstATop" },
|
||||||
{ SkPorterDuff::kXor_Mode, "Xor" },
|
{ SkXfermode::kXor_Mode, "Xor" },
|
||||||
{ SkPorterDuff::kDarken_Mode, "Darken" },
|
|
||||||
{ SkPorterDuff::kLighten_Mode, "Lighten" },
|
{ SkXfermode::kPlus_Mode, "Plus" },
|
||||||
{ SkPorterDuff::kMultiply_Mode, "Multiply" },
|
{ SkXfermode::kMultiply_Mode, "Multiply" },
|
||||||
{ SkPorterDuff::kScreen_Mode, "Screen" }
|
{ 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" },
|
||||||
};
|
};
|
||||||
|
|
||||||
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
|
||||||
@ -125,15 +134,17 @@ protected:
|
|||||||
labelP.setAntiAlias(true);
|
labelP.setAntiAlias(true);
|
||||||
labelP.setTextAlign(SkPaint::kCenter_Align);
|
labelP.setTextAlign(SkPaint::kCenter_Align);
|
||||||
|
|
||||||
|
const int W = 5;
|
||||||
|
|
||||||
SkScalar x0 = 0;
|
SkScalar x0 = 0;
|
||||||
for (int twice = 0; twice < 2; twice++) {
|
for (int twice = 0; twice < 2; twice++) {
|
||||||
SkScalar x = x0, y = 0;
|
SkScalar x = x0, y = 0;
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
|
||||||
SkXfermode* mode = SkPorterDuff::CreateXfermode(gModes[i].fMode);
|
SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
|
||||||
|
|
||||||
fBitmap.eraseColor(0);
|
fBitmap.eraseColor(0);
|
||||||
draw_mode(&c, mode, twice ? 0x88 : 0xFF);
|
draw_mode(&c, mode, twice ? 0x88 : 0xFF);
|
||||||
mode->safeUnref();
|
SkSafeUnref(mode);
|
||||||
|
|
||||||
SkPaint p;
|
SkPaint p;
|
||||||
SkRect r;
|
SkRect r;
|
||||||
@ -145,20 +156,19 @@ protected:
|
|||||||
p.setShader(s);
|
p.setShader(s);
|
||||||
r.inset(SK_ScalarHalf, SK_ScalarHalf);
|
r.inset(SK_ScalarHalf, SK_ScalarHalf);
|
||||||
canvas->drawRect(r, p);
|
canvas->drawRect(r, p);
|
||||||
|
|
||||||
canvas->drawBitmap(fBitmap, x, y, NULL);
|
canvas->drawBitmap(fBitmap, x, y, NULL);
|
||||||
|
|
||||||
#if 1
|
|
||||||
canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
|
canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
|
||||||
x + w/2, y - labelP.getTextSize()/2, labelP);
|
x + w/2, y - labelP.getTextSize()/2, labelP);
|
||||||
#endif
|
|
||||||
x += w + SkIntToScalar(10);
|
x += w + SkIntToScalar(10);
|
||||||
if ((i & 3) == 3) {
|
if ((i % W) == W - 1) {
|
||||||
x = x0;
|
x = x0;
|
||||||
y += h + SkIntToScalar(30);
|
y += h + SkIntToScalar(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x0 += SkIntToScalar(330);
|
x0 += SkIntToScalar(400);
|
||||||
}
|
}
|
||||||
s->unref();
|
s->unref();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user