diff options
-rw-r--r-- | gm/image_pict.cpp | 3 | ||||
-rw-r--r-- | include/private/GrSurfaceProxy.h | 4 | ||||
-rw-r--r-- | src/core/SkSpecialImage.cpp | 3 | ||||
-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 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 1 | ||||
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 4 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 3 | ||||
-rw-r--r-- | tests/SRGBReadWritePixelsTest.cpp | 9 |
16 files changed, 77 insertions, 21 deletions
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index 0e39d3b997..bf1c651de6 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -186,8 +186,11 @@ protected: desc.fHeight = info.height(); desc.fConfig = fProxy->config(); + GrMipMapped mipMapped = willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo; + sk_sp<GrSurfaceContext> dstContext(fCtx->contextPriv().makeDeferredSurfaceContext( desc, + mipMapped, SkBackingFit::kExact, SkBudgeted::kYes)); if (!dstContext) { diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 2bbf02a20f..0eccdce32c 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -326,12 +326,12 @@ public: // Helper function that creates a temporary SurfaceContext to perform the copy // It always returns a kExact-backed proxy bc it is used when converting an SkSpecialImage // to an SkImage. The copy is is not a render target and not multisampled. - static sk_sp<GrTextureProxy> Copy(GrContext*, GrSurfaceProxy* src, + static sk_sp<GrTextureProxy> Copy(GrContext*, GrSurfaceProxy* src, GrMipMapped, SkIRect srcRect, SkBudgeted); // Copy the entire 'src' // It always returns a kExact-backed proxy bc it is used in SkGpuDevice::snapSpecial - static sk_sp<GrTextureProxy> Copy(GrContext* context, GrSurfaceProxy* src, + static sk_sp<GrTextureProxy> Copy(GrContext* context, GrSurfaceProxy* src, GrMipMapped, SkBudgeted budgeted); // Test-only entry point - should decrease in use as proxies propagate diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index db4fadcce2..df56afdcd1 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -464,7 +464,8 @@ public: } sk_sp<GrTextureProxy> subsetProxy(GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), - *subset, SkBudgeted::kYes)); + GrMipMapped::kNo, *subset, + SkBudgeted::kYes)); if (!subsetProxy) { return nullptr; } 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; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 9f1586c2a1..e89af42432 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -249,6 +249,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { sk_sp<GrSurfaceContext> sContext(fContext->contextPriv().makeDeferredSurfaceContext( desc, + GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted)); if (!sContext) { diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 6e9bc3f0e7..8b7a065478 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -110,7 +110,9 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot() { if (!srcProxy || rtc->priv().refsWrappedObjects()) { SkASSERT(rtc->origin() == rtc->asSurfaceProxy()->origin()); - srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), budgeted); + // TODO: We should look at the rtc to see if it is mipped and if so create the copy as well + // with mips. + srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), GrMipMapped::kNo, budgeted); } const SkImageInfo info = fDevice->imageInfo(); diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index e5dc6ae824..eff8c2584e 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -212,7 +212,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info) // Try creating the texture as a deferred proxy. for (int i = 0; i < 2; ++i) { auto surfCtx = context->contextPriv().makeDeferredSurfaceContext( - desc, approx ? SkBackingFit::kApprox : SkBackingFit::kExact, + desc, GrMipMapped::kNo, + approx ? SkBackingFit::kApprox : SkBackingFit::kExact, SkBudgeted::kYes); if (!surfCtx) { continue; diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp index a52e96104f..6ebdcf7c20 100644 --- a/tests/SRGBReadWritePixelsTest.cpp +++ b/tests/SRGBReadWritePixelsTest.cpp @@ -176,8 +176,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) { context->caps()->isConfigTexturable(desc.fConfig)) { sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeDeferredSurfaceContext( - desc, SkBackingFit::kExact, - SkBudgeted::kNo); + desc, GrMipMapped::kNo, + SkBackingFit::kExact, + SkBudgeted::kNo); if (!sContext) { ERRORF(reporter, "Could not create SRGBA surface context."); return; @@ -215,7 +216,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) { } desc.fConfig = kRGBA_8888_GrPixelConfig; - sContext = context->contextPriv().makeDeferredSurfaceContext(desc, SkBackingFit::kExact, + sContext = context->contextPriv().makeDeferredSurfaceContext(desc, + GrMipMapped::kNo, + SkBackingFit::kExact, SkBudgeted::kNo); if (!sContext) { ERRORF(reporter, "Could not create RGBA surface context."); |