本文整理汇总了C++中SkPaint::getXfermode方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPaint::getXfermode方法的具体用法?C++ SkPaint::getXfermode怎么用?C++ SkPaint::getXfermode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPaint
的用法示例。
在下文中一共展示了SkPaint::getXfermode方法的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().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;
}
示例2: drawCrossfade
void CrossfadeGeneratedImage::drawCrossfade(SkCanvas* canvas, const SkPaint& paint, ImageClampingMode clampMode)
{
FloatRect fromImageRect(FloatPoint(), FloatSize(m_fromImage->size()));
FloatRect toImageRect(FloatPoint(), FloatSize(m_toImage->size()));
FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize));
// TODO(junov): The various effects encoded into paint should probably be applied here
// instead of inside the layer. This probably faulty behavior was maintained in order
// to preserve pre-existing behavior while refactoring this code. This should be
// investigated further. crbug.com/472634
SkPaint layerPaint;
layerPaint.setXfermode(sk_ref_sp(paint.getXfermode()));
SkAutoCanvasRestore ar(canvas, false);
canvas->saveLayer(nullptr, &layerPaint);
SkPaint imagePaint(paint);
imagePaint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
int imageAlpha = clampedAlphaForBlending(1 - m_percentage);
imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha);
imagePaint.setAntiAlias(paint.isAntiAlias());
// TODO(junov): This code should probably be propagating the RespectImageOrientationEnum
// form CrossfadeGeneratedImage::draw. Code was written this way during refactoring to
// avoid modifying existing behavior, but this warrants further investigation. crbug.com/472634
m_fromImage->draw(canvas, imagePaint, destRect, fromImageRect, DoNotRespectImageOrientation, clampMode);
imagePaint.setXfermodeMode(SkXfermode::kPlus_Mode);
imageAlpha = clampedAlphaForBlending(m_percentage);
imagePaint.setAlpha(imageAlpha > 255 ? 255 : imageAlpha);
m_toImage->draw(canvas, imagePaint, destRect, toImageRect, DoNotRespectImageOrientation, clampMode);
}
示例3: fStrokeWidth
SkPDFGraphicState::SkPDFGraphicState(const SkPaint& p)
: fStrokeWidth(p.getStrokeWidth())
, fStrokeMiter(p.getStrokeMiter())
, fAlpha(p.getAlpha())
, fStrokeCap(SkToU8(p.getStrokeCap()))
, fStrokeJoin(SkToU8(p.getStrokeJoin()))
, fMode(SkToU8(mode_for_pdf(p.getXfermode()))) {}
示例4: 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);
}
示例5: 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;
}
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;
}
// 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 SkXfermode::kSrcOver_Mode == mode;
}
示例6: SetPaint
void SkGL::SetPaint(const SkPaint& paint, bool isPremul, bool justAlpha) {
if (justAlpha) {
SkGL::SetAlpha(paint.getAlpha());
} else {
SkGL::SetColor(paint.getColor());
}
GLenum sm = GL_ONE;
GLenum dm = GL_ONE_MINUS_SRC_ALPHA;
SkXfermode* mode = paint.getXfermode();
SkXfermode::Coeff sc, dc;
if (mode && mode->asCoeff(&sc, &dc)) {
sm = gXfermodeCoeff2Blend[sc];
dm = gXfermodeCoeff2Blend[dc];
}
// hack for text, which is not-premul (afaik)
if (!isPremul) {
if (GL_ONE == sm) {
sm = GL_SRC_ALPHA;
}
}
glEnable(GL_BLEND);
glBlendFunc(sm, dm);
if (paint.isDither()) {
glEnable(GL_DITHER);
} else {
glDisable(GL_DITHER);
}
}
示例7: INHERITED
SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device,
const SkPaint& paint)
: INHERITED(device, paint) {
fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
(fXfermode = paint.getXfermode())->safeRef();
}
示例8: apply_paint_xfermode
static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, bool sendBinaries) {
SkFlattenable* xfermode = paint.getXfermode();
if (xfermode != nullptr) {
Json::Value jsonXfermode;
flatten(xfermode, &jsonXfermode, sendBinaries);
(*target)[SKJSONCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode;
}
}
示例9: 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;
}
示例10:
State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext) {
fXfer = paint.getXfermode();
if (shaderContext) {
fBuffer.reset(info.width());
} else {
fPM4f = SkColor4f::FromColor(paint.getColor()).premul();
}
fFlags = 0;
}
示例11: 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;
}
示例12: 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();
}
示例13: HasAnyEffect
static bool HasAnyEffect(const SkPaint& paint) {
return paint.getPathEffect() ||
paint.getShader() ||
paint.getXfermode() ||
paint.getMaskFilter() ||
paint.getColorFilter() ||
paint.getRasterizer() ||
paint.getLooper() ||
paint.getImageFilter();
}
示例14: 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;
}
示例15: drawNeedsLayer
static bool drawNeedsLayer(const SkPaint& paint)
{
if (SkColorGetA(paint.getColor()) < 255)
return true;
SkXfermode::Mode xfermode;
if (SkXfermode::AsMode(paint.getXfermode(), &xfermode)) {
if (xfermode != SkXfermode::kSrcOver_Mode)
return true;
}
return false;
}