本文整理汇总了C++中SkRasterClip类的典型用法代码示例。如果您正苦于以下问题:C++ SkRasterClip类的具体用法?C++ SkRasterClip怎么用?C++ SkRasterClip使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkRasterClip类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateMask
static void generateMask(const SkMask& mask, const SkPath& path,
const SkMaskGamma::PreBlend& maskPreBlend) {
SkPaint paint;
int srcW = mask.fBounds.width();
int srcH = mask.fBounds.height();
int dstW = srcW;
int dstH = srcH;
int dstRB = mask.fRowBytes;
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
-SkIntToScalar(mask.fBounds.fTop));
SkBitmap::Config config = SkBitmap::kA8_Config;
paint.setAntiAlias(SkMask::kBW_Format != mask.fFormat);
switch (mask.fFormat) {
case SkMask::kBW_Format:
dstRB = 0; // signals we need a copy
break;
case SkMask::kA8_Format:
break;
case SkMask::kLCD16_Format:
case SkMask::kLCD32_Format:
// TODO: trigger off LCD orientation
dstW = 4*dstW - 8;
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft + 1),
-SkIntToScalar(mask.fBounds.fTop));
matrix.postScale(SkIntToScalar(4), SK_Scalar1);
dstRB = 0; // signals we need a copy
break;
default:
SkDEBUGFAIL("unexpected mask format");
}
SkRasterClip clip;
clip.setRect(SkIRect::MakeWH(dstW, dstH));
SkBitmap bm;
bm.setConfig(config, dstW, dstH, dstRB);
if (0 == dstRB) {
if (!bm.allocPixels()) {
// can't allocate offscreen, so empty the mask and return
sk_bzero(mask.fImage, mask.computeImageSize());
return;
}
bm.lockPixels();
} else {
bm.setPixels(mask.fImage);
}
sk_bzero(bm.getPixels(), bm.getSafeSize());
SkDraw draw;
draw.fRC = &clip;
draw.fClip = &clip.bwRgn();
draw.fMatrix = &matrix;
draw.fBitmap = &bm;
draw.drawPath(path, paint);
switch (mask.fFormat) {
case SkMask::kBW_Format:
packA8ToA1(mask, bm.getAddr8(0, 0), bm.rowBytes());
break;
case SkMask::kA8_Format:
if (maskPreBlend.isApplicable()) {
applyLUTToA8Mask(mask, maskPreBlend.fG);
}
break;
case SkMask::kLCD16_Format:
if (maskPreBlend.isApplicable()) {
pack4xHToLCD16<true>(bm, mask, maskPreBlend);
} else {
pack4xHToLCD16<false>(bm, mask, maskPreBlend);
}
break;
case SkMask::kLCD32_Format:
if (maskPreBlend.isApplicable()) {
pack4xHToLCD32<true>(bm, mask, maskPreBlend);
} else {
pack4xHToLCD32<false>(bm, mask, maskPreBlend);
}
break;
default:
break;
}
}
示例2: generateMask
static void generateMask(const SkMask& mask, const SkPath& path,
const SkMaskGamma::PreBlend& maskPreBlend) {
SkPaint paint;
int srcW = mask.fBounds.width();
int srcH = mask.fBounds.height();
int dstW = srcW;
int dstH = srcH;
int dstRB = mask.fRowBytes;
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft),
-SkIntToScalar(mask.fBounds.fTop));
paint.setAntiAlias(SkMask::kBW_Format != mask.fFormat);
switch (mask.fFormat) {
case SkMask::kBW_Format:
dstRB = 0; // signals we need a copy
break;
case SkMask::kA8_Format:
break;
case SkMask::kLCD16_Format:
// TODO: trigger off LCD orientation
dstW = 4*dstW - 8;
matrix.setTranslate(-SkIntToScalar(mask.fBounds.fLeft + 1),
-SkIntToScalar(mask.fBounds.fTop));
matrix.postScale(SkIntToScalar(4), SK_Scalar1);
dstRB = 0; // signals we need a copy
break;
default:
SkDEBUGFAIL("unexpected mask format");
}
SkRasterClip clip;
clip.setRect(SkIRect::MakeWH(dstW, dstH));
const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
SkAutoPixmapStorage dst;
if (0 == dstRB) {
if (!dst.tryAlloc(info)) {
// can't allocate offscreen, so empty the mask and return
sk_bzero(mask.fImage, mask.computeImageSize());
return;
}
} else {
dst.reset(info, mask.fImage, dstRB);
}
sk_bzero(dst.writable_addr(), dst.getSafeSize());
SkDraw draw;
draw.fDst = dst;
draw.fRC = &clip;
draw.fMatrix = &matrix;
draw.drawPath(path, paint);
switch (mask.fFormat) {
case SkMask::kBW_Format:
packA8ToA1(mask, dst.addr8(0, 0), dst.rowBytes());
break;
case SkMask::kA8_Format:
if (maskPreBlend.isApplicable()) {
applyLUTToA8Mask(mask, maskPreBlend.fG);
}
break;
case SkMask::kLCD16_Format:
if (maskPreBlend.isApplicable()) {
pack4xHToLCD16<true>(dst, mask, maskPreBlend);
} else {
pack4xHToLCD16<false>(dst, mask, maskPreBlend);
}
break;
default:
break;
}
}