本文整理汇总了C++中GrContext::makeDrawContextWithFallback方法的典型用法代码示例。如果您正苦于以下问题:C++ GrContext::makeDrawContextWithFallback方法的具体用法?C++ GrContext::makeDrawContextWithFallback怎么用?C++ GrContext::makeDrawContextWithFallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrContext
的用法示例。
在下文中一共展示了GrContext::makeDrawContextWithFallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_on_gpu
static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
const CopyParams& copyParams) {
SkASSERT(!subset || !subset->isEmpty());
GrContext* context = inputTexture->getContext();
SkASSERT(context);
GrPixelConfig config = GrMakePixelConfigUncompressed(inputTexture->config());
sk_sp<GrDrawContext> copyDC = context->makeDrawContextWithFallback(SkBackingFit::kExact,
copyParams.fWidth,
copyParams.fHeight,
config, nullptr);
if (!copyDC) {
return nullptr;
}
GrPaint paint;
paint.setGammaCorrect(true);
SkScalar sx SK_INIT_TO_AVOID_WARNING;
SkScalar sy SK_INIT_TO_AVOID_WARNING;
if (subset) {
sx = 1.f / inputTexture->width();
sy = 1.f / inputTexture->height();
}
if (copyParams.fFilter != GrTextureParams::kNone_FilterMode && subset &&
(subset->width() != copyParams.fWidth || subset->height() != copyParams.fHeight)) {
SkRect domain;
domain.fLeft = (subset->fLeft + 0.5f) * sx;
domain.fTop = (subset->fTop + 0.5f)* sy;
domain.fRight = (subset->fRight - 0.5f) * sx;
domain.fBottom = (subset->fBottom - 0.5f) * sy;
// This would cause us to read values from outside the subset. Surely, the caller knows
// better!
SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode);
paint.addColorFragmentProcessor(
GrTextureDomainEffect::Make(inputTexture, nullptr, SkMatrix::I(), domain,
GrTextureDomain::kClamp_Mode,
copyParams.fFilter));
} else {
GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter);
paint.addColorTextureProcessor(inputTexture, nullptr, SkMatrix::I(), params);
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkRect localRect;
if (subset) {
localRect = SkRect::Make(*subset);
localRect.fLeft *= sx;
localRect.fTop *= sy;
localRect.fRight *= sx;
localRect.fBottom *= sy;
} else {
localRect = SkRect::MakeWH(1.f, 1.f);
}
SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
copyDC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect);
return copyDC->asTexture().release();
}