本文整理汇总了C++中SkGlyph::computeImageSize方法的典型用法代码示例。如果您正苦于以下问题:C++ SkGlyph::computeImageSize方法的具体用法?C++ SkGlyph::computeImageSize怎么用?C++ SkGlyph::computeImageSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkGlyph
的用法示例。
在下文中一共展示了SkGlyph::computeImageSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateImage
void SkRandomScalerContext::generateImage(const SkGlyph& glyph) {
SkMask::Format format = (SkMask::Format)glyph.fMaskFormat;
switch (glyph.getGlyphID() % 4) {
case 0:
format = SkMask::kLCD16_Format;
break;
case 1:
format = SkMask::kA8_Format;
break;
case 2:
format = SkMask::kARGB32_Format;
break;
case 3:
format = SkMask::kBW_Format;
break;
}
const_cast<SkGlyph&>(glyph).fMaskFormat = format;
// if the format is ARGB, we just draw the glyph from path ourselves. Otherwise, we force
// our proxy context to generate the image from paths.
if (!fFakeIt) {
if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
SkPath path;
fProxy->getPath(glyph, &path);
SkBitmap bm;
bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight),
glyph.fImage, glyph.rowBytes());
bm.eraseColor(0);
SkCanvas canvas(bm);
canvas.translate(-SkIntToScalar(glyph.fLeft),
-SkIntToScalar(glyph.fTop));
canvas.drawPath(path, fFace->paint());
} else {
fProxy->forceGenerateImageFromPath();
fProxy->getImage(glyph);
fProxy->forceOffGenerateImageFromPath();
}
} else {
sk_bzero(glyph.fImage, glyph.computeImageSize());
}
}
示例2: generateImage
void RandomScalerContext::generateImage(const SkGlyph& glyph) {
// TODO: can force down but not up
/*
SkMask::Format format = (SkMask::Format)glyph.fMaskFormat;
switch (glyph.getGlyphID() % 4) {
case 0: format = SkMask::kLCD16_Format; break;
case 1: format = SkMask::kA8_Format; break;
case 2: format = SkMask::kARGB32_Format; break;
case 3: format = SkMask::kBW_Format; break;
}
const_cast<SkGlyph&>(glyph).fMaskFormat = format;
*/
if (fFakeIt) {
sk_bzero(glyph.fImage, glyph.computeImageSize());
return;
}
if (SkMask::kARGB32_Format != glyph.fMaskFormat) {
fProxy->getImage(glyph);
return;
}
// If the format is ARGB, just draw the glyph from path.
SkPath path;
if (!fProxy->getPath(glyph.getPackedID(), &path)) {
fProxy->getImage(glyph);
return;
}
SkBitmap bm;
bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight),
glyph.fImage,
glyph.rowBytes());
bm.eraseColor(0);
SkCanvas canvas(bm);
canvas.translate(-SkIntToScalar(glyph.fLeft), -SkIntToScalar(glyph.fTop));
canvas.drawPath(path, this->getRandomTypeface()->paint());
}
示例3: getImage
void SkScalerContext::getImage(const SkGlyph& origGlyph) {
const SkGlyph* glyph = &origGlyph;
SkGlyph tmpGlyph;
// in case we need to call generateImage on a mask-format that is different
// (i.e. larger) than what our caller allocated by looking at origGlyph.
SkAutoMalloc tmpGlyphImageStorage;
// If we are going to draw-from-path, then we cannot generate color, since
// the path only makes a mask. This case should have been caught up in
// generateMetrics().
SkASSERT(!fGenerateImageFromPath ||
SkMask::kARGB32_Format != origGlyph.fMaskFormat);
if (fMaskFilter) { // restore the prefilter bounds
tmpGlyph.initGlyphIdFrom(origGlyph);
// need the original bounds, sans our maskfilter
SkMaskFilter* mf = fMaskFilter;
fMaskFilter = nullptr; // temp disable
this->getMetrics(&tmpGlyph);
fMaskFilter = mf; // restore
// we need the prefilter bounds to be <= filter bounds
SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
SkASSERT(tmpGlyph.fHeight <= origGlyph.fHeight);
if (tmpGlyph.fMaskFormat == origGlyph.fMaskFormat) {
tmpGlyph.fImage = origGlyph.fImage;
} else {
tmpGlyphImageStorage.reset(tmpGlyph.computeImageSize());
tmpGlyph.fImage = tmpGlyphImageStorage.get();
}
glyph = &tmpGlyph;
}
if (fGenerateImageFromPath) {
SkPath devPath, fillPath;
SkMatrix fillToDevMatrix;
SkMask mask;
this->internalGetPath(*glyph, &fillPath, &devPath, &fillToDevMatrix);
glyph->toMask(&mask);
if (fRasterizer) {
mask.fFormat = SkMask::kA8_Format;
sk_bzero(glyph->fImage, mask.computeImageSize());
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
fMaskFilter, &mask,
SkMask::kJustRenderImage_CreateMode)) {
return;
}
if (fPreBlend.isApplicable()) {
applyLUTToA8Mask(mask, fPreBlend.fG);
}
} else {
SkASSERT(SkMask::kARGB32_Format != mask.fFormat);
generateMask(mask, devPath, fPreBlend);
}
} else {
generateImage(*glyph);
}
if (fMaskFilter) {
SkMask srcM, dstM;
SkMatrix matrix;
// the src glyph image shouldn't be 3D
SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat);
SkAutoSMalloc<32*32> a8storage;
glyph->toMask(&srcM);
if (SkMask::kARGB32_Format == srcM.fFormat) {
// now we need to extract the alpha-channel from the glyph's image
// and copy it into a temp buffer, and then point srcM at that temp.
srcM.fFormat = SkMask::kA8_Format;
srcM.fRowBytes = SkAlign4(srcM.fBounds.width());
size_t size = srcM.computeImageSize();
a8storage.reset(size);
srcM.fImage = (uint8_t*)a8storage.get();
extract_alpha(srcM,
(const SkPMColor*)glyph->fImage, glyph->rowBytes());
}
fRec.getMatrixFrom2x2(&matrix);
if (fMaskFilter->filterMask(&dstM, srcM, matrix, nullptr)) {
int width = SkFastMin32(origGlyph.fWidth, dstM.fBounds.width());
int height = SkFastMin32(origGlyph.fHeight, dstM.fBounds.height());
int dstRB = origGlyph.rowBytes();
int srcRB = dstM.fRowBytes;
const uint8_t* src = (const uint8_t*)dstM.fImage;
uint8_t* dst = (uint8_t*)origGlyph.fImage;
if (SkMask::k3D_Format == dstM.fFormat) {
// we have to copy 3 times as much
height *= 3;
}
//.........这里部分代码省略.........