本文整理汇总了C++中GrPaint::isAntiAlias方法的典型用法代码示例。如果您正苦于以下问题:C++ GrPaint::isAntiAlias方法的具体用法?C++ GrPaint::isAntiAlias怎么用?C++ GrPaint::isAntiAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrPaint
的用法示例。
在下文中一共展示了GrPaint::isAntiAlias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDashLine
bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const GrPaint& paint,
const GrStrokeInfo& strokeInfo, GrGpu* gpu,
GrDrawTarget* target, const SkMatrix& vm) {
if (!can_fast_path_dash(pts, strokeInfo, *target, vm)) {
return false;
}
const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap();
SkScalar srcStrokeWidth = strokeInfo.getStrokeRec().getWidth();
// the phase should be normalized to be [0, sum of all intervals)
SkASSERT(info.fPhase >= 0 && info.fPhase < info.fIntervals[0] + info.fIntervals[1]);
SkScalar srcPhase = info.fPhase;
// Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[1].fX
SkMatrix srcRotInv;
SkPoint ptsRot[2];
if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) {
SkMatrix rotMatrix;
align_to_x_axis(pts, &rotMatrix, ptsRot);
if(!rotMatrix.invert(&srcRotInv)) {
GrPrintf("Failed to create invertible rotation matrix!\n");
return false;
}
} else {
srcRotInv.reset();
memcpy(ptsRot, pts, 2 * sizeof(SkPoint));
}
bool useAA = paint.isAntiAlias();
// Scale corrections of intervals and stroke from view matrix
SkScalar parallelScale;
SkScalar perpScale;
calc_dash_scaling(¶llelScale, &perpScale, vm, ptsRot);
bool hasCap = SkPaint::kButt_Cap != cap && 0 != srcStrokeWidth;
// We always want to at least stroke out half a pixel on each side in device space
// so 0.5f / perpScale gives us this min in src space
SkScalar halfSrcStroke = SkMaxScalar(srcStrokeWidth * 0.5f, 0.5f / perpScale);
SkScalar strokeAdj;
if (!hasCap) {
strokeAdj = 0.f;
} else {
strokeAdj = halfSrcStroke;
}
SkScalar startAdj = 0;
SkMatrix combinedMatrix = srcRotInv;
combinedMatrix.postConcat(vm);
bool lineDone = false;
SkRect startRect;
bool hasStartRect = false;
// If we are using AA, check to see if we are drawing a partial dash at the start. If so
// draw it separately here and adjust our start point accordingly
if (useAA) {
if (srcPhase > 0 && srcPhase < info.fIntervals[0]) {
SkPoint startPts[2];
startPts[0] = ptsRot[0];
startPts[1].fY = startPts[0].fY;
startPts[1].fX = SkMinScalar(startPts[0].fX + info.fIntervals[0] - srcPhase,
ptsRot[1].fX);
startRect.set(startPts, 2);
startRect.outset(strokeAdj, halfSrcStroke);
hasStartRect = true;
startAdj = info.fIntervals[0] + info.fIntervals[1] - srcPhase;
}
}
// adjustments for start and end of bounding rect so we only draw dash intervals
// contained in the original line segment.
startAdj += calc_start_adjustment(info);
if (startAdj != 0) {
ptsRot[0].fX += startAdj;
srcPhase = 0;
}
SkScalar endingInterval = 0;
SkScalar endAdj = calc_end_adjustment(info, ptsRot, srcPhase, &endingInterval);
ptsRot[1].fX -= endAdj;
if (ptsRot[0].fX >= ptsRot[1].fX) {
lineDone = true;
}
SkRect endRect;
bool hasEndRect = false;
// If we are using AA, check to see if we are drawing a partial dash at then end. If so
// draw it separately here and adjust our end point accordingly
if (useAA && !lineDone) {
// If we adjusted the end then we will not be drawing a partial dash at the end.
// If we didn't adjust the end point then we just need to make sure the ending
//.........这里部分代码省略.........
示例2: pipelineBuilder
void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
GrDrawContext* drawContext,
const GrPaint& grPaint,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
SkScalar x, SkScalar y,
const SkIRect& clipBounds,
GrAtlasTextContext* fallbackTextContext,
const SkPaint& originalSkPaint) const {
SkASSERT(fInstanceData);
SkASSERT(drawContext->isStencilBufferMultisampled() || !grPaint.isAntiAlias());
if (fInstanceData->count()) {
static constexpr GrUserStencilSettings kCoverPass(
GrUserStencilSettings::StaticInit<
0x0000,
GrUserStencilTest::kNotEqual, // Stencil pass accounts for clip.
0xffff,
GrUserStencilOp::kZero,
GrUserStencilOp::kKeep,
0xffff>()
);
SkAutoTUnref<GrPathRange> glyphs(this->createGlyphs(ctx));
if (fLastDrawnGlyphsID != glyphs->uniqueID()) {
// Either this is the first draw or the glyphs object was purged since last draw.
glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->count());
fLastDrawnGlyphsID = glyphs->uniqueID();
}
// Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy
// the entire dst. Realistically this is a moot point, because any context that supports
// NV_path_rendering will also support NV_blend_equation_advanced.
// For clipping we'll just skip any optimizations based on the bounds. This does, however,
// hurt batching.
const SkRect bounds = SkRect::MakeIWH(drawContext->width(), drawContext->height());
SkAutoTUnref<GrDrawBatch> batch(
GrDrawPathRangeBatch::Create(viewMatrix, fTextRatio, fTextInverseRatio * x,
fTextInverseRatio * y, grPaint.getColor(),
GrPathRendering::kWinding_FillType, glyphs, fInstanceData,
bounds));
GrPipelineBuilder pipelineBuilder(grPaint);
pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, grPaint.isAntiAlias());
pipelineBuilder.setUserStencil(&kCoverPass);
drawContext->drawBatch(pipelineBuilder, clip, batch);
}
if (fFallbackTextBlob) {
SkPaint fallbackSkPaint(originalSkPaint);
fStyle.strokeRec().applyToPaint(&fallbackSkPaint);
if (!fStyle.isSimpleFill()) {
fallbackSkPaint.setStrokeWidth(fStyle.strokeRec().getWidth() * fTextRatio);
}
fallbackTextContext->drawTextBlob(ctx, drawContext, clip, fallbackSkPaint, viewMatrix,
props, fFallbackTextBlob.get(), x, y, nullptr,
clipBounds);
}
}