本文整理汇总了C++中SkScalerContext::getPath方法的典型用法代码示例。如果您正苦于以下问题:C++ SkScalerContext::getPath方法的具体用法?C++ SkScalerContext::getPath怎么用?C++ SkScalerContext::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkScalerContext
的用法示例。
在下文中一共展示了SkScalerContext::getPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateMetrics
void SkGScalerContext::generateMetrics(SkGlyph* glyph) {
fProxy->getMetrics(glyph);
SkVector advance;
fMatrix.mapXY(SkFloatToScalar(glyph->fAdvanceX),
SkFloatToScalar(glyph->fAdvanceY), &advance);
glyph->fAdvanceX = SkScalarToFloat(advance.fX);
glyph->fAdvanceY = SkScalarToFloat(advance.fY);
SkPath path;
fProxy->getPath(*glyph, &path);
path.transform(fMatrix);
SkRect storage;
const SkPaint& paint = fFace->paint();
const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(),
&storage,
SkPaint::kFill_Style);
SkIRect ibounds;
newBounds.roundOut(&ibounds);
glyph->fLeft = ibounds.fLeft;
glyph->fTop = ibounds.fTop;
glyph->fWidth = ibounds.width();
glyph->fHeight = ibounds.height();
glyph->fMaskFormat = SkMask::kARGB32_Format;
}
示例2: generateMetrics
void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) {
fProxy->getAdvance(glyph);
SkVector advance;
fMatrix.mapXY(SkFixedToScalar(glyph->fAdvanceX),
SkFixedToScalar(glyph->fAdvanceY), &advance);
glyph->fAdvanceX = SkScalarToFixed(advance.fX);
glyph->fAdvanceY = SkScalarToFixed(advance.fY);
SkPath path;
fProxy->getPath(*glyph, &path);
path.transform(fMatrix);
SkRect storage;
const SkPaint& paint = fFace->paint();
const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(),
&storage,
SkPaint::kFill_Style);
SkIRect ibounds;
newBounds.roundOut(&ibounds);
glyph->fLeft = ibounds.fLeft;
glyph->fTop = ibounds.fTop;
glyph->fWidth = ibounds.width();
glyph->fHeight = ibounds.height();
// Here we will change the mask format of the glyph
// NOTE this is being overridden by the base class
SkMask::Format format;
switch (glyph->getGlyphID() % 6) {
case 0:
format = SkMask::kLCD16_Format;
break;
case 1:
format = SkMask::kA8_Format;
break;
case 2:
format = SkMask::kARGB32_Format;
break;
default:
// we will fiddle with these in generate image
format = (SkMask::Format)MASK_FORMAT_UNKNOWN;
}
glyph->fMaskFormat = format;
}
示例3: 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());
}
}
示例4: generateImage
void SkGScalerContext::generateImage(const SkGlyph& glyph) {
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.concat(fMatrix);
canvas.drawPath(path, fFace->paint());
} else {
fProxy->getImage(glyph);
}
}
示例5: generateMetrics
void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) {
// Here we will change the mask format of the glyph
// NOTE this is being overridden by the base class
SkMask::Format format = SkMask::kARGB32_Format; // init to handle defective compilers
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;
}
fProxy->getMetrics(glyph);
glyph->fMaskFormat = format;
if (fFakeIt) {
return;
}
if (SkMask::kARGB32_Format == format) {
SkPath path;
fProxy->getPath(*glyph, &path);
SkRect storage;
const SkPaint& paint = fFace->paint();
const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(),
&storage,
SkPaint::kFill_Style);
SkIRect ibounds;
newBounds.roundOut(&ibounds);
glyph->fLeft = ibounds.fLeft;
glyph->fTop = ibounds.fTop;
glyph->fWidth = ibounds.width();
glyph->fHeight = ibounds.height();
} else {
SkPath devPath, fillPath;
SkMatrix fillToDevMatrix;
this->internalGetPath(*glyph, &fillPath, &devPath, &fillToDevMatrix);
// just use devPath
const SkIRect ir = devPath.getBounds().roundOut();
if (ir.isEmpty() || !ir.is16Bit()) {
glyph->fLeft = 0;
glyph->fTop = 0;
glyph->fWidth = 0;
glyph->fHeight = 0;
return;
}
glyph->fLeft = ir.fLeft;
glyph->fTop = ir.fTop;
glyph->fWidth = SkToU16(ir.width());
glyph->fHeight = SkToU16(ir.height());
if (glyph->fWidth > 0) {
switch (glyph->fMaskFormat) {
case SkMask::kLCD16_Format:
glyph->fWidth += 2;
glyph->fLeft -= 1;
break;
default:
break;
}
}
}
}
示例6: generatePath
void SkRandomScalerContext::generatePath(const SkGlyph& glyph, SkPath* path) {
fProxy->getPath(glyph, path);
}
示例7: generatePath
void SkGScalerContext::generatePath(const SkGlyph& glyph, SkPath* path) {
fProxy->getPath(glyph, path);
path->transform(fMatrix);
}