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:
reed@android.com 2009-06-23 00:09:12 +00:00
parent 8ede49268d
commit c9c6422903

View File

@ -67,7 +67,7 @@ protected:
return SkString("xfermodes");
}
SkISize onISize() { return make_isize(640, 380); }
SkISize onISize() { return make_isize(790, 480); }
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
@ -88,25 +88,34 @@ protected:
this->drawBG(canvas);
const struct {
SkPorterDuff::Mode fMode;
SkXfermode::Mode fMode;
const char* fLabel;
} gModes[] = {
{ SkPorterDuff::kClear_Mode, "Clear" },
{ SkPorterDuff::kSrc_Mode, "Src" },
{ SkPorterDuff::kDst_Mode, "Dst" },
{ SkPorterDuff::kSrcOver_Mode, "SrcOver" },
{ SkPorterDuff::kDstOver_Mode, "DstOver" },
{ SkPorterDuff::kSrcIn_Mode, "SrcIn" },
{ SkPorterDuff::kDstIn_Mode, "DstIn" },
{ SkPorterDuff::kSrcOut_Mode, "SrcOut" },
{ SkPorterDuff::kDstOut_Mode, "DstOut" },
{ SkPorterDuff::kSrcATop_Mode, "SrcATop" },
{ SkPorterDuff::kDstATop_Mode, "DstATop" },
{ SkPorterDuff::kXor_Mode, "Xor" },
{ SkPorterDuff::kDarken_Mode, "Darken" },
{ SkPorterDuff::kLighten_Mode, "Lighten" },
{ SkPorterDuff::kMultiply_Mode, "Multiply" },
{ SkPorterDuff::kScreen_Mode, "Screen" }
{ 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::kMultiply_Mode, "Multiply" },
{ 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));
@ -125,15 +134,17 @@ protected:
labelP.setAntiAlias(true);
labelP.setTextAlign(SkPaint::kCenter_Align);
const int W = 5;
SkScalar x0 = 0;
for (int twice = 0; twice < 2; twice++) {
SkScalar x = x0, y = 0;
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);
draw_mode(&c, mode, twice ? 0x88 : 0xFF);
mode->safeUnref();
SkSafeUnref(mode);
SkPaint p;
SkRect r;
@ -145,20 +156,19 @@ protected:
p.setShader(s);
r.inset(SK_ScalarHalf, SK_ScalarHalf);
canvas->drawRect(r, p);
canvas->drawBitmap(fBitmap, x, y, NULL);
#if 1
canvas->drawText(gModes[i].fLabel, strlen(gModes[i].fLabel),
x + w/2, y - labelP.getTextSize()/2, labelP);
#endif
x += w + SkIntToScalar(10);
if ((i & 3) == 3) {
if ((i % W) == W - 1) {
x = x0;
y += h + SkIntToScalar(30);
}
}
x0 += SkIntToScalar(330);
x0 += SkIntToScalar(400);
}
s->unref();
}