本文整理汇总了C++中SkPaint::getPathEffect方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getPathEffect方法的具体用法?C++ SkPaint::getPathEffect怎么用?C++ SkPaint::getPathEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getPathEffect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canDraw
bool GrStencilAndCoverTextContext::canDraw(const GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
const SkMatrix& viewMatrix) {
if (skPaint.getRasterizer()) {
return false;
}
if (skPaint.getMaskFilter()) {
return false;
}
if (SkPathEffect* pe = skPaint.getPathEffect()) {
if (pe->asADash(NULL) != SkPathEffect::kDash_DashType) {
return false;
}
}
// No hairlines unless we can map the 1 px width to the object space.
if (skPaint.getStyle() == SkPaint::kStroke_Style
&& skPaint.getStrokeWidth() == 0
&& viewMatrix.hasPerspective()) {
return false;
}
// No color bitmap fonts.
SkScalerContext::Rec rec;
SkScalerContext::MakeRec(skPaint, &fDeviceProperties, NULL, &rec);
return rec.getFormat() != SkMask::kARGB32_Format;
}
示例2: drawTextBlob
void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, GrRenderTargetContext* rtc,
const GrClip& clip, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const SkSurfaceProps& props,
const SkTextBlob* skBlob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter,
const SkIRect& clipBounds) {
if (context->abandoned()) {
return;
}
if (!this->internalCanDraw(skPaint)) {
fFallbackTextContext->drawTextBlob(context, rtc, clip, skPaint, viewMatrix, props, skBlob,
x, y, drawFilter, clipBounds);
return;
}
if (drawFilter || skPaint.getPathEffect()) {
// This draw can't be cached.
this->uncachedDrawTextBlob(context, rtc, clip, skPaint, viewMatrix, props, skBlob, x, y,
drawFilter, clipBounds);
return;
}
const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint);
TextBlob::Iter iter(blob);
for (TextRun *run = iter.get(), *nextRun; run; run = nextRun) {
nextRun = iter.next();
run->draw(context, rtc, clip, viewMatrix, props, x, y, clipBounds, fFallbackTextContext,
skPaint);
run->releaseGlyphCache();
}
}
示例3: apply_paint_patheffect
static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, bool sendBinaries) {
SkPathEffect* pathEffect = paint.getPathEffect();
if (pathEffect != nullptr) {
SkPathEffect::DashInfo dashInfo;
SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo);
if (dashType == SkPathEffect::kDash_DashType) {
dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar));
pathEffect->asADash(&dashInfo);
Json::Value dashing(Json::objectValue);
Json::Value intervals(Json::arrayValue);
for (int32_t i = 0; i < dashInfo.fCount; i++) {
intervals.append(Json::Value(dashInfo.fIntervals[i]));
}
free(dashInfo.fIntervals);
dashing[SKJSONCANVAS_ATTRIBUTE_INTERVALS] = intervals;
dashing[SKJSONCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase;
(*target)[SKJSONCANVAS_ATTRIBUTE_DASHING] = dashing;
}
else {
Json::Value jsonPathEffect;
flatten(pathEffect, &jsonPathEffect, sendBinaries);
(*target)[SKJSONCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect;
}
}
}
示例4: ShouldDisableLCD
bool GrTextUtils::ShouldDisableLCD(const SkPaint& paint) {
return !SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
paint.getMaskFilter() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style;
}
示例5: drawArc
void SkBaseDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar startAngle,
SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
SkPath path;
bool isFillNoPathEffect = SkPaint::kFill_Style == paint.getStyle() && !paint.getPathEffect();
SkPathPriv::CreateDrawArcPath(&path, oval, startAngle, sweepAngle, useCenter,
isFillNoPathEffect);
this->drawPath(draw, path, paint);
}
示例6: fold_opacity_layer_color_to_paint
static bool fold_opacity_layer_color_to_paint(const SkPaint& layerPaint,
bool isSaveLayer,
SkPaint* paint) {
// We assume layerPaint is always from a saveLayer. If isSaveLayer is
// true, we assume paint is too.
// The alpha folding can proceed if the filter layer paint does not have properties which cause
// the resulting filter layer to be "blended" in complex ways to the parent layer. For example,
// looper drawing unmodulated filter layer twice and then modulating the result produces
// different image to drawing modulated filter layer twice.
// TODO: most likely the looper and only some xfer modes are the hard constraints
if (paint->getXfermode() || paint->getLooper()) {
return false;
}
if (!isSaveLayer && paint->getImageFilter()) {
// For normal draws, the paint color is used as one input for the color for the draw. Image
// filter will operate on the result, and thus we can not change the input.
// For layer saves, the image filter is applied to the layer contents. The layer is then
// modulated with the paint color, so it's fine to proceed with the fold for saveLayer
// paints with image filters.
return false;
}
if (paint->getColorFilter()) {
// Filter input depends on the paint color.
// Here we could filter the color if we knew the draw is going to be uniform color. This
// should be detectable as drawPath/drawRect/.. without a shader being uniform, while
// drawBitmap/drawSprite or a shader being non-uniform. However, current matchers don't
// give the type out easily, so just do not optimize that at the moment.
return false;
}
const uint32_t layerColor = layerPaint.getColor();
// The layer paint color must have only alpha component.
if (SK_ColorTRANSPARENT != SkColorSetA(layerColor, SK_AlphaTRANSPARENT)) {
return false;
}
// The layer paint can not have any effects.
if (layerPaint.getPathEffect() ||
layerPaint.getShader() ||
layerPaint.getXfermode() ||
layerPaint.getMaskFilter() ||
layerPaint.getColorFilter() ||
layerPaint.getRasterizer() ||
layerPaint.getLooper() ||
layerPaint.getImageFilter()) {
return false;
}
paint->setAlpha(SkMulDiv255Round(paint->getAlpha(), SkColorGetA(layerColor)));
return true;
}
示例7: is_simple
// Is the supplied paint simply a color?
static bool is_simple(const SkPaint& p) {
return NULL == p.getPathEffect() &&
NULL == p.getShader() &&
NULL == p.getXfermode() &&
NULL == p.getMaskFilter() &&
NULL == p.getColorFilter() &&
NULL == p.getRasterizer() &&
NULL == p.getLooper() &&
NULL == p.getImageFilter();
}
示例8: HasAnyEffect
static bool HasAnyEffect(const SkPaint& paint) {
return paint.getPathEffect() ||
paint.getShader() ||
paint.getXfermode() ||
paint.getMaskFilter() ||
paint.getColorFilter() ||
paint.getRasterizer() ||
paint.getLooper() ||
paint.getImageFilter();
}
示例9: onShouldDisableLCD
bool SkBitmapDevice::onShouldDisableLCD(const SkPaint& paint) const {
if (kN32_SkColorType != fBitmap.colorType() ||
paint.getRasterizer() ||
paint.getPathEffect() ||
paint.isFakeBoldText() ||
paint.getStyle() != SkPaint::kFill_Style ||
!SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
{
return true;
}
return false;
}
示例10: DrawPosTextAsPath
void GrTextUtils::DrawPosTextAsPath(GrContext* context,
GrDrawContext* dc,
const SkSurfaceProps& props,
const GrClip& clip,
const SkPaint& origPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
// setup our std paint, in hopes of getting hits in the cache
SkPaint paint(origPaint);
SkScalar matrixScale = paint.setupForAsPaths();
SkMatrix matrix;
matrix.setScale(matrixScale, matrixScale);
// Temporarily jam in kFill, so we only ever ask for the raw outline from the cache.
paint.setStyle(SkPaint::kFill_Style);
paint.setPathEffect(nullptr);
SkPaint::GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(true);
SkAutoGlyphCache autoCache(paint, &props, nullptr);
SkGlyphCache* cache = autoCache.getCache();
const char* stop = text + byteLength;
SkTextAlignProc alignProc(paint.getTextAlign());
SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition);
// Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle());
paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache, &text);
if (glyph.fWidth) {
const SkPath* path = cache->findPath(glyph);
if (path) {
SkPoint tmsLoc;
tmsProc(pos, &tmsLoc);
SkPoint loc;
alignProc(tmsLoc, glyph, &loc);
matrix[SkMatrix::kMTransX] = loc.fX;
matrix[SkMatrix::kMTransY] = loc.fY;
GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, *path, paint,
viewMatrix, &matrix, clipBounds, false);
}
}
pos += scalarsPerPosition;
}
}
示例11: SkASSERT
static uint16_t compute_nondef(const SkPaint& paint, PaintUsage usage) {
// kRespectsStroke_PaintUsage is only valid if other bits are also set
SkASSERT(0 != (usage & ~kRespectsStroke_PaintUsage));
const SkScalar kTextSize_Default = 12;
const SkScalar kTextScaleX_Default = 1;
const SkScalar kTextSkewX_Default = 0;
const SkScalar kStrokeWidth_Default = 0;
const SkScalar kStrokeMiter_Default = 4;
const SkColor kColor_Default = SK_ColorBLACK;
unsigned bits = (paint.getColor() != kColor_Default) ? kColor_NonDef : 0;
if (usage & kText_PaintUsage) {
bits |= (paint.getTextSize() != kTextSize_Default ? kTextSize_NonDef : 0);
bits |= (paint.getTextScaleX() != kTextScaleX_Default ? kTextScaleX_NonDef : 0);
bits |= (paint.getTextSkewX() != kTextSkewX_Default ? kTextSkewX_NonDef : 0);
bits |= (paint.getTypeface() ? kTypeface_NonDef : 0);
}
// TODO: kImage_PaintUsage only needs the shader/maskfilter IF its colortype is kAlpha_8
if (usage & (kVertices_PaintUsage | kDrawPaint_PaintUsage | kImage_PaintUsage |
kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) {
bits |= (paint.getShader() ? kShader_NonDef : 0);
}
if (usage & (kText_PaintUsage | kGeometry_PaintUsage | kTextBlob_PaintUsage)) {
bits |= (paint.getPathEffect() ? kPathEffect_NonDef : 0);
bits |= (paint.getRasterizer() ? kRasterizer_NonDef : 0);
if (paint.getStyle() != SkPaint::kFill_Style || (usage & kRespectsStroke_PaintUsage)) {
bits |= (paint.getStrokeWidth() != kStrokeWidth_Default ? kStrokeWidth_NonDef : 0);
bits |= (paint.getStrokeMiter() != kStrokeMiter_Default ? kStrokeMiter_NonDef : 0);
}
}
if (usage &
(kText_PaintUsage | kGeometry_PaintUsage | kImage_PaintUsage | kTextBlob_PaintUsage))
{
bits |= (paint.getMaskFilter() ? kMaskFilter_NonDef : 0);
}
bits |= (paint.getColorFilter() ? kColorFilter_NonDef : 0);
bits |= (paint.getImageFilter() ? kImageFilter_NonDef : 0);
bits |= (paint.getDrawLooper() ? kDrawLooper_NonDef : 0);
return SkToU16(bits);
}
示例12: internalCanDraw
bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) {
if (skPaint.getRasterizer()) {
return false;
}
if (skPaint.getMaskFilter()) {
return false;
}
if (SkPathEffect* pe = skPaint.getPathEffect()) {
if (pe->asADash(nullptr) != SkPathEffect::kDash_DashType) {
return false;
}
}
// No hairlines. They would require new paths with customized strokes for every new draw matrix.
return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrokeWidth();
}
示例13: drawPathWithMaskFilter
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrDrawContext* drawContext,
const GrClip& clip,
const SkPath& origSrcPath,
const SkPaint& paint,
const SkMatrix& origViewMatrix,
const SkMatrix* prePathMatrix,
const SkIRect& clipBounds,
bool pathIsMutable) {
SkASSERT(!pathIsMutable || origSrcPath.isVolatile());
GrStrokeInfo strokeInfo(paint);
// comment out the line below to determine if it is the reason that the chrome mac perf bot
// has begun crashing
// strokeInfo.setResScale(SkDraw::ComputeResScaleForStroking(origViewMatrix));
// If we have a prematrix, apply it to the path, optimizing for the case
// where the original path can in fact be modified in place (even though
// its parameter type is const).
SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath);
SkTLazy<SkPath> tmpPath;
SkTLazy<SkPath> effectPath;
SkPathEffect* pathEffect = paint.getPathEffect();
SkMatrix viewMatrix = origViewMatrix;
if (prePathMatrix) {
// stroking, path effects, and blurs are supposed to be applied *after* the prePathMatrix.
// The pre-path-matrix also should not affect shading.
if (!paint.getMaskFilter() && !pathEffect && !paint.getShader() &&
(strokeInfo.isFillStyle() || strokeInfo.isHairlineStyle())) {
viewMatrix.preConcat(*prePathMatrix);
} else {
SkPath* result = pathPtr;
if (!pathIsMutable) {
result = tmpPath.init();
result->setIsVolatile(true);
pathIsMutable = true;
}
// should I push prePathMatrix on our MV stack temporarily, instead
// of applying it here? See SkDraw.cpp
pathPtr->transform(*prePathMatrix, result);
pathPtr = result;
}
}
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
示例14: 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();
}
}
示例15: 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());
}