本文整理汇总了C++中SkPaint::isAntiAlias方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::isAntiAlias方法的具体用法?C++ SkPaint::isAntiAlias怎么用?C++ SkPaint::isAntiAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::isAntiAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Make
sk_sp<SkFont> SkFont::Testing_CreateFromPaint(const SkPaint& paint) {
uint32_t flags = 0;
if (paint.isVerticalText()) {
flags |= kVertical_Flag;
}
if (paint.isEmbeddedBitmapText()) {
flags |= kEmbeddedBitmaps_Flag;
}
if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) {
flags |= kGenA8FromLCD_Flag;
}
if (paint.isFakeBoldText()) {
flags |= kEmbolden_Flag;
}
if (SkPaint::kFull_Hinting == paint.getHinting()) {
flags |= kEnableByteCodeHints_Flag;
}
if (paint.isAutohinted()) {
flags |= kEnableAutoHints_Flag;
}
if (paint.isSubpixelText() || paint.isLinearText()) {
// this is our default
} else {
flags |= kUseNonlinearMetrics_Flag;
}
MaskType maskType = SkFont::kBW_MaskType;
if (paint.isAntiAlias()) {
maskType = paint.isLCDRenderText() ? kLCD_MaskType : kA8_MaskType;
}
return Make(sk_ref_sp(paint.getTypeface()), paint.getTextSize(), paint.getTextScaleX(),
paint.getTextSkewX(), maskType, flags);
}
示例2: type
TessellationCache::Description::Description(Type type, const Matrix4& transform, const SkPaint& paint)
: type(type)
, aa(paint.isAntiAlias())
, cap(paint.getStrokeCap())
, style(paint.getStyle())
, strokeWidth(paint.getStrokeWidth()) {
PathTessellator::extractTessellationScales(transform, &scaleX, &scaleY);
memset(&shape, 0, sizeof(Shape));
}
示例3: FilterTextFlags
uint32_t GrTextUtils::FilterTextFlags(const SkSurfaceProps& surfaceProps, const SkPaint& paint) {
uint32_t flags = paint.getFlags();
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
return flags;
}
if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisableLCD(paint)) {
flags &= ~SkPaint::kLCDRenderText_Flag;
flags |= SkPaint::kGenA8FromLCD_Flag;
}
return flags;
}
示例4: filterTextFlags
uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const {
uint32_t flags = paint.getFlags();
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
return flags;
}
if (kUnknown_SkPixelGeometry == fSurfaceProps.pixelGeometry()
|| this->onShouldDisableLCD(paint)) {
flags &= ~SkPaint::kLCDRenderText_Flag;
flags |= SkPaint::kGenA8FromLCD_Flag;
}
return flags;
}
示例5: drawRegion
void SkBaseDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const SkPaint& paint) {
bool isNonTranslate = draw.fMatrix->getType() & ~(SkMatrix::kTranslate_Mask);
bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMaskFilter() ||
paint.getPathEffect();
bool antiAlias = paint.isAntiAlias() && (!is_int(draw.fMatrix->getTranslateX()) ||
!is_int(draw.fMatrix->getTranslateY()));
if (isNonTranslate || complexPaint || antiAlias) {
SkPath path;
region.getBoundaryPath(&path);
return this->drawPath(draw, path, paint, nullptr, false);
}
SkRegion::Iterator it(region);
while (!it.done()) {
this->drawRect(draw, SkRect::Make(it.rect()), paint);
it.next();
}
}
示例6: paint_write
static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
{
buffer.writeBool(paint.isAntiAlias());
buffer.write8(paint.getStyle());
buffer.write8(paint.getAlpha());
if (paint.getStyle() != SkPaint::kFill_Style)
{
buffer.writeScalar(paint.getStrokeWidth());
buffer.writeScalar(paint.getStrokeMiter());
buffer.write8(paint.getStrokeCap());
buffer.write8(paint.getStrokeJoin());
}
buffer.writeFlattenable(paint.getMaskFilter());
buffer.writeFlattenable(paint.getPathEffect());
buffer.writeFlattenable(paint.getRasterizer());
buffer.writeFlattenable(paint.getXfermode());
}
示例7: drawAndTest
static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
const SkPaint& paint, bool shouldDraw) {
SkBitmap bm;
bm.allocN32Pixels(DIMENSION, DIMENSION);
SkASSERT(DIMENSION*4 == bm.rowBytes()); // ensure no padding on each row
bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bm);
SkPaint p(paint);
p.setColor(SK_ColorWHITE);
canvas.drawPath(path, p);
size_t count = DIMENSION * DIMENSION;
const SkPMColor* ptr = bm.getAddr32(0, 0);
SkPMColor andValue = ~0U;
SkPMColor orValue = 0;
for (size_t i = 0; i < count; ++i) {
SkPMColor c = ptr[i];
andValue &= c;
orValue |= c;
}
// success means we drew everywhere or nowhere (depending on shouldDraw)
bool success = shouldDraw ? (~0U == andValue) : (0 == orValue);
if (!success) {
const char* str;
if (shouldDraw) {
str = "Path expected to draw everywhere, but didn't. ";
} else {
str = "Path expected to draw nowhere, but did. ";
}
ERRORF(reporter, "%s style[%d] cap[%d] join[%d] antialias[%d]"
" filltype[%d] ptcount[%d]", str, paint.getStyle(),
paint.getStrokeCap(), paint.getStrokeJoin(),
paint.isAntiAlias(), path.getFillType(), path.countPoints());
// uncomment this if you want to step in to see the failure
// canvas.drawPath(path, p);
}
}
示例8: stringForSkPaintFlags
String LoggingCanvas::stringForSkPaintFlags(const SkPaint& paint)
{
if (!paint.getFlags())
return "none";
String flagsString = "";
appendFlagToString(&flagsString, paint.isAntiAlias(), "AntiAlias");
appendFlagToString(&flagsString, paint.isDither(), "Dither");
appendFlagToString(&flagsString, paint.isUnderlineText(), "UnderlinText");
appendFlagToString(&flagsString, paint.isStrikeThruText(), "StrikeThruText");
appendFlagToString(&flagsString, paint.isFakeBoldText(), "FakeBoldText");
appendFlagToString(&flagsString, paint.isLinearText(), "LinearText");
appendFlagToString(&flagsString, paint.isSubpixelText(), "SubpixelText");
appendFlagToString(&flagsString, paint.isDevKernText(), "DevKernText");
appendFlagToString(&flagsString, paint.isLCDRenderText(), "LCDRenderText");
appendFlagToString(&flagsString, paint.isEmbeddedBitmapText(), "EmbeddedBitmapText");
appendFlagToString(&flagsString, paint.isAutohinted(), "Autohinted");
appendFlagToString(&flagsString, paint.isVerticalText(), "VerticalText");
appendFlagToString(&flagsString, paint.getFlags() & SkPaint::kGenA8FromLCD_Flag, "GenA8FromLCD");
return flagsString;
}
示例9: cgSetPaintForText
static void cgSetPaintForText(CGContextRef cg, const SkPaint& paint) {
SkColor c = paint.getColor();
CGFloat rgba[] = {
SkColorGetB(c) / 255.0f,
SkColorGetG(c) / 255.0f,
SkColorGetR(c) / 255.0f,
SkColorGetA(c) / 255.0f,
};
CGContextSetRGBFillColor(cg, rgba[0], rgba[1], rgba[2], rgba[3]);
CGContextSetTextDrawingMode(cg, kCGTextFill);
CGContextSetFont(cg, typefaceToCGFont(paint.getTypeface()));
CGContextSetFontSize(cg, SkScalarToFloat(paint.getTextSize()));
CGContextSetAllowsFontSubpixelPositioning(cg, paint.isSubpixelText());
CGContextSetShouldSubpixelPositionFonts(cg, paint.isSubpixelText());
CGContextSetShouldAntialias(cg, paint.isAntiAlias());
CGContextSetShouldSmoothFonts(cg, paint.isLCDRenderText());
}
示例10: filterTextFlags
bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
// we're cool with the paint as is
return false;
}
if (kN32_SkColorType != fBitmap.colorType() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style ||
!SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
// turn off lcd
flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
flags->fHinting = paint.getHinting();
return true;
}
// we're cool with the paint as is
return false;
}
示例11: drawBitmapRect
void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const SkRect* srcOrNull,
const SkRect& dst, const SkPaint& paint,
SkCanvas::SrcRectConstraint) {
SkMatrix adjustedMatrix;
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
dst,
SkMatrix::kFill_ScaleToFit);
adjustedMatrix.postConcat(*draw.fMatrix);
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
SkClipStack adjustedClipStack;
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
adjustedClipStack = *draw.fClipStack;
adjustedClipStack.clipRect(dst, *draw.fMatrix, SkCanvas::kIntersect_Op,
paint.isAntiAlias());
adjustedDraw.fClipStack = &adjustedClipStack;
}
drawBitmapCommon(adjustedDraw, bm, paint);
}
示例12: filterTextFlags
bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
// we're cool with the paint as is
return false;
}
if (SkBitmap::kARGB_8888_Config != fBitmap.config() ||
paint.getShader() ||
paint.getXfermode() || // unless its srcover
paint.getMaskFilter() ||
paint.getRasterizer() ||
paint.getColorFilter() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style) {
// turn off lcd
flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
flags->fHinting = paint.getHinting();
return true;
}
// we're cool with the paint as is
return false;
}
示例13: makePaint
Json::Value SkJSONCanvas::makePaint(const SkPaint& paint) {
Json::Value result(Json::objectValue);
store_scalar(&result, SKJSONCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
store_scalar(&result, SKJSONCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMiter(),
SkPaintDefaults_MiterLimit);
store_bool(&result, SKJSONCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
store_scalar(&result, SKJSONCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
SkPaintDefaults_TextSize);
store_scalar(&result, SKJSONCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScaleX(), SK_Scalar1);
store_scalar(&result, SKJSONCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX(), 0.0f);
apply_paint_color(paint, &result);
apply_paint_style(paint, &result);
apply_paint_cap(paint, &result);
apply_paint_textalign(paint, &result);
apply_paint_patheffect(paint, &result, fSendBinaries);
apply_paint_maskfilter(paint, &result, fSendBinaries);
apply_paint_shader(paint, &result, fSendBinaries);
apply_paint_xfermode(paint, &result, fSendBinaries);
apply_paint_imagefilter(paint, &result, fSendBinaries);
apply_paint_colorfilter(paint, &result, fSendBinaries);
apply_paint_typeface(paint, &result, fSendBinaries);
return result;
}
示例14: drawBitmapRect
void SkSVGDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bm, const SkRect* srcOrNull,
const SkRect& dst, const SkPaint& paint,
SK_VIRTUAL_CONSTRAINT_TYPE) {
SkMatrix adjustedMatrix;
adjustedMatrix.setRectToRect(srcOrNull ? *srcOrNull : SkRect::Make(bm.bounds()),
dst,
SkMatrix::kFill_ScaleToFit);
adjustedMatrix.postConcat(*draw.fMatrix);
SkDraw adjustedDraw(draw);
adjustedDraw.fMatrix = &adjustedMatrix;
SkClipStack adjustedClipStack;
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
SkRect devClipRect;
draw.fMatrix->mapRect(&devClipRect, dst);
adjustedClipStack = *draw.fClipStack;
adjustedClipStack.clipDevRect(devClipRect, SkRegion::kIntersect_Op, paint.isAntiAlias());
adjustedDraw.fClipStack = &adjustedClipStack;
}
drawBitmapCommon(adjustedDraw, bm, paint);
}
示例15: drawTextureProducerImpl
void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
const SkRect& clippedSrcRect,
const SkRect& clippedDstRect,
SkCanvas::SrcRectConstraint constraint,
const SkMatrix& viewMatrix,
const SkMatrix& srcToDstMatrix,
const GrClip& clip,
const SkPaint& paint) {
// Specifying the texture coords as local coordinates is an attempt to enable more GrDrawOp
// combining by not baking anything about the srcRect, dstRect, or viewMatrix, into the texture
// FP. In the future this should be an opaque optimization enabled by the combination of
// GrDrawOp/GP and FP.
const SkMaskFilter* mf = paint.getMaskFilter();
// The shader expects proper local coords, so we can't replace local coords with texture coords
// if the shader will be used. If we have a mask filter we will change the underlying geometry
// that is rendered.
bool canUseTextureCoordsAsLocalCoords = !use_shader(producer->isAlphaOnly(), paint) && !mf;
bool doBicubic;
GrSamplerParams::FilterMode fm =
GrSkFilterQualityToGrFilterMode(paint.getFilterQuality(), viewMatrix, srcToDstMatrix,
&doBicubic);
const GrSamplerParams::FilterMode* filterMode = doBicubic ? nullptr : &fm;
GrTextureProducer::FilterConstraint constraintMode;
if (SkCanvas::kFast_SrcRectConstraint == constraint) {
constraintMode = GrTextureAdjuster::kNo_FilterConstraint;
} else {
constraintMode = GrTextureAdjuster::kYes_FilterConstraint;
}
// If we have to outset for AA then we will generate texture coords outside the src rect. The
// same happens for any mask filter that extends the bounds rendered in the dst.
// This is conservative as a mask filter does not have to expand the bounds rendered.
bool coordsAllInsideSrcRect = !paint.isAntiAlias() && !mf;
// Check for optimization to drop the src rect constraint when on bilerp.
if (filterMode && GrSamplerParams::kBilerp_FilterMode == *filterMode &&
GrTextureAdjuster::kYes_FilterConstraint == constraintMode && coordsAllInsideSrcRect) {
SkMatrix combinedMatrix;
combinedMatrix.setConcat(viewMatrix, srcToDstMatrix);
if (can_ignore_bilerp_constraint(*producer, clippedSrcRect, combinedMatrix,
fRenderTargetContext->isUnifiedMultisampled())) {
constraintMode = GrTextureAdjuster::kNo_FilterConstraint;
}
}
const SkMatrix* textureMatrix;
SkMatrix tempMatrix;
if (canUseTextureCoordsAsLocalCoords) {
textureMatrix = &SkMatrix::I();
} else {
if (!srcToDstMatrix.invert(&tempMatrix)) {
return;
}
textureMatrix = &tempMatrix;
}
sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
fRenderTargetContext->getColorSpace()));
if (!fp) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(fContext.get(), fRenderTargetContext.get(), paint, viewMatrix,
fp, producer->isAlphaOnly(), &grPaint)) {
return;
}
GrAA aa = GrBoolToAA(paint.isAntiAlias());
if (canUseTextureCoordsAsLocalCoords) {
fRenderTargetContext->fillRectToRect(clip, std::move(grPaint), aa, viewMatrix,
clippedDstRect, clippedSrcRect);
return;
}
if (!mf) {
fRenderTargetContext->drawRect(clip, std::move(grPaint), aa, viewMatrix, clippedDstRect);
return;
}
// First see if we can do the draw + mask filter direct to the dst.
if (viewMatrix.isScaleTranslate()) {
SkRect devClippedDstRect;
viewMatrix.mapRectScaleTranslate(&devClippedDstRect, clippedDstRect);
SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
if (mf->directFilterRRectMaskGPU(fContext.get(),
fRenderTargetContext.get(),
std::move(grPaint),
clip,
viewMatrix,
rec,
SkRRect::MakeRect(clippedDstRect),
SkRRect::MakeRect(devClippedDstRect))) {
return;
}
}
SkPath rectPath;
//.........这里部分代码省略.........