本文整理汇总了C++中SkMask类的典型用法代码示例。如果您正苦于以下问题:C++ SkMask类的具体用法?C++ SkMask怎么用?C++ SkMask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkMask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
// TODO: native BW masks?
return INHERITED::blitMask(mask, clip);
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
auto dst = fDst.writable_addr(0,y);
SkRasterPipeline p;
p.extend(fShader);
p.extend(fColorFilter);
this->append_load_d(&p, dst);
p.extend(fXfermode);
switch (mask.fFormat) {
case SkMask::kA8_Format:
p.append<lerp_a8, lerp_a8_1>(mask.getAddr8(x,y)-x);
break;
case SkMask::kLCD16_Format:
p.append<lerp_lcd16, lerp_lcd16_1>(mask.getAddrLCD16(x,y)-x);
break;
default: break;
}
this->append_store(&p, dst);
p.run(x, clip.width());
}
}
示例2: SkASSERT
void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
if (mask.fFormat == SkMask::kBW_Format) {
SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
return;
} else if (SkMask::kARGB32_Format == mask.fFormat) {
SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
return;
} else if (SkMask::kLCD16_Format == mask.fFormat) {
blitmask_lcd16(fDevice, mask, clip, fPMColor);
return;
}
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
#if defined(SK_SUPPORT_LCDTEXT)
const bool lcdMode = mask.fFormat == SkMask::kHorizontalLCD_Format;
const bool verticalLCDMode = mask.fFormat == SkMask::kVerticalLCD_Format;
// In LCD mode the masks have either an extra couple of rows or columns on the edges.
if (lcdMode || verticalLCDMode) {
int widthAdjustment, heightAdjustment;
const uint32_t* alpha32;
uint32_t* device = adjustForSubpixelClip(mask, clip, fDevice, &widthAdjustment, &heightAdjustment, &alpha32);
width += widthAdjustment;
height += heightAdjustment;
unsigned devRB = fDevice.rowBytes() - (width << 2);
unsigned alphaExtraRowWords = mask.rowWordsLCD() - width;
SkPMColor srcColor = fPMColor;
do {
unsigned w = width;
do {
const uint32_t alphaPixel = *alpha32++;
const uint32_t originalPixel = *device;
*device++ = BlendLCDPixelWithOpaqueColor(alphaPixel, originalPixel, srcColor);
} while (--w != 0);
device = (uint32_t*)((char*)device + devRB);
alpha32 += alphaExtraRowWords;
} while (--height != 0);
return;
}
#endif
fBlitMaskProc(fDevice.getAddr32(x, y), fDevice.rowBytes(),
SkBitmap::kARGB_8888_Config,
mask.getAddr(x, y), mask.fRowBytes, fColor, width, height);
}
示例3: p
void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
// TODO: native BW masks?
return INHERITED::blitMask(mask, clip);
}
if (mask.fFormat == SkMask::kA8_Format && !fBlitMaskA8) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
if (fBlend == SkBlendMode::kSrcOver) {
p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
this->append_load_d(&p);
this->append_blend(&p);
} else {
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
}
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskA8 = p.compile();
}
if (mask.fFormat == SkMask::kLCD16_Format && !fBlitMaskLCD16) {
SkRasterPipeline p(fAlloc);
p.extend(fColorPipeline);
this->append_load_d(&p);
this->append_blend(&p);
p.append(SkRasterPipeline::lerp_565, &fMaskPtr);
this->maybe_clamp(&p);
this->append_store(&p);
fBlitMaskLCD16 = p.compile();
}
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
fDstPtr = fDst.writable_addr(0,y);
this->maybe_shade(x,y,clip.width());
switch (mask.fFormat) {
case SkMask::kA8_Format:
fMaskPtr = mask.getAddr8(x,y)-x;
fBlitMaskA8(x,y,clip.width());
break;
case SkMask::kLCD16_Format:
fMaskPtr = mask.getAddrLCD16(x,y)-x;
fBlitMaskLCD16(x,y,clip.width());
break;
default:
// TODO
break;
}
}
}
示例4: makeMask
bool makeMask(SkMask *m, const SkRect& r) override {
SkMask src;
r.roundOut(&src.fBounds);
src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to origin
src.fFormat = SkMask::kA8_Format;
src.fRowBytes = src.fBounds.width();
src.fImage = SkMask::AllocImage(src.computeTotalImageSize());
SkAutoMaskFreeImage amfi(src.fImage);
memset(src.fImage, 0xff, src.computeTotalImageSize());
return SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radius()),
m, src, this->style());
}
示例5: SkASSERT
void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
if (mask.fFormat == SkMask::kBW_Format) {
SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
return;
} else if (SkMask::kARGB32_Format == mask.fFormat) {
SkARGB32_Blit32(fDevice, mask, clip, fPMColor);
return;
} else if (SkMask::kLCD16_Format == mask.fFormat) {
blitmask_lcd16(fDevice, mask, clip, fPMColor);
return;
} else if (SkMask::kLCD32_Format == mask.fFormat) {
blitmask_lcd32(fDevice, mask, clip, fPMColor);
return;
}
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
fBlitMaskProc(fDevice.getAddr32(x, y), fDevice.rowBytes(),
SkBitmap::kARGB_8888_Config,
mask.getAddr(x, y), mask.fRowBytes, fColor, width, height);
}
示例6: SkASSERT
void SkARGB32_Opaque_Blitter::blitMask(const SkMask& mask,
const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
if (mask.fFormat == SkMask::kBW_Format) {
SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
return;
}
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
uint32_t* device = fDevice.getAddr32(x, y);
const uint8_t* alpha = mask.getAddr(x, y);
uint32_t srcColor = fPMColor;
unsigned devRB = fDevice.rowBytes() - (width << 2);
unsigned maskRB = mask.fRowBytes - width;
do {
int w = width;
do {
unsigned aa = *alpha++;
*device = SkAlphaMulQ(srcColor, SkAlpha255To256(aa)) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
device += 1;
} while (--w != 0);
device = (uint32_t*)((char*)device + devRB);
alpha += maskRB;
} while (--height != 0);
}
示例7: blitMask
void blitMask(const SkMask& mask, const SkIRect& clip) override {
if (SkMask::kLCD16_Format == mask.fFormat) {
this->blitLCDMask(mask, clip);
return;
}
if (SkMask::kA8_Format != mask.fFormat) {
this->INHERITED::blitMask(mask, clip);
return;
}
SkASSERT(mask.fBounds.contains(clip));
const int x = clip.fLeft;
const int width = clip.width();
const int y = clip.fTop;
const int height = clip.height();
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t dstRB = fDevice.rowBytes();
const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
for (int i = 0; i < height; ++i) {
fState.fProc1(fState.fXfer, device, &fState.fPM4f, width, maskRow);
device = (typename State::DstType*)((char*)device + dstRB);
maskRow += maskRB;
}
}
示例8: SkASSERT
void SkRGB16_Black_Blitter::blitMask(const SkMask& mask,
const SkIRect& clip) {
if (mask.fFormat == SkMask::kBW_Format) {
SkRGB16_Black_BlitBW(fDevice, mask, clip);
} else {
uint16_t* SK_RESTRICT device = fDevice.getAddr16(clip.fLeft, clip.fTop);
const uint8_t* SK_RESTRICT alpha = mask.getAddr8(clip.fLeft, clip.fTop);
unsigned width = clip.width();
unsigned height = clip.height();
size_t deviceRB = fDevice.rowBytes() - (width << 1);
unsigned maskRB = mask.fRowBytes - width;
SkASSERT((int)height > 0);
SkASSERT((int)width > 0);
SkASSERT((int)deviceRB >= 0);
SkASSERT((int)maskRB >= 0);
do {
unsigned w = width;
do {
unsigned aa = *alpha++;
*device = SkAlphaMulRGB16(*device, SkAlpha255To256(255 - aa));
device += 1;
} while (--w != 0);
device = (uint16_t*)((char*)device + deviceRB);
alpha += maskRB;
} while (--height != 0);
}
}
示例9: dump
static void dump(const SkMask& mask) {
for (int y = mask.fBounds.top(); y < mask.fBounds.bottom(); ++y) {
for (int x = mask.fBounds.left(); x < mask.fBounds.right(); ++x) {
SkDebugf("%02X", *mask.getAddr8(x, y));
}
SkDebugf("\n");
}
SkDebugf("\n");
}
示例10: SkASSERT
void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
// we only handle kA8 with an xfermode
if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) {
this->INHERITED::blitMask(mask, clip);
return;
}
SkASSERT(mask.fBounds.contains(clip));
SkBlitMask::RowProc proc = NULL;
if (!fXfermode) {
unsigned flags = 0;
if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) {
flags |= SkBlitMask::kSrcIsOpaque_RowFlag;
}
proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat,
(SkBlitMask::RowFlags)flags);
if (NULL == proc) {
this->INHERITED::blitMask(mask, clip);
return;
}
}
const int x = clip.fLeft;
const int width = clip.width();
int y = clip.fTop;
int height = clip.height();
char* dstRow = (char*)fDevice.getAddr32(x, y);
const size_t dstRB = fDevice.rowBytes();
const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
SkShader* shader = fShader;
SkPMColor* span = fBuffer;
if (fXfermode) {
SkASSERT(SkMask::kA8_Format == mask.fFormat);
SkXfermode* xfer = fXfermode;
do {
shader->shadeSpan(x, y, span, width);
xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow);
dstRow += dstRB;
maskRow += maskRB;
y += 1;
} while (--height > 0);
} else {
do {
shader->shadeSpan(x, y, span, width);
proc(dstRow, maskRow, span, width);
dstRow += dstRB;
maskRow += maskRB;
y += 1;
} while (--height > 0);
}
}
示例11: merge_src_with_blur
bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, SkScalar sigma, SkBlurStyle style,
SkIPoint* margin) {
if (src.fFormat != SkMask::kA8_Format && src.fFormat != SkMask::kARGB32_Format) {
return false;
}
SkIPoint border;
SkMaskBlurFilter blurFilter{sigma, sigma};
if (blurFilter.hasNoBlur()) {
return false;
}
border = blurFilter.blur(src, dst);
// If src.fImage is null, then this call is only to calculate the border.
if (src.fImage != nullptr && dst->fImage == nullptr) {
return false;
}
if (src.fImage != nullptr) {
// if need be, alloc the "real" dst (same size as src) and copy/merge
// the blur into it (applying the src)
if (style == kInner_SkBlurStyle) {
// now we allocate the "real" dst, mirror the size of src
size_t srcSize = src.computeImageSize();
if (0 == srcSize) {
return false; // too big to allocate, abort
}
auto blur = dst->fImage;
dst->fImage = SkMask::AllocImage(srcSize);
auto blurStart = &blur[border.x() + border.y() * dst->fRowBytes];
merge_src_with_blur(dst->fImage, src.fRowBytes,
src.fImage, src.fRowBytes,
blurStart,
dst->fRowBytes,
src.fBounds.width(), src.fBounds.height());
SkMask::FreeImage(blur);
} else if (style != kNormal_SkBlurStyle) {
auto dstStart = &dst->fImage[border.x() + border.y() * dst->fRowBytes];
clamp_with_orig(dstStart,
dst->fRowBytes, src.fImage, src.fRowBytes,
src.fBounds.width(), src.fBounds.height(), style);
}
}
if (style == kInner_SkBlurStyle) {
dst->fBounds = src.fBounds; // restore trimmed bounds
dst->fRowBytes = src.fRowBytes;
}
if (margin != nullptr) {
*margin = border;
}
return true;
}
示例12: SkScalarCeilToInt
bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src,
const SkMatrix& matrix, SkIPoint* margin) const {
SkScalar sigma = matrix.mapRadius(fBlurSigma);
if (!SkBlurMask::BoxBlur(dst, src, sigma, SkBlurMask::kInner_Style,
SkBlurMask::kLow_Quality)) {
return false;
}
dst->fFormat = SkMask::k3D_Format;
if (margin) {
margin->set(SkScalarCeilToInt(3*sigma), SkScalarCeilToInt(3*sigma));
}
if (src.fImage == NULL) {
return true;
}
// create a larger buffer for the other two channels (should force fBlur to do this for us)
{
uint8_t* alphaPlane = dst->fImage;
size_t planeSize = dst->computeImageSize();
if (0 == planeSize) {
return false; // too big to allocate, abort
}
dst->fImage = SkMask::AllocImage(planeSize * 3);
memcpy(dst->fImage, alphaPlane, planeSize);
SkMask::FreeImage(alphaPlane);
}
// run the light direction through the matrix...
Light light = fLight;
matrix.mapVectors((SkVector*)(void*)light.fDirection,
(SkVector*)(void*)fLight.fDirection, 1);
// now restore the length of the XY component
// cast to SkVector so we can call setLength (this double cast silences alias warnings)
SkVector* vec = (SkVector*)(void*)light.fDirection;
vec->setLength(light.fDirection[0],
light.fDirection[1],
SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1]));
SkEmbossMask::Emboss(dst, light);
// restore original alpha
memcpy(dst->fImage, src.fImage, src.computeImageSize());
return true;
}
示例13: blitmask_lcd16
static void blitmask_lcd16(const SkBitmap& device, const SkMask& mask,
const SkIRect& clip, SkPMColor srcColor) {
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
SkPMColor* dstRow = device.getAddr32(x, y);
const uint16_t* srcRow = mask.getAddrLCD16(x, y);
do {
blit_lcd16_opaque(dstRow, srcRow, srcColor, width);
dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes());
srcRow = (const uint16_t*)((const char*)srcRow + mask.fRowBytes);
} while (--height != 0);
}
示例14: blitLCDMask
void blitLCDMask(const SkMask& mask, const SkIRect& clip) {
auto proc = fState.getLCDProc(SkXfermode::kSrcIsSingle_LCDFlag);
const int x = clip.fLeft;
const int width = clip.width();
const int y = clip.fTop;
const int height = clip.height();
typename State::DstType* device = State::WritableAddr(fDevice, x, y);
const size_t dstRB = fDevice.rowBytes();
const uint16_t* maskRow = (const uint16_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
for (int i = 0; i < height; ++i) {
proc(device, &fState.fPM4f, width, maskRow);
device = (typename State::DstType*)((char*)device + dstRB);
maskRow = (const uint16_t*)((const char*)maskRow + maskRB);
}
}
示例15: SkARGB32_Blit32
static void SkARGB32_Blit32(const SkPixmap& device, const SkMask& mask,
const SkIRect& clip, SkPMColor srcColor) {
U8CPU alpha = SkGetPackedA32(srcColor);
unsigned flags = SkBlitRow::kSrcPixelAlpha_Flag32;
if (alpha != 255) {
flags |= SkBlitRow::kGlobalAlpha_Flag32;
}
SkBlitRow::Proc32 proc = SkBlitRow::Factory32(flags);
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
SkPMColor* dstRow = device.writable_addr32(x, y);
const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr8(x, y));
do {
proc(dstRow, srcRow, width, alpha);
dstRow = (SkPMColor*)((char*)dstRow + device.rowBytes());
srcRow = (const SkPMColor*)((const char*)srcRow + mask.fRowBytes);
} while (--height != 0);
}