diff options
author | Greg Daniel <egdaniel@google.com> | 2017-10-12 12:27:11 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-12 17:02:41 +0000 |
commit | 177e695589edb1f776cc5c28b9d3eee244d48284 (patch) | |
tree | eaa617f0300127c65a90a6aea03dc85f7d136d46 /tests | |
parent | 18e5cbbe65cc70c6818cc6b135ff45f4653f960b (diff) |
Add flag on GrBackendTexture to say whether texture is mipped or not
Bug: skia:
Change-Id: Ia684e3daf779ec2feaaec64c04dabf5cb03cd07a
Reviewed-on: https://skia-review.googlesource.com/57821
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BlendTest.cpp | 1 | ||||
-rw-r--r-- | tests/GrMipMappedTest.cpp | 97 | ||||
-rw-r--r-- | tests/GrPorterDuffTest.cpp | 1 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 1 | ||||
-rw-r--r-- | tests/ImageFilterCacheTest.cpp | 1 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 1 | ||||
-rw-r--r-- | tests/ResourceAllocatorTest.cpp | 1 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceSemaphoreTest.cpp | 1 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 3 | ||||
-rw-r--r-- | tests/TextureProxyTest.cpp | 1 | ||||
-rw-r--r-- | tests/VkWrapTests.cpp | 6 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 3 |
13 files changed, 115 insertions, 4 deletions
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp index 20ea6e0f00..354bb3cebb 100644 --- a/tests/BlendTest.cpp +++ b/tests/BlendTest.cpp @@ -105,6 +105,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target( width, height, config, + GrMipMapped::kNo, (*backingSurface)->getTextureHandle()); sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(context, backendTex, origin, diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp new file mode 100644 index 0000000000..166713a2bd --- /dev/null +++ b/tests/GrMipMappedTest.cpp @@ -0,0 +1,97 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkTypes.h" + +#if SK_SUPPORT_GPU + +#include "GrBackendSurface.h" +#include "GrContext.h" +#include "GrContextPriv.h" +#include "GrGpu.h" +#include "GrRenderTargetContext.h" +#include "GrSurfaceProxyPriv.h" +#include "GrTest.h" +#include "GrTexturePriv.h" +#include "GrTextureProxy.h" +#include "SkCanvas.h" +#include "SkImage_Base.h" +#include "SkGpuDevice.h" +#include "SkSurface.h" +#include "SkSurface_Gpu.h" +#include "Test.h" + +// Test that the correct mip map states are on the GrTextures when wrapping GrBackendTextures in +// SkImages and SkSurfaces +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { + for (auto isRT : {false, true}) { + // CreateTestingOnlyBackendTexture currently doesn't support uploading data to mip maps + // so we don't send any. However, we pretend there is data for the checks below which is + // fine since we are never actually using these textures for any work on the gpu. + GrBackendObject backendHandle = context->getGpu()->createTestingOnlyBackendTexture( + nullptr, 8, 8, kRGBA_8888_GrPixelConfig, isRT, mipMapped); + + GrBackend backend = context->contextPriv().getBackend(); + GrBackendTexture backendTex = GrTest::CreateBackendTexture(backend, + 8, + 8, + kRGBA_8888_GrPixelConfig, + mipMapped, + backendHandle); + + GrTextureProxy* proxy; + sk_sp<SkImage> image; + if (isRT) { + sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture( + context, + backendTex, + kTopLeft_GrSurfaceOrigin, + 0, + nullptr, + nullptr); + + SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); + proxy = device->accessRenderTargetContext()->asTextureProxy(); + } else { + image = SkImage::MakeFromTexture(context, backendTex, + kTopLeft_GrSurfaceOrigin, + kPremul_SkAlphaType, nullptr); + proxy = as_IB(image)->peekProxy(); + } + REPORTER_ASSERT(reporter, proxy); + if (!proxy) { + context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle); + return; + } + + REPORTER_ASSERT(reporter, proxy->priv().isInstantiated()); + + GrTexture* texture = proxy->priv().peekTexture(); + REPORTER_ASSERT(reporter, texture); + if (!texture) { + context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle); + return; + } + + if (GrMipMapped::kYes == mipMapped) { + REPORTER_ASSERT(reporter, texture->texturePriv().hasMipMaps()); + if (isRT) { + REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); + } else { + REPORTER_ASSERT(reporter, !texture->texturePriv().mipMapsAreDirty()); + } + } else { + REPORTER_ASSERT(reporter, !texture->texturePriv().hasMipMaps()); + } + context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle); + } + } +} + +#endif diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp index 073bdf0667..6ce0458a56 100644 --- a/tests/GrPorterDuffTest.cpp +++ b/tests/GrPorterDuffTest.cpp @@ -1072,6 +1072,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { 100, 100, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendTexHandle); GrXferProcessor::DstProxy fakeDstProxy; diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 8f5aa55685..e5dc6ae824 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -54,6 +54,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { 256, 256, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendTexHandle); sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapRenderableBackendTexture( diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp index 4e6df3b57e..449b252acf 100644 --- a/tests/ImageFilterCacheTest.cpp +++ b/tests/ImageFilterCacheTest.cpp @@ -219,6 +219,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ct kFullSize, kFullSize, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, tex->getTextureHandle()); GrSurfaceOrigin texOrigin = kTopLeft_GrSurfaceOrigin; sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context, diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 9e0137f3cf..a35d56caf3 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -776,6 +776,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c kWidth, kHeight, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendTexHandle); TextureReleaseChecker releaseChecker; diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp index 7af0d03a35..bb4acf013f 100644 --- a/tests/ResourceAllocatorTest.cpp +++ b/tests/ResourceAllocatorTest.cpp @@ -52,6 +52,7 @@ static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams& p.fSize, p.fSize, p.fConfig, + GrMipMapped::kNo, *backendTexHandle); sk_sp<GrSurface> tex = context->resourceProvider()->wrapBackendTexture(backendTex, diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index af33f2d9bc..0cb1d2b269 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -214,6 +214,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI kW, kH, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, texHandles[0]); sk_sp<GrTexture> borrowed(context->resourceProvider()->wrapBackendTexture( backendTex1, kBorrow_GrWrapOwnership)); @@ -222,6 +223,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI kW, kH, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, texHandles[1]); sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture( backendTex2, kAdopt_GrWrapOwnership)); diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp index 09d3c35900..9b3f90429a 100644 --- a/tests/SurfaceSemaphoreTest.cpp +++ b/tests/SurfaceSemaphoreTest.cpp @@ -67,6 +67,7 @@ void draw_child(skiatest::Reporter* reporter, GrBackendTexture backendTexture = GrTest::CreateBackendTexture(childInfo.backend(), MAIN_W, MAIN_H, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendImage); childInfo.testContext()->makeCurrent(); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 2fd987fdf6..bcd9e2dc7e 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -596,6 +596,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture( kWidth, kHeight, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendHandle); sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, backendTex, @@ -623,6 +624,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target( kWidth, kHeight, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, backendHandle); sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget( context, backendTex, kTopLeft_GrSurfaceOrigin, sampleCnt, nullptr, nullptr); @@ -904,6 +906,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, kSize, kSize, config, + GrMipMapped::kNo, backendHandle); return SkSurface::MakeFromBackendTexture(context, backendTex, diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp index d2277890c2..a4b93c8d7a 100644 --- a/tests/TextureProxyTest.cpp +++ b/tests/TextureProxyTest.cpp @@ -125,6 +125,7 @@ static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackin GrTest::CreateBackendTexture(context->contextPriv().getBackend(), 64, 64, kRGBA_8888_GrPixelConfig, + GrMipMapped::kNo, (*backingSurface)->getTextureHandle()); return GrSurfaceProxy::MakeWrappedBackend(context, backendTex, kBottomLeft_GrSurfaceOrigin); diff --git a/tests/VkWrapTests.cpp b/tests/VkWrapTests.cpp index 4f4c83362f..07b82a8a2d 100644 --- a/tests/VkWrapTests.cpp +++ b/tests/VkWrapTests.cpp @@ -33,7 +33,7 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - false); + false, GrMipMapped::kNo); const GrVkImageInfo* imageInfo = reinterpret_cast<const GrVkImageInfo*>(backendObj); GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo); @@ -71,7 +71,7 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - true); + true, GrMipMapped::kNo); const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj); GrBackendRenderTarget backendRT(kW, kH, 0, 0, *backendTex); @@ -103,7 +103,7 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig, - true); + true, GrMipMapped::kNo); const GrVkImageInfo* imageInfo = reinterpret_cast<const GrVkImageInfo*>(backendObj); GrBackendTexture backendTex = GrBackendTexture(kW, kH, *imageInfo); diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index 7ea0aad12f..92390ae023 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -431,7 +431,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsNonTexture_Gpu, reporter, ctxInfo) auto handle = context->getGpu()->createTestingOnlyBackendTexture( nullptr, DEV_W, DEV_H, kSkia8888_GrPixelConfig, true); GrBackendTexture backendTexture = GrTest::CreateBackendTexture( - ctxInfo.backend(), DEV_W, DEV_H, kSkia8888_GrPixelConfig, handle); + ctxInfo.backend(), DEV_W, DEV_H, kSkia8888_GrPixelConfig, GrMipMapped::kNo, + handle); sk_sp<SkSurface> surface(SkSurface::MakeFromBackendTextureAsRenderTarget( context, backendTexture, origin, sampleCnt, nullptr, nullptr)); if (!surface) { |