diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.cpp | 43 | ||||
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 12 | ||||
-rw-r--r-- | src/gpu/GrContextPriv.h | 1 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrYUVProvider.cpp | 4 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 1 |
9 files changed, 58 insertions, 13 deletions
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index 164e3d6d45..bdfdbd0a8a 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -104,17 +104,44 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture( return nullptr; } + bool makingASubset = true; if (0 == origin.fX && 0 == origin.fY && info.width() == getInfo().width() && info.height() == getInfo().height()) { - // If the caller wants the entire texture, we're done - return proxy; - } else { - // Otherwise, make a copy of the requested subset. - return GrSurfaceProxy::Copy(context, proxy.get(), - SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), - info.height()), - SkBudgeted::kYes); + makingASubset = false; + if (!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped()) { + // If the caller wants the full texture and we have the correct mip support, we're done + return proxy; + } } + // Otherwise, make a copy for the requested subset or for mip maps. + SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height()); + + GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo; + + sk_sp<GrTextureProxy> texProxy = GrSurfaceProxy::Copy(context, proxy.get(), mipMapped, + subset, SkBudgeted::kYes); + if (!makingASubset && texProxy) { + // We are in this case if we wanted the full texture, but we will be mip mapping the + // texture. Therefore we want to update the cached texture so that we point to the + // mipped version instead of the old one. + SkASSERT(willNeedMipMaps); + SkASSERT(GrMipMapped::kYes == texProxy->mipMapped()); + + // The only way we should get into here is if we just made a new texture in makeProxy or + // we found a cached texture in the same context. Thus the current and cached contexts + // should match. + SkASSERT(context->uniqueID() == fOwningContextID); + + // Clear out the old cached texture. + this->clear(); + + // We need to get the actual GrTexture so force instantiation of the GrTextureProxy + texProxy->instantiate(context->resourceProvider()); + GrTexture* texture = texProxy->priv().peekTexture(); + SkASSERT(texture); + fOriginalTexture = texture; + } + return texProxy; } #endif diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 68fd9f3899..9760205de2 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -85,6 +85,7 @@ static bool sw_draw_with_mask_filter(GrContext* context, sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext( desc, + GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes); if (!sContext) { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index f4f1d6c677..605fe2e793 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -750,11 +750,19 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurface } sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc, + GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted isDstBudgeted) { - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->resourceProvider(), - dstDesc, fit, isDstBudgeted); + sk_sp<GrTextureProxy> proxy; + if (GrMipMapped::kNo == mipMapped) { + proxy = GrSurfaceProxy::MakeDeferred(fContext->resourceProvider(), dstDesc, fit, + isDstBudgeted); + } else { + SkASSERT(SkBackingFit::kExact == fit); + proxy = GrSurfaceProxy::MakeDeferredMipMap(fContext->resourceProvider(), dstDesc, + isDstBudgeted); + } if (!proxy) { return nullptr; } diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index e1773c8e81..cdd04b4dbf 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -27,6 +27,7 @@ public: sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, sk_sp<SkColorSpace>); sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc&, + GrMipMapped, SkBackingFit, SkBudgeted); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 5f071e8bdf..44550e1ee5 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -1890,6 +1890,7 @@ bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const Gr sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeDeferredSurfaceContext( desc, + GrMipMapped::kNo, fit, SkBudgeted::kYes); if (!sContext) { diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index d45847afd8..100575875b 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -100,6 +100,7 @@ sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBacki sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext( desc, + GrMipMapped::kNo, fit, SkBudgeted::kYes); if (!sContext || !sContext->asTextureProxy()) { diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index da5bb172cd..3e188b89fa 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -411,6 +411,7 @@ void GrSurfaceProxy::validate(GrContext* context) const { sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context, GrSurfaceProxy* src, + GrMipMapped mipMapped, SkIRect srcRect, SkBudgeted budgeted) { if (!srcRect.intersect(SkIRect::MakeWH(src->width(), src->height()))) { @@ -425,6 +426,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context, sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext( dstDesc, + mipMapped, SkBackingFit::kExact, budgeted)); if (!dstContext) { @@ -439,8 +441,8 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context, } sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context, GrSurfaceProxy* src, - SkBudgeted budgeted) { - return Copy(context, src, SkIRect::MakeWH(src->width(), src->height()), budgeted); + GrMipMapped mipMapped, SkBudgeted budgeted) { + return Copy(context, src, mipMapped, SkIRect::MakeWH(src->width(), src->height()), budgeted); } sk_sp<GrSurfaceContext> GrSurfaceProxy::TestCopy(GrContext* context, const GrSurfaceDesc& dstDesc, @@ -448,6 +450,7 @@ sk_sp<GrSurfaceContext> GrSurfaceProxy::TestCopy(GrContext* context, const GrSur sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext( dstDesc, + GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes)); if (!dstContext) { diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp index 085e5bedd4..d6a56660a4 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -109,7 +109,9 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS (yuvDesc.fHeight != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight) ? SkBackingFit::kExact : SkBackingFit::kApprox; - yuvTextureContexts[i] = ctx->contextPriv().makeDeferredSurfaceContext(yuvDesc, fit, + yuvTextureContexts[i] = ctx->contextPriv().makeDeferredSurfaceContext(yuvDesc, + GrMipMapped::kNo, + fit, SkBudgeted::kYes); if (!yuvTextureContexts[i]) { return nullptr; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 93414ed06b..fe1f6aefaa 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1238,6 +1238,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial() { // filter proxy = GrSurfaceProxy::Copy(fContext.get(), this->accessRenderTargetContext()->asSurfaceProxy(), + GrMipMapped::kNo, SkBudgeted::kYes); if (!proxy) { return nullptr; |