本文整理汇总了C++中SkAutoTUnref::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::swap方法的具体用法?C++ SkAutoTUnref::swap怎么用?C++ SkAutoTUnref::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::swap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GaussianBlur
GrTexture* GaussianBlur(GrContext* context,
GrTexture* srcTexture,
bool canClobberSrc,
const SkRect& dstBounds,
const SkRect* srcBounds,
float sigmaX,
float sigmaY,
GrTextureProvider::SizeConstraint constraint) {
SkASSERT(context);
SkIRect clearRect;
int scaleFactorX, radiusX;
int scaleFactorY, radiusY;
int maxTextureSize = context->caps()->maxTextureSize();
sigmaX = adjust_sigma(sigmaX, maxTextureSize, &scaleFactorX, &radiusX);
sigmaY = adjust_sigma(sigmaY, maxTextureSize, &scaleFactorY, &radiusY);
SkPoint srcOffset = SkPoint::Make(-dstBounds.x(), -dstBounds.y());
SkRect localDstBounds = SkRect::MakeWH(dstBounds.width(), dstBounds.height());
SkRect localSrcBounds;
SkRect srcRect;
if (srcBounds) {
srcRect = localSrcBounds = *srcBounds;
srcRect.offset(srcOffset);
srcBounds = &localSrcBounds;
} else {
srcRect = localDstBounds;
}
scale_rect(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
srcRect.roundOut(&srcRect);
scale_rect(&srcRect, static_cast<float>(scaleFactorX),
static_cast<float>(scaleFactorY));
// setup new clip
GrClip clip(localDstBounds);
SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() ||
kRGBA_8888_GrPixelConfig == srcTexture->config() ||
kAlpha_8_GrPixelConfig == srcTexture->config());
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = SkScalarFloorToInt(dstBounds.width());
desc.fHeight = SkScalarFloorToInt(dstBounds.height());
desc.fConfig = srcTexture->config();
GrTexture* dstTexture;
GrTexture* tempTexture;
SkAutoTUnref<GrTexture> temp1, temp2;
temp1.reset(context->textureProvider()->createTexture(desc, constraint));
dstTexture = temp1.get();
if (canClobberSrc) {
tempTexture = srcTexture;
} else {
temp2.reset(context->textureProvider()->createTexture(desc, constraint));
tempTexture = temp2.get();
}
if (nullptr == dstTexture || nullptr == tempTexture) {
return nullptr;
}
SkAutoTUnref<GrDrawContext> srcDrawContext;
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
SkRect dstRect(srcRect);
if (srcBounds && i == 1) {
SkRect domain;
matrix.mapRect(&domain, *srcBounds);
domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width() : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height() : 0.0f);
SkAutoTUnref<const GrFragmentProcessor> fp(GrTextureDomainEffect::Create(
srcTexture,
matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
paint.addColorFragmentProcessor(fp);
srcRect.offset(-srcOffset);
srcOffset.set(0, 0);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
paint.addColorTextureProcessor(srcTexture, matrix, params);
}
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
SkAutoTUnref<GrDrawContext> dstDrawContext(
context->drawContext(dstTexture->asRenderTarget()));
if (!dstDrawContext) {
return nullptr;
}
dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
srcDrawContext.swap(dstDrawContext);
//.........这里部分代码省略.........