From 9457546761a40c96f586b34b755fef47a7ad006a Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Thu, 21 Jun 2018 17:00:26 -0400 Subject: Alternative fix for stale MIP maps on texture export/import. This change assumes imported textures in SkImages have dirty mip levels and disables regenerating the MIP levels on export (added in https://skia.googlesource.com/skia/+/930f939c48af1be6005af12bb6f709ca5da9d118). This is being done temporarily because it is a simpler change to cherry pick to earlier branches than https://skia.googlesource.com/skia/+/930f939c48af1be6005af12bb6f709ca5da9d118 Bug: chromium:850617 Change-Id: I7c90da782a0ed9014acd6a54ffdee1a0b34fa00c Reviewed-on: https://skia-review.googlesource.com/136788 Commit-Queue: Brian Salomon Auto-Submit: Brian Salomon Reviewed-by: Greg Daniel --- src/gpu/GrDrawingManager.cpp | 4 ++++ src/image/SkImage_Gpu.cpp | 12 +++++++++++- tests/GrMipMappedTest.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index fcee576699..d481632d97 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -382,12 +382,16 @@ GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( if (auto* rt = surface->asRenderTarget()) { gpu->resolveRenderTarget(rt); } +#if 0 + // This is temporarily is disabled. See comment in SkImage_Gpu.cpp, + // new_wrapped_texture_common(). if (auto* tex = surface->asTexture()) { if (tex->texturePriv().mipMapped() == GrMipMapped::kYes && tex->texturePriv().mipMapsAreDirty()) { gpu->regenerateMipMapLevels(tex); } } +#endif return result; } diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index b13abe1d45..670b41ffe5 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -316,7 +316,17 @@ static sk_sp new_wrapped_texture_common(GrContext* ctx, if (!proxy) { return nullptr; } - +#if 1 + // Temporary fix for crbug.com/850617 that can be cleanly merged back to older branches. Assume + // any MIP levels on the incoming texture are dirty. The proper fix is to make them clean on + // export. See #if 0'ed out code in GrDrawingManager::prepareSurfaceForExternalIO(). + SkASSERT(proxy->priv().isInstantiated()); + if (auto* tex = proxy->priv().peekTexture()) { + if (tex->texturePriv().mipMapped() == GrMipMapped::kYes) { + proxy->priv().peekTexture()->texturePriv().markMipMapsDirty(); + } + } +#endif return sk_make_sp(sk_ref_sp(ctx), kNeedNewImageUniqueID, at, std::move(proxy), std::move(colorSpace), SkBudgeted::kNo); } diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp index 5c303633ec..e7c98633d7 100644 --- a/tests/GrMipMappedTest.cpp +++ b/tests/GrMipMappedTest.cpp @@ -87,7 +87,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) { if (isRT) { REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); } else { +#if 1 + // This is temporarily checks that the new image DOES have dirty MIP levels. See + // comment in SkImage_Gpu.cpp, new_wrapped_texture_common(). + REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); +#else REPORTER_ASSERT(reporter, !texture->texturePriv().mipMapsAreDirty()); +#endif } } else { REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped()); -- cgit v1.2.3