diff options
author | 2014-10-14 11:47:22 -0700 | |
---|---|---|
committer | 2014-10-14 11:47:22 -0700 | |
commit | e30597375c19dfb5197fd065a3d1768401eb00fa (patch) | |
tree | d61474ce6dc1ed158456299951a194800e119ad4 /src | |
parent | ec87dc64dd40c1a4f80088023c94764caca79bf9 (diff) |
Remove uses of GrAutoScratchTexture.
Rename GrContext::lockAndRefScratchTexture to refScratchTexture.
GrSurface::writePixels returns bool instead of void.
BUG=skia:2889
Review URL: https://codereview.chromium.org/638403003
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkImageFilter.cpp | 10 | ||||
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 7 | ||||
-rw-r--r-- | src/effects/SkGpuBlurUtils.cpp | 25 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 26 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 8 | ||||
-rwxr-xr-x | src/gpu/GrContext.cpp | 14 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrLayerCache.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 14 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.h | 9 | ||||
-rw-r--r-- | src/gpu/GrSoftwarePathRenderer.h | 1 | ||||
-rw-r--r-- | src/gpu/GrTexture.cpp | 1 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 57 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 18 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 2 |
16 files changed, 96 insertions, 117 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 6456d17a69..666b719831 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -255,13 +255,14 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont desc.fHeight = bounds.height(); desc.fConfig = kRGBA_8888_GrPixelConfig; - GrAutoScratchTexture dst(context, desc); - if (NULL == dst.texture()) { + SkAutoTUnref<GrTexture> dst( + context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + if (!dst) { return false; } GrContext::AutoMatrix am; am.setIdentity(context); - GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget()); + GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); GrContext::AutoClip acs(context, dstRect); GrFragmentProcessor* fp; offset->fX = bounds.left(); @@ -275,8 +276,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont paint.addColorProcessor(fp)->unref(); context->drawRectToRect(paint, dstRect, srcRect); - SkAutoTUnref<GrTexture> resultTex(dst.detach()); - WrapTexture(resultTex, bounds.width(), bounds.height(), result); + WrapTexture(dst, bounds.width(), bounds.height(), result); return true; } #endif diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 823c3028c5..025a757b79 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -284,14 +284,14 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, // the outside. maskDesc.fWidth = texture->width(); maskDesc.fHeight = texture->height(); - GrAutoScratchTexture ast(context, maskDesc, GrContext::kApprox_ScratchTexMatch); - GrTexture* maskTexture = ast.texture(); - if (NULL == maskTexture) { + SkAutoTUnref<GrTexture> maskTexture( + context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMatch)); + if (!maskTexture) { return false; } { - GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()); + GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget()); GrPaint grPaint; grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); SkRegion::Iterator iter(fRegion); diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 59768fc158..5e9a1a393b 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -414,11 +414,12 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, desc.fHeight = bounds.height(); desc.fConfig = kSkia8888_GrPixelConfig; - GrAutoScratchTexture ast(context, desc); - if (NULL == ast.texture()) { + SkAutoTUnref<GrTexture> dst( + context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + + if (!dst) { return false; } - SkAutoTUnref<GrTexture> dst(ast.detach()); GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp index 76c3b3bb7f..3297d2fc77 100644 --- a/src/effects/SkGpuBlurUtils.cpp +++ b/src/effects/SkGpuBlurUtils.cpp @@ -178,9 +178,19 @@ GrTexture* GaussianBlur(GrContext* context, desc.fHeight = SkScalarFloorToInt(srcRect.height()); desc.fConfig = srcTexture->config(); - GrAutoScratchTexture temp1, temp2; - GrTexture* dstTexture = temp1.set(context, desc); - GrTexture* tempTexture = canClobberSrc ? srcTexture : temp2.set(context, desc); + GrTexture* dstTexture; + GrTexture* tempTexture; + SkAutoTUnref<GrTexture> temp1, temp2; + + temp1.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + dstTexture = temp1.get(); + if (canClobberSrc) { + tempTexture = srcTexture; + } else { + temp2.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + tempTexture = temp2.get(); + } + if (NULL == dstTexture || NULL == tempTexture) { return NULL; } @@ -295,14 +305,7 @@ GrTexture* GaussianBlur(GrContext* context, srcTexture = dstTexture; SkTSwap(dstTexture, tempTexture); } - if (srcTexture == temp1.texture()) { - return temp1.detach(); - } else if (srcTexture == temp2.texture()) { - return temp2.detach(); - } else { - srcTexture->ref(); - return srcTexture; - } + return SkRef(srcTexture); } #endif diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 3e3dbe41fe..6c3e6f6dc7 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -503,11 +503,9 @@ bool apply_morphology(const SkBitmap& input, GrMorphologyEffect::MorphologyType morphType, SkISize radius, SkBitmap* dst) { - GrTexture* srcTexture = input.getTexture(); + SkAutoTUnref<GrTexture> srcTexture(SkRef(input.getTexture())); SkASSERT(srcTexture); GrContext* context = srcTexture->getContext(); - srcTexture->ref(); - SkAutoTUnref<GrTexture> src(srcTexture); GrContext::AutoMatrix am; am.setIdentity(context); @@ -524,32 +522,32 @@ bool apply_morphology(const SkBitmap& input, SkIRect srcRect = rect; if (radius.fWidth > 0) { - GrAutoScratchTexture ast(context, desc); - if (NULL == ast.texture()) { + GrTexture* texture = context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch); + if (NULL == texture) { return false; } - GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()); - apply_morphology_pass(context, src, srcRect, dstRect, radius.fWidth, + GrContext::AutoRenderTarget art(context, texture->asRenderTarget()); + apply_morphology_pass(context, srcTexture, srcRect, dstRect, radius.fWidth, morphType, Gr1DKernelEffect::kX_Direction); SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, dstRect.width(), radius.fHeight); context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType == morphType ? SK_ColorWHITE : SK_ColorTRANSPARENT, false); - src.reset(ast.detach()); + srcTexture.reset(texture); srcRect = dstRect; } if (radius.fHeight > 0) { - GrAutoScratchTexture ast(context, desc); - if (NULL == ast.texture()) { + GrTexture* texture = context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch); + if (NULL == texture) { return false; } - GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget()); - apply_morphology_pass(context, src, srcRect, dstRect, radius.fHeight, + GrContext::AutoRenderTarget art(context, texture->asRenderTarget()); + apply_morphology_pass(context, srcTexture, srcRect, dstRect, radius.fHeight, morphType, Gr1DKernelEffect::kY_Direction); - src.reset(ast.detach()); + srcTexture.reset(texture); } - SkImageFilter::WrapTexture(src, rect.width(), rect.height(), dst); + SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst); return true; } diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index bca5223db4..a50978e39b 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -139,13 +139,11 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, desc.fWidth = src.width(); desc.fHeight = src.height(); desc.fConfig = kSkia8888_GrPixelConfig; - - GrAutoScratchTexture ast(context, desc); - if (NULL == ast.texture()) { + SkAutoTUnref<GrTexture> dst( + context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + if (!dst) { return false; } - SkAutoTUnref<GrTexture> dst(ast.detach()); - GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 402e2ec9ae..b9cbf3f1a3 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -446,9 +446,8 @@ GrTexture* GrContext::createNewScratchTexture(const GrTextureDesc& desc) { return texture; } -GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, ScratchTexMatch match, - bool calledDuringFlush) { - +GrTexture* GrContext::refScratchTexture(const GrTextureDesc& inDesc, ScratchTexMatch match, + bool calledDuringFlush) { // kNoStencil has no meaning if kRT isn't set. SkASSERT((inDesc.fFlags & kRenderTarget_GrTextureFlagBit) || !(inDesc.fFlags & kNoStencil_GrTextureFlagBit)); @@ -1306,9 +1305,8 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, desc.fWidth = width; desc.fHeight = height; desc.fConfig = writeConfig; - GrAutoScratchTexture ast(this, desc); - GrTexture* texture = ast.texture(); - if (NULL == texture) { + SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, kApprox_ScratchTexMatch)); + if (!texture) { return false; } @@ -1438,7 +1436,6 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, // conversions in the draw we set the corresponding bool to false so that we don't reapply it // on the read back pixels. GrTexture* src = target->asTexture(); - GrAutoScratchTexture ast; if (src && (swapRAndB || unpremul || flipY)) { // Make the scratch a render so we can read its pixels. GrTextureDesc desc; @@ -1460,8 +1457,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, fGpu->fullReadPixelsIsFasterThanPartial()) { match = kExact_ScratchTexMatch; } - ast.set(this, desc, match); - GrTexture* texture = ast.texture(); + SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, match)); if (texture) { // compute a matrix to perform the draw SkMatrix textureMatrix; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index b144caf63e..e830145cfb 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -455,15 +455,16 @@ bool GrDrawTarget::setupDstReadIfNecessary(GrDeviceCoordTexture* dstCopy, const desc.fWidth = copyRect.width(); desc.fHeight = copyRect.height(); - GrAutoScratchTexture ast(fContext, desc, GrContext::kApprox_ScratchTexMatch); + SkAutoTUnref<GrTexture> copy( + fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); - if (NULL == ast.texture()) { + if (!copy) { GrPrintf("Failed to create temporary copy of destination texture.\n"); return false; } SkIPoint dstPoint = {0, 0}; - if (this->copySurface(ast.texture(), rt, copyRect, dstPoint)) { - dstCopy->setTexture(ast.texture()); + if (this->copySurface(copy, rt, copyRect, dstPoint)) { + dstCopy->setTexture(copy); dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); return true; } else { diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp index de4a90a1c1..7c2a8bd61c 100644 --- a/src/gpu/GrLayerCache.cpp +++ b/src/gpu/GrLayerCache.cpp @@ -218,8 +218,8 @@ bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do // The texture wouldn't fit in the cache - give it it's own texture. // This path always uses a new scratch texture and (thus) doesn't cache anything. // This can yield a lot of re-rendering - SkAutoTUnref<GrTexture> tex(fContext->lockAndRefScratchTexture(desc, - GrContext::kApprox_ScratchTexMatch)); + SkAutoTUnref<GrTexture> tex( + fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); layer->setTexture(tex, GrIRect16::MakeWH(SkToS16(desc.fWidth), SkToS16(desc.fHeight))); layer->setLocked(true); diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 90aab9030f..e66f91cb89 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -228,9 +228,8 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds, /** * Get a texture (from the texture cache) of the correct size & format. - * Return true on success; false on failure. */ -bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* texture) { +GrTexture* GrSWMaskHelper::createTexture() { GrTextureDesc desc; desc.fWidth = fBM.width(); desc.fHeight = fBM.height(); @@ -249,8 +248,7 @@ bool GrSWMaskHelper::getTexture(GrAutoScratchTexture* texture) { SkASSERT(fContext->getGpu()->caps()->isConfigTexturable(desc.fConfig)); } - texture->set(fContext, desc); - return SkToBool(texture->texture()); + return fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch); } void GrSWMaskHelper::sendTextureData(GrTexture *texture, const GrTextureDesc& desc, @@ -337,14 +335,14 @@ GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context, helper.draw(path, stroke, SkRegion::kReplace_Op, antiAlias, 0xFF); - GrAutoScratchTexture ast; - if (!helper.getTexture(&ast)) { + GrTexture* texture(helper.createTexture()); + if (!texture) { return NULL; } - helper.toTexture(ast.texture()); + helper.toTexture(texture); - return ast.detach(); + return texture; } void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h index b23ee2c7c0..e758c092d2 100644 --- a/src/gpu/GrSWMaskHelper.h +++ b/src/gpu/GrSWMaskHelper.h @@ -18,7 +18,6 @@ #include "SkTextureCompressor.h" #include "SkTypes.h" -class GrAutoScratchTexture; class GrContext; class GrTexture; class SkPath; @@ -61,10 +60,6 @@ public: void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op, bool antiAlias, uint8_t alpha); - // Helper function to get a scratch texture suitable for capturing the - // result (i.e., right size & format) - bool getTexture(GrAutoScratchTexture* texture); - // Move the mask generation results from the internal bitmap to the gpu. void toTexture(GrTexture* texture); @@ -100,6 +95,10 @@ public: const SkIRect& rect); private: + // Helper function to get a scratch texture suitable for capturing the + // result (i.e., right size & format) + GrTexture* createTexture(); + GrContext* fContext; SkMatrix fMatrix; SkBitmap fBM; diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h index f8c5620f49..bc355327f1 100644 --- a/src/gpu/GrSoftwarePathRenderer.h +++ b/src/gpu/GrSoftwarePathRenderer.h @@ -12,7 +12,6 @@ #include "GrPathRenderer.h" class GrContext; -class GrAutoScratchTexture; /** * This class uses the software side to render a path to an SkBitmap and diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index b49e2076a7..9c73394e95 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -53,7 +53,6 @@ size_t GrTexture::gpuMemorySize() const { return textureSize; } - void GrTexture::onRelease() { SkASSERT(!this->texturePriv().isSetFlag((GrTextureFlags) kReturnToCache_FlagBit)); INHERITED::onRelease(); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0912b3d28e..8197d2a0e8 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -607,10 +607,9 @@ bool draw_with_mask_filter(GrContext* context, const SkPath& devPath, desc.fHeight = dstM.fBounds.height(); desc.fConfig = kAlpha_8_GrPixelConfig; - GrAutoScratchTexture ast(context, desc); - GrTexture* texture = ast.texture(); - - if (NULL == texture) { + SkAutoTUnref<GrTexture> texture( + context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); + if (!texture) { return false; } texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, @@ -621,20 +620,18 @@ bool draw_with_mask_filter(GrContext* context, const SkPath& devPath, return draw_mask(context, maskRect, grp, texture); } -// Create a mask of 'devPath' and place the result in 'mask'. Return true on -// success; false otherwise. -bool create_mask_GPU(GrContext* context, - const SkRect& maskRect, - const SkPath& devPath, - const GrStrokeInfo& strokeInfo, - bool doAA, - GrAutoScratchTexture* mask, - int SampleCnt) { +// Create a mask of 'devPath' and place the result in 'mask'. +GrTexture* create_mask_GPU(GrContext* context, + const SkRect& maskRect, + const SkPath& devPath, + const GrStrokeInfo& strokeInfo, + bool doAA, + int sampleCnt) { GrTextureDesc desc; desc.fFlags = kRenderTarget_GrTextureFlagBit; desc.fWidth = SkScalarCeilToInt(maskRect.width()); desc.fHeight = SkScalarCeilToInt(maskRect.height()); - desc.fSampleCnt = doAA ? SampleCnt : 0; + desc.fSampleCnt = doAA ? sampleCnt : 0; // We actually only need A8, but it often isn't supported as a // render target so default to RGBA_8888 desc.fConfig = kRGBA_8888_GrPixelConfig; @@ -644,15 +641,14 @@ bool create_mask_GPU(GrContext* context, desc.fConfig = kAlpha_8_GrPixelConfig; } - mask->set(context, desc); - if (NULL == mask->texture()) { - return false; + GrTexture* mask = context->refScratchTexture(desc,GrContext::kApprox_ScratchTexMatch); + if (NULL == mask) { + return NULL; } - GrTexture* maskTexture = mask->texture(); SkRect clipRect = SkRect::MakeWH(maskRect.width(), maskRect.height()); - GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget()); + GrContext::AutoRenderTarget art(context, mask->asRenderTarget()); GrContext::AutoClip ac(context, clipRect); context->clear(NULL, 0x0, true); @@ -676,7 +672,7 @@ bool create_mask_GPU(GrContext* context, translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); am.set(context, translate); context->drawPath(tempPaint, devPath, strokeInfo); - return true; + return mask; } SkBitmap wrap_texture(GrTexture* texture) { @@ -771,25 +767,16 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, return; } - GrAutoScratchTexture mask; - if (create_mask_GPU(fContext, maskRect, *devPathPtr, strokeInfo, - grPaint.isAntiAlias(), &mask, fRenderTarget->numSamples())) { + SkAutoTUnref<GrTexture> mask(create_mask_GPU(fContext, maskRect, *devPathPtr, + strokeInfo, grPaint.isAntiAlias(), + fRenderTarget->numSamples())); + if (mask) { GrTexture* filtered; - if (paint.getMaskFilter()->filterMaskGPU(mask.texture(), - ctm, maskRect, &filtered, true)) { + if (paint.getMaskFilter()->filterMaskGPU(mask, ctm, maskRect, &filtered, true)) { // filterMaskGPU gives us ownership of a ref to the result SkAutoTUnref<GrTexture> atu(filtered); - - // If the scratch texture that we used as the filter src also holds the filter - // result then we must detach so that this texture isn't recycled for a later - // draw. - if (filtered == mask.texture()) { - mask.detach(); - filtered->unref(); // detach transfers GrAutoScratchTexture's ref to us. - } - if (draw_mask(fContext, maskRect, &grPaint, filtered)) { // This path is completely drawn return; @@ -1771,7 +1758,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage) const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == usage) ? GrContext::kApprox_ScratchTexMatch : GrContext::kExact_ScratchTexMatch; - texture.reset(fContext->lockAndRefScratchTexture(desc, match)); + texture.reset(fContext->refScratchTexture(desc, match)); #else texture.reset(fContext->createUncachedTexture(desc, NULL, 0)); #endif diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 4a2cf47663..fdd4a79e48 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -159,7 +159,7 @@ static GrTexture* sk_gr_allocate_texture(GrContext* ctx, // cache so no one else can find it. Additionally, once unlocked, the // scratch texture will go to the end of the list for purging so will // likely be available for this volatile bitmap the next time around. - result = ctx->lockAndRefScratchTexture(desc, GrContext::kExact_ScratchTexMatch); + result = ctx->refScratchTexture(desc, GrContext::kExact_ScratchTexMatch); if (pixels) { result->writePixels(0, 0, bm.width(), bm.height(), desc.fConfig, pixels, rowBytes); } @@ -248,14 +248,15 @@ static GrTexture *load_yuv_texture(GrContext* ctx, bool cache, const GrTexturePa GrTextureDesc yuvDesc; yuvDesc.fConfig = kAlpha_8_GrPixelConfig; - GrAutoScratchTexture yuvTextures[3]; + SkAutoTUnref<GrTexture> yuvTextures[3]; for (int i = 0; i < 3; ++i) { yuvDesc.fWidth = yuvSizes[i].fWidth; yuvDesc.fHeight = yuvSizes[i].fHeight; - yuvTextures[i].set(ctx, yuvDesc); - if ((NULL == yuvTextures[i].texture()) || - !yuvTextures[i].texture()->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, - yuvDesc.fConfig, planes[i], rowBytes[i])) { + yuvTextures[i].reset( + ctx->refScratchTexture(yuvDesc, GrContext::kApprox_ScratchTexMatch)); + if (!yuvTextures[i] || + !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, + yuvDesc.fConfig, planes[i], rowBytes[i])) { return NULL; } } @@ -269,9 +270,8 @@ static GrTexture *load_yuv_texture(GrContext* ctx, bool cache, const GrTexturePa GrRenderTarget* renderTarget = result ? result->asRenderTarget() : NULL; if (renderTarget) { - SkAutoTUnref<GrFragmentProcessor> yuvToRgbProcessor(GrYUVtoRGBEffect::Create( - yuvTextures[0].texture(), yuvTextures[1].texture(), yuvTextures[2].texture(), - colorSpace)); + SkAutoTUnref<GrFragmentProcessor> yuvToRgbProcessor( + GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1], yuvTextures[2], colorSpace)); GrPaint paint; paint.addColorProcessor(yuvToRgbProcessor); SkRect r = SkRect::MakeWH(SkIntToScalar(yuvSizes[0].fWidth), diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index e6fd080235..38a0db2b1f 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -146,7 +146,7 @@ SkSurface* SkSurface::NewScratchRenderTarget(GrContext* ctx, const SkImageInfo& desc.fConfig = SkImageInfo2GrPixelConfig(info); desc.fSampleCnt = sampleCount; - SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::kExact_ScratchTexMatch)); + SkAutoTUnref<GrTexture> tex(ctx->refScratchTexture(desc, GrContext::kExact_ScratchTexMatch)); if (NULL == tex) { return NULL; |