本文整理汇总了C++中SkPaint::getMaskFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getMaskFilter方法的具体用法?C++ SkPaint::getMaskFilter怎么用?C++ SkPaint::getMaskFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getMaskFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawContent
virtual void onDrawContent(SkCanvas* canvas) {
const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
SkPaint paint;
SkScalar x = SkIntToScalar(10);
SkScalar y = SkIntToScalar(20);
paint.setFlags(0x105);
paint.setARGB(fByte, 0xFF, 0xFF, 0xFF);
paint.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle));
paint.getMaskFilter()->unref();
SkRandom rand;
for (int ps = 6; ps <= 35; ps++) {
paint.setColor(rand.nextU() | (0xFF << 24));
paint.setTextSize(SkIntToScalar(ps));
paint.setTextSize(SkIntToScalar(24));
canvas->drawText(str, strlen(str), x, y, paint);
y += paint.getFontMetrics(NULL);
}
if (false) { // avoid bit rot, suppress warning
check_for_nonwhite(canvas->getDevice()->accessBitmap(false), fByte);
SkDebugf("------ byte %x\n", fByte);
}
if (false) {
fByte += 1;
fByte &= 0xFF;
this->inval(NULL);
}
}
示例2: Supports
static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint& paint) {
if (dst.colorType() != src.colorType()) {
return false;
}
if (dst.info().profileType() != src.info().profileType()) {
return false;
}
if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFilter()) {
return false;
}
if (0xFF != paint.getAlpha()) {
return false;
}
SkXfermode::Mode mode;
if (!SkXfermode::AsMode(paint.getXfermode(), &mode)) {
return false;
}
if (SkXfermode::kSrc_Mode == mode) {
return true;
}
if (SkXfermode::kSrcOver_Mode == mode && src.isOpaque()) {
return true;
}
return false;
}
示例3: canDraw
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) {
// TODO: support perspective (need getMaxScale replacement)
if (viewMatrix.hasPerspective()) {
return false;
}
SkScalar maxScale = viewMatrix.getMaxScale();
SkScalar scaledTextSize = maxScale*paint.getTextSize();
// Scaling up beyond 2x yields undesireable artifacts
if (scaledTextSize > 2*kLargeDFFontSize) {
return false;
}
if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP() &&
scaledTextSize < kLargeDFFontSize) {
return false;
}
// rasterizers and mask filters modify alpha, which doesn't
// translate well to distance
if (paint.getRasterizer() || paint.getMaskFilter() ||
!fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
return false;
}
// TODO: add some stroking support
if (paint.getStyle() != SkPaint::kFill_Style) {
return false;
}
return true;
}
示例4: 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;
}
示例5: canDraw
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) {
return false;
}
// rasterizers and mask filters modify alpha, which doesn't
// translate well to distance
if (paint.getRasterizer() || paint.getMaskFilter() ||
!fContext->getTextTarget()->caps()->shaderDerivativeSupport()) {
return false;
}
// TODO: add some stroking support
if (paint.getStyle() != SkPaint::kFill_Style) {
return false;
}
// TODO: choose an appropriate maximum scale for distance fields and
// enable perspective
if (SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix())) {
return false;
}
return true;
}
示例6: Supports
static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint& paint) {
if (dst.colorType() != src.colorType()) {
return false;
}
if (dst.info().gammaCloseToSRGB() != src.info().gammaCloseToSRGB()) {
return false;
}
if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFilter()) {
return false;
}
if (0xFF != paint.getAlpha()) {
return false;
}
SkBlendMode mode = paint.getBlendMode();
if (SkBlendMode::kSrc == mode) {
return true;
}
if (SkBlendMode::kSrcOver == mode && src.isOpaque()) {
return true;
}
// At this point memcpy can't be used. The following check for using SrcOver.
if (dst.colorType() != kN32_SkColorType || !dst.info().gammaCloseToSRGB()) {
return false;
}
return SkBlendMode::kSrcOver == mode;
}
示例7: drawPathWithMaskFilter
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrDrawContext* drawContext,
const GrClip& clip,
const SkPath& origPath,
const SkPaint& paint,
const SkMatrix& origViewMatrix,
const SkMatrix* prePathMatrix,
const SkIRect& clipBounds,
bool pathIsMutable) {
SkASSERT(!pathIsMutable || origPath.isVolatile());
GrStyle style(paint);
// 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).
const SkPath* path = &origPath;
SkTLazy<SkPath> tmpPath;
SkMatrix viewMatrix = origViewMatrix;
if (prePathMatrix) {
// Styling, blurs, and shading are supposed to be applied *after* the prePathMatrix.
if (!paint.getMaskFilter() && !paint.getShader() && !style.applies()) {
viewMatrix.preConcat(*prePathMatrix);
} else {
SkPath* result = pathIsMutable ? const_cast<SkPath*>(path) : tmpPath.init();
pathIsMutable = true;
path->transform(*prePathMatrix, result);
path = result;
result->setIsVolatile(true);
}
}
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
示例8: 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;
}
示例9: CanApplyDstMatrixAsCTM
static inline bool CanApplyDstMatrixAsCTM(const SkMatrix& m, const SkPaint& paint) {
if (!paint.getMaskFilter()) {
return true;
}
// Some mask filters parameters (sigma) depend on the CTM/scale.
return m.getType() <= SkMatrix::kTranslate_Mask;
}
示例10: 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;
}
示例11: 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();
}
示例12: HasAnyEffect
static bool HasAnyEffect(const SkPaint& paint) {
return paint.getPathEffect() ||
paint.getShader() ||
paint.getXfermode() ||
paint.getMaskFilter() ||
paint.getColorFilter() ||
paint.getRasterizer() ||
paint.getLooper() ||
paint.getImageFilter();
}
示例13: 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);
}
示例14: 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();
}
示例15: ShouldDither
bool SkPaintPriv::ShouldDither(const SkPaint& p, SkColorType dstCT) {
// The paint dither flag can veto.
if (!p.isDither()) {
return false;
}
// We always dither 565 or 4444 when requested.
if (dstCT == kRGB_565_SkColorType || dstCT == kARGB_4444_SkColorType) {
return true;
}
// Otherwise, dither is only needed for non-const paints.
return p.getImageFilter() || p.getMaskFilter()
|| !p.getShader() || !as_SB(p.getShader())->isConstant();
}