本文整理汇总了C++中GraphicsContext::computeFilterQuality方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::computeFilterQuality方法的具体用法?C++ GraphicsContext::computeFilterQuality怎么用?C++ GraphicsContext::computeFilterQuality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::computeFilterQuality方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPattern
void Image::drawPattern(GraphicsContext& context,
const FloatRect& floatSrcRect,
const FloatSize& scale,
const FloatPoint& phase,
SkBlendMode compositeOp,
const FloatRect& destRect,
const FloatSize& repeatSpacing) {
TRACE_EVENT0("skia", "Image::drawPattern");
sk_sp<SkImage> image = imageForCurrentFrame();
if (!image)
return;
FloatRect normSrcRect = floatSrcRect;
normSrcRect.intersect(FloatRect(0, 0, image->width(), image->height()));
if (destRect.isEmpty() || normSrcRect.isEmpty())
return; // nothing to draw
SkMatrix localMatrix;
// We also need to translate it such that the origin of the pattern is the
// origin of the destination rect, which is what WebKit expects. Skia uses
// the coordinate system origin as the base for the pattern. If WebKit wants
// a shifted image, it will shift it from there using the localMatrix.
const float adjustedX = phase.x() + normSrcRect.x() * scale.width();
const float adjustedY = phase.y() + normSrcRect.y() * scale.height();
localMatrix.setTranslate(SkFloatToScalar(adjustedX),
SkFloatToScalar(adjustedY));
// Because no resizing occurred, the shader transform should be
// set to the pattern's transform, which just includes scale.
localMatrix.preScale(scale.width(), scale.height());
// Fetch this now as subsetting may swap the image.
auto imageID = image->uniqueID();
image = image->makeSubset(enclosingIntRect(normSrcRect));
if (!image)
return;
{
SkPaint paint = context.fillPaint();
paint.setColor(SK_ColorBLACK);
paint.setBlendMode(static_cast<SkBlendMode>(compositeOp));
paint.setFilterQuality(
context.computeFilterQuality(this, destRect, normSrcRect));
paint.setAntiAlias(context.shouldAntialias());
paint.setShader(createPatternShader(
image.get(), localMatrix, paint,
FloatSize(repeatSpacing.width() / scale.width(),
repeatSpacing.height() / scale.height())));
context.drawRect(destRect, paint);
}
if (currentFrameIsLazyDecoded())
PlatformInstrumentation::didDrawLazyPixelRef(imageID);
}
示例2: drawTile
void CrossfadeGeneratedImage::drawTile(GraphicsContext& context,
const FloatRect& srcRect) {
// Draw nothing if either of the images hasn't loaded yet.
if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage())
return;
SkPaint paint = context.fillPaint();
paint.setBlendMode(SkBlendMode::kSrcOver);
paint.setAntiAlias(context.shouldAntialias());
FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize));
paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect));
drawCrossfade(context.canvas(), paint, ClampImageToSourceRect);
}