本文整理汇总了C++中SkPaint::getColorFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getColorFilter方法的具体用法?C++ SkPaint::getColorFilter怎么用?C++ SkPaint::getColorFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getColorFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: apply
SkPaint SkColorSpaceXformer::apply(const SkPaint& src) {
const AutoCachePurge autoPurge(this);
SkPaint dst = src;
// All SkColorSpaces have the same black point.
if (src.getColor() & 0xffffff) {
dst.setColor(this->apply(src.getColor()));
}
if (auto shader = src.getShader()) {
dst.setShader(this->apply(shader));
}
if (auto cf = src.getColorFilter()) {
dst.setColorFilter(this->apply(cf));
}
if (auto looper = src.getDrawLooper()) {
dst.setDrawLooper(looper->makeColorSpace(this));
}
if (auto imageFilter = src.getImageFilter()) {
dst.setImageFilter(this->apply(imageFilter));
}
return dst;
}
示例3: onDrawPaint
void SkOverdrawCanvas::onDrawPaint(const SkPaint& paint) {
if (0 == paint.getColor() && !paint.getColorFilter() && !paint.getShader()) {
// This is a clear, ignore it.
} else {
fList[0]->onDrawPaint(this->overdrawPaint(paint));
}
}
示例4: 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;
}
示例5: INHERITED
SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkPixmap& device, const SkPaint& paint)
: INHERITED(device, paint) {
SkASSERT(paint.getShader() == nullptr);
SkASSERT(paint.getColorFilter() == nullptr);
SkASSERT(paint.isSrcOver());
SkASSERT(paint.getColor() == SK_ColorBLACK);
}
示例6: INHERITED
SkRGB16_Black_Blitter::SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
: INHERITED(device, paint) {
SkASSERT(paint.getShader() == NULL);
SkASSERT(paint.getColorFilter() == NULL);
SkASSERT(paint.getXfermode() == NULL);
SkASSERT(paint.getColor() == SK_ColorBLACK);
}
示例7: apply_paint_colorfilter
static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, bool sendBinaries) {
SkFlattenable* colorFilter = paint.getColorFilter();
if (colorFilter != nullptr) {
Json::Value jsonColorFilter;
flatten(colorFilter, &jsonColorFilter, sendBinaries);
(*target)[SKJSONCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter;
}
}
示例8: 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;
}
示例9: 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();
}
示例10: HasAnyEffect
static bool HasAnyEffect(const SkPaint& paint) {
return paint.getPathEffect() ||
paint.getShader() ||
paint.getXfermode() ||
paint.getMaskFilter() ||
paint.getColorFilter() ||
paint.getRasterizer() ||
paint.getLooper() ||
paint.getImageFilter();
}
示例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: Supports
static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint& paint) {
// the caller has already inspected the colorspace on src and dst
SkASSERT(!SkColorSpaceXformSteps::Required(src.colorSpace(), dst.colorSpace()));
if (dst.colorType() != src.colorType()) {
return false;
}
if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFilter()) {
return false;
}
if (0xFF != paint.getAlpha()) {
return false;
}
SkBlendMode mode = paint.getBlendMode();
return SkBlendMode::kSrc == mode || (SkBlendMode::kSrcOver == mode && src.isOpaque());
}
示例13: Supports
static bool Supports(const SkPixmap& dst, const SkPixmap& src, const SkPaint& paint) {
if (dst.colorType() != src.colorType()) {
return false;
}
if (!SkColorSpace::Equals(dst.colorSpace(), src.colorSpace())) {
return false;
}
if (paint.getMaskFilter() || paint.getColorFilter() || paint.getImageFilter()) {
return false;
}
if (0xFF != paint.getAlpha()) {
return false;
}
SkBlendMode mode = paint.getBlendMode();
return SkBlendMode::kSrc == mode || (SkBlendMode::kSrcOver == mode && src.isOpaque());
}
示例14: SkSpriteBlitter
Sprite_D32_XferFilter(const SkBitmap& source, const SkPaint& paint)
: SkSpriteBlitter(source) {
fColorFilter = paint.getColorFilter();
SkSafeRef(fColorFilter);
fXfermode = paint.getXfermode();
SkSafeRef(fXfermode);
fBufferSize = 0;
fBuffer = NULL;
unsigned flags32 = 0;
if (255 != paint.getAlpha()) {
flags32 |= SkBlitRow::kGlobalAlpha_Flag32;
}
if (!source.isOpaque()) {
flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32;
}
fProc32 = SkBlitRow::Factory32(flags32);
fAlpha = paint.getAlpha();
}
示例15: filterTextFlags
bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
if (!paint.isLCDRenderText()) {
// 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;
}