aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/texdata.cpp2
-rw-r--r--src/core/SkImageFilter.cpp2
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp2
-rw-r--r--src/effects/SkBlurMaskFilter.cpp2
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp2
-rw-r--r--src/effects/SkGpuBlurUtils.cpp26
-rw-r--r--src/effects/SkLightingImageFilter.cpp2
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp4
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp2
-rw-r--r--src/gpu/GrBlurUtils.cpp2
-rw-r--r--src/gpu/GrContext.cpp9
-rw-r--r--src/gpu/GrLayerCache.cpp2
-rw-r--r--src/gpu/GrRenderTarget.cpp6
-rw-r--r--src/gpu/SkGpuDevice.cpp4
-rw-r--r--src/gpu/SkGr.cpp4
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp6
-rw-r--r--src/image/SkImage_Gpu.cpp6
17 files changed, 46 insertions, 37 deletions
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 13a1c2a6c2..1a807c7b9b 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -39,7 +39,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTarget();
GrContext* ctx = canvas->getGrContext();
- GrDrawContext* drawContext = ctx ? ctx->drawContext() : nullptr;
+ SkAutoTUnref<GrDrawContext> drawContext(ctx ? ctx->drawContext() : nullptr);
if (drawContext && target) {
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
static const int stride = 2 * S;
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index cda3e053b9..32562946ed 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -354,7 +354,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
SkASSERT(fp);
paint.addColorFragmentProcessor(fp)->unref();
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (drawContext) {
drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(),
dstRect, srcRect);
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index b28a62bcd7..066a91f9c5 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -277,7 +277,7 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
return false;
}
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (drawContext) {
GrPaint grPaint;
grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 1bd708b5e0..2ef86b0162 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -1226,7 +1226,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
}
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return false;
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 49290718e3..e87a871faf 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -453,7 +453,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
matrix.setTranslate(-SkIntToScalar(colorBounds.x()),
-SkIntToScalar(colorBounds.y()));
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return false;
}
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 8b0e5fb799..fd27cc3600 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -196,7 +196,7 @@ GrTexture* GaussianBlur(GrContext* context,
return nullptr;
}
- GrDrawContext* srcDrawContext = nullptr;
+ SkAutoTUnref<GrDrawContext> srcDrawContext;
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
@@ -224,14 +224,14 @@ GrTexture* GaussianBlur(GrContext* context,
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return nullptr;
}
dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
SkMatrix::I(), dstRect, srcRect);
- srcDrawContext = dstDrawContext;
+ srcDrawContext.swap(&dstDrawContext);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
@@ -247,14 +247,14 @@ GrTexture* GaussianBlur(GrContext* context,
SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return nullptr;
}
convolve_gaussian_2d(dstDrawContext, dstTexture->asRenderTarget(), clip, srcRect, dstRect,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, cropToRect, srcIRect);
- srcDrawContext = dstDrawContext;
+ srcDrawContext.swap(&dstDrawContext);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
@@ -264,7 +264,7 @@ GrTexture* GaussianBlur(GrContext* context,
if (scaleFactorX > 1) {
// TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) {
- srcDrawContext = context->drawContext();
+ srcDrawContext.reset(context->drawContext());
if (!srcDrawContext) {
return nullptr;
}
@@ -278,7 +278,7 @@ GrTexture* GaussianBlur(GrContext* context,
}
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return nullptr;
}
@@ -286,7 +286,7 @@ GrTexture* GaussianBlur(GrContext* context,
srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
cropToRect);
- srcDrawContext = dstDrawContext;
+ srcDrawContext.swap(&dstDrawContext);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -296,7 +296,7 @@ GrTexture* GaussianBlur(GrContext* context,
if (scaleFactorY > 1 || sigmaX > 0.0f) {
// TODO: if we pass in the source draw context we don't need this here
if (!srcDrawContext) {
- srcDrawContext = context->drawContext();
+ srcDrawContext.reset(context->drawContext());
if (!srcDrawContext) {
return nullptr;
}
@@ -311,7 +311,7 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return nullptr;
}
@@ -319,7 +319,7 @@ GrTexture* GaussianBlur(GrContext* context,
dstRect, srcTexture, Gr1DKernelEffect::kY_Direction, radiusY, sigmaY,
cropToRect);
- srcDrawContext = dstDrawContext;
+ srcDrawContext.swap(&dstDrawContext);
srcTexture = dstTexture;
srcRect = dstRect;
SkTSwap(dstTexture, tempTexture);
@@ -348,14 +348,14 @@ GrTexture* GaussianBlur(GrContext* context,
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return nullptr;
}
dstDrawContext->drawNonAARectToRect(dstTexture->asRenderTarget(), clip, paint,
SkMatrix::I(), dstRect, srcRect);
- srcDrawContext = dstDrawContext;
+ srcDrawContext.swap(&dstDrawContext);
srcRect = dstRect;
srcTexture = dstTexture;
SkTSwap(dstTexture, tempTexture);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 240a6939ae..c46cc67e8c 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -408,7 +408,7 @@ bool SkLightingImageFilterInternal::filterImageGPU(Proxy* proxy,
SkRect bottom = SkRect::MakeXYWH(1, dstRect.height() - 1, dstRect.width() - 2, 1);
SkRect bottomRight = SkRect::MakeXYWH(dstRect.width() - 1, dstRect.height() - 1, 1, 1);
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return false;
}
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 2c99af92da..440d88d5bf 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -573,7 +573,7 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) {
return false;
}
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return false;
}
@@ -596,7 +596,7 @@ bool apply_morphology(const SkBitmap& input,
if (nullptr == scratch) {
return false;
}
- GrDrawContext* dstDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
if (!dstDrawContext) {
return false;
}
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 7c4a94b949..9ffbe62bdc 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -192,7 +192,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
paint.addColorFragmentProcessor(foregroundDomain.get());
paint.addColorFragmentProcessor(xferProcessor)->unref();
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return false;
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index a6eeae6f6b..039a12c3c8 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -122,7 +122,7 @@ static GrTexture* create_mask_GPU(GrContext* context,
SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height());
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return nullptr;
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6dae8c7083..4e8060b187 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -124,7 +124,8 @@ GrDrawContext* GrContext::DrawingMgr::drawContext(const SkSurfaceProps* surfaceP
new GrDrawContext(fContext, fDrawTarget, props);
}
- return fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()];
+ // For now, everyone gets a faux creation ref
+ return SkRef(fDrawContext[props.pixelGeometry()][props.isUseDeviceIndependentFonts()]);
}
////////////////////////////////////////////////////////////////////////////////
@@ -422,7 +423,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
}
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
- GrDrawContext* drawContext = this->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
if (!drawContext) {
return false;
}
@@ -533,7 +534,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
if (fp) {
paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
- GrDrawContext* drawContext = this->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint,
SkMatrix::I(), rect, nullptr);
surfaceToRead.reset(SkRef(temp.get()));
@@ -609,7 +610,7 @@ void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
return;
}
- GrDrawContext* drawContext = this->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext());
if (!drawContext) {
return;
}
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index f33384c3e9..27cb55b9ee 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -467,7 +467,7 @@ void GrLayerCache::purgeAll() {
SkASSERT(0 == fPictureHash.count());
- GrDrawContext* drawContext = fContext->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(fContext->drawContext());
if (drawContext) {
drawContext->discard(fAtlas->getTexture()->asRenderTarget());
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 090834912a..5cb34e849a 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -18,7 +18,11 @@
void GrRenderTarget::discard() {
// go through context so that all necessary flushing occurs
GrContext* context = this->getContext();
- GrDrawContext* drawContext = context ? context->drawContext() : nullptr;
+ if (!context) {
+ return;
+ }
+
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b9c2f7ceca..fd03acc240 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -196,7 +196,7 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
fLegacyBitmap.setInfo(info);
fLegacyBitmap.setPixelRef(pr)->unref();
- fDrawContext.reset(SkRef(fContext->drawContext(&this->surfaceProps())));
+ fDrawContext.reset(fContext->drawContext(&this->surfaceProps()));
}
GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::Budgeted budgeted,
@@ -373,7 +373,7 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
fLegacyBitmap.setPixelRef(pr)->unref();
- fDrawContext.reset(SkRef(fRenderTarget->getContext()->drawContext(&this->surfaceProps())));
+ fDrawContext.reset(fRenderTarget->getContext()->drawContext(&this->surfaceProps()));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 4293194de3..29c4572859 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -312,7 +312,7 @@ GrTexture* stretch_texture(GrTexture* inputTexture, const Stretch& stretch,
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtDesc.fHeight));
SkRect localRect = SkRect::MakeWH(1.f, 1.f);
- GrDrawContext* drawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(context->drawContext());
if (!drawContext) {
return nullptr;
}
@@ -473,7 +473,7 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrUniqueKey& optionalKe
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
SkIntToScalar(yuvInfo.fSize[0].fHeight));
- GrDrawContext* drawContext = ctx->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext());
if (!drawContext) {
return nullptr;
}
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 3f68268b20..042e5f8047 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -226,7 +226,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint1.addColorFragmentProcessor(pmToUPM1);
- GrDrawContext* readDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> readDrawContext(context->drawContext());
if (!readDrawContext) {
failed = true;
break;
@@ -243,7 +243,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint2.addColorFragmentProcessor(upmToPM);
- GrDrawContext* tempDrawContext = context->drawContext();
+ SkAutoTUnref<GrDrawContext> tempDrawContext(context->drawContext());
if (!tempDrawContext) {
failed = true;
break;
@@ -257,7 +257,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
paint3.addColorFragmentProcessor(pmToUPM2);
- readDrawContext = context->drawContext();
+ readDrawContext.reset(context->drawContext());
if (!readDrawContext) {
failed = true;
break;
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 6655e39c17..fdcb87136d 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -254,7 +254,11 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
SkIntToScalar(dstDesc.fHeight));
- GrDrawContext* drawContext = ctx->drawContext();
+ SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext());
+ if (!drawContext) {
+ return nullptr;
+ }
+
drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst);
return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,