From 8e9b4c47575cd468d345e7b3a0e7ba17d21d42fc Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Fri, 20 Jul 2018 10:30:48 -0400 Subject: Reland "Don't require mips in GrTextureProducer if texture is 1x1." This reverts commit c861eee3a6f1f93ad3df27b8be94f44b245bd128. Reason for revert: Relanding with fix for gray8 not copyable Original change's description: > Revert "Don't require mips in GrTextureProducer if texture is 1x1." > > This reverts commit 5191fd7555d34225ef771ad4cac65bcbbb50a89c. > > Reason for revert: breaking angle > > Original change's description: > > Don't require mips in GrTextureProducer if texture is 1x1. > > > > Bug: chromium:862921 > > Change-Id: I5f3584ad36e160a5a09d0a37e31e147155076b4d > > Reviewed-on: https://skia-review.googlesource.com/142586 > > Reviewed-by: Brian Osman > > Reviewed-by: Brian Salomon > > Commit-Queue: Greg Daniel > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Iaef7a56b061cb41f4c75ec20d8df77d3e52b194d > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:862921 > Reviewed-on: https://skia-review.googlesource.com/142600 > Reviewed-by: Greg Daniel > Commit-Queue: Greg Daniel TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com Change-Id: I52378fa43efe2fdf583335f5fa8aa5b04a68ae2f Bug: chromium:862921 Reviewed-on: https://skia-review.googlesource.com/142760 Commit-Queue: Greg Daniel Reviewed-by: Greg Daniel --- tests/GrMipMappedTest.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp index 3c47598e38..ee4838d2ce 100644 --- a/tests/GrMipMappedTest.cpp +++ b/tests/GrMipMappedTest.cpp @@ -289,3 +289,40 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn } } } + +// Test that we don't create a mip mapped texture if the size is 1x1 even if the filter mode is set +// to use mips. This test passes by not crashing or hitting asserts in code. +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + if (!context->contextPriv().caps()->mipMapSupport()) { + return; + } + + // Make surface to draw into + SkImageInfo info = SkImageInfo::MakeN32(16, 16, kPremul_SkAlphaType); + sk_sp surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); + + // Make 1x1 raster bitmap + SkBitmap bmp; + bmp.allocN32Pixels(1, 1); + SkPMColor* pixel = reinterpret_cast(bmp.getPixels()); + *pixel = 0; + + sk_sp bmpImage = SkImage::MakeFromBitmap(bmp); + + // Make sure we scale so we don't optimize out the use of mips. + surface->getCanvas()->scale(0.5f, 0.5f); + + SkPaint paint; + // This should upload the image to a non mipped GrTextureProxy. + surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint); + surface->flush(); + + // Now set the filter quality to high so we use mip maps. We should find the non mipped texture + // in the cache for the SkImage. Since the texture is 1x1 we should just use that texture + // instead of trying to do a copy to a mipped texture. + paint.setFilterQuality(kHigh_SkFilterQuality); + surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint); + surface->flush(); +} + -- cgit v1.2.3