本文整理汇总了C++中SkXfermode::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SkXfermode::unref方法的具体用法?C++ SkXfermode::unref怎么用?C++ SkXfermode::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkXfermode
的用法示例。
在下文中一共展示了SkXfermode::unref方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_asMode
static void test_asMode(skiatest::Reporter* reporter) {
for (int mode = 0; mode <= SkXfermode::kLastMode; mode++) {
SkXfermode* xfer = SkXfermode::Create((SkXfermode::Mode) mode);
SkXfermode::Mode reportedMode = ILLEGAL_MODE;
REPORTER_ASSERT(reporter, reportedMode != mode);
// test IsMode
REPORTER_ASSERT(reporter, SkXfermode::AsMode(xfer, &reportedMode));
REPORTER_ASSERT(reporter, reportedMode == mode);
// repeat that test, but with asMode instead
if (xfer) {
reportedMode = (SkXfermode::Mode) -1;
REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == mode);
xfer->unref();
} else {
REPORTER_ASSERT(reporter, SkXfermode::kSrcOver_Mode == mode);
}
}
SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc);
SkXfermode::Mode reportedMode = ILLEGAL_MODE;
REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);
REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode));
REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);
bogusXfer->unref();
}
示例2: SkIntToScalar
ShaderView()
{
SkImageDecoder::DecodeFile("/cover.png", &fBitmap);
SkPoint pts[2];
SkColor colors[2];
pts[0].set(0, 0);
pts[1].set(SkIntToScalar(100), 0);
colors[0] = SK_ColorRED;
colors[1] = SK_ColorBLUE;
SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
pts[0].set(0, 0);
pts[1].set(0, SkIntToScalar(100));
colors[0] = SK_ColorBLACK;
colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
SkXfermode* mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode);
fShader = new SkComposeShader(shaderA, shaderB, mode);
shaderA->unref();
shaderB->unref();
mode->unref();
}
示例3: test_asMode
static void test_asMode(skiatest::Reporter* reporter) {
for (int mode = 0; mode <= SkXfermode::kLastMode; mode++) {
SkXfermode* xfer = SkXfermode::Create((SkXfermode::Mode) mode);
SkXfermode::Mode reportedMode = (SkXfermode::Mode) -1;
REPORTER_ASSERT(reporter,
xfer != NULL || mode == SkXfermode::kSrcOver_Mode);
if (xfer) {
REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == mode);
xfer->unref();
}
}
SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc);
SkXfermode::Mode reportedMode = (SkXfermode::Mode) -1;
REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == -1);
bogusXfer->unref();
}
示例4: mbe_copy_source
void mbe_copy_source(mbe_t *src, mbe_t *dst) {
SkPaint *paint = dst->paint;
const SkBitmap *bmap;
SkXfermode *mode;
/* _prepare_paint(dst, SkPaint::kFill_Style); */
mode = SkXfermode::Create(SkXfermode::kSrc_Mode);
paint->setXfermode(mode);
bmap = &src->canvas->getDevice()->accessBitmap(false);
dst->canvas->drawBitmap(*bmap, 0, 0, paint);
paint->reset();
mode->unref();
/* _finish_paint(dst); */
}
示例5: onDraw
void onDraw(SkCanvas* canvas) override {
// start with the center of a 3x3 grid
static const uint16_t fan[] = {
4,
0, 1, 2, 5, 8, 7, 6, 3, 0
};
const struct {
const SkColor* fColors;
const SkPoint* fTexs;
} rec[] = {
{ fColors, NULL },
{ NULL, fTexs },
{ fColors, fTexs },
};
const SkXfermode::Mode modes[] = {
SkXfermode::kSrc_Mode,
SkXfermode::kDst_Mode,
SkXfermode::kModulate_Mode,
};
SkPaint paint;
paint.setShader(fShader);
paint.setAlpha(fAlpha);
canvas->translate(20, 20);
for (size_t j = 0; j < SK_ARRAY_COUNT(modes); ++j) {
SkXfermode* xfer = SkXfermode::Create(modes[j]);
canvas->save();
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode,
SK_ARRAY_COUNT(fPts), fPts,
rec[i].fTexs, rec[i].fColors,
xfer, fan, SK_ARRAY_COUNT(fan), paint);
canvas->translate(200, 0);
}
canvas->restore();
canvas->translate(0, 200);
xfer->unref();
}
}
示例6: make_bitmapfade
static SkShader* make_bitmapfade(const SkBitmap& bm)
{
SkPoint pts[2];
SkColor colors[2];
pts[0].set(0, 0);
pts[1].set(0, SkIntToScalar(bm.height()));
colors[0] = SK_ColorBLACK;
colors[1] = SkColorSetARGB(0, 0, 0, 0);
SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
SkShader* shaderB = SkShader::CreateBitmapShader(bm,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
SkXfermode* mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode);
SkShader* shader = new SkComposeShader(shaderB, shaderA, mode);
shaderA->unref();
shaderB->unref();
mode->unref();
return shader;
}