aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-10-30 13:41:26 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-30 20:06:53 +0000
commit45d6303f6e8403db9499ab28494f672b2bcd034e (patch)
treee3729181fa9bdccbb6fc87f3bf4489d8daba5edd /tests
parent1b361150239a2ae79979a5bab5c35dfa0c5adb9c (diff)
Have mip status match surface when snapping image from wrapped object
Also fixes some bugs involved with creating mipped SkSurfaces. Bug: skia: Change-Id: I6e0109000eadd2bdee4a907d3ee2231104528165 Reviewed-on: https://skia-review.googlesource.com/65063 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GLProgramsTest.cpp2
-rw-r--r--tests/GpuSampleLocationsTest.cpp4
-rw-r--r--tests/GrMipMappedTest.cpp75
-rw-r--r--tests/PathRendererCacheTests.cpp2
-rw-r--r--tests/TessellatingPathRendererTests.cpp1
5 files changed, 76 insertions, 8 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 55ffca911f..e0ac272009 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -159,7 +159,7 @@ static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* cont
kRGBA_8888_GrPixelConfig,
nullptr,
sampleCnt,
- false,
+ GrMipMapped::kNo,
origin));
return renderTargetContext;
}
diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp
index fa99a9ae9e..36b518111f 100644
--- a/tests/GpuSampleLocationsTest.cpp
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -119,11 +119,11 @@ void test_sampleLocations(skiatest::Reporter* reporter, TestSampleLocationsInter
GrAlwaysAssert(numSamples > 1 && SkIsPow2(numSamples));
bottomUps[i] = ctx->makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
- rand.nextRangeU(1 + numSamples / 2, numSamples),
+ rand.nextRangeU(1 + numSamples / 2, numSamples), GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin);
topDowns[i] = ctx->makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
- rand.nextRangeU(1 + numSamples / 2, numSamples),
+ rand.nextRangeU(1 + numSamples / 2, numSamples), GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin);
}
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index aad3b60d8d..f023018902 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -28,6 +28,8 @@
#include "SkSurface_Gpu.h"
#include "Test.h"
+static constexpr int kSize = 8;
+
// 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) {
@@ -45,8 +47,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
GrBackend backend = context->contextPriv().getBackend();
GrBackendTexture backendTex = GrTest::CreateBackendTexture(backend,
- 8,
- 8,
+ kSize,
+ kSize,
kRGBA_8888_GrPixelConfig,
mipMapped,
backendHandle);
@@ -103,8 +105,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
// Test that we correctly copy or don't copy GrBackendTextures in the GrBackendTextureImageGenerator
// based on if we will use mips in the draw and the mip status of the GrBackendTexture.
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter, ctxInfo) {
- static const int kSize = 8;
-
GrContext* context = ctxInfo.grContext();
if (!context->caps()->mipMapSupport()) {
return;
@@ -218,5 +218,72 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
}
}
+// Test that when we call makeImageSnapshot on an SkSurface we retains the same mip status as the
+// resource we took the snapshot of.
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
+ if (!context->caps()->mipMapSupport()) {
+ return;
+ }
+
+ for (auto willUseMips : {false, true}) {
+ for (auto isWrapped : {false, true}) {
+ GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
+ sk_sp<SkSurface> surface;
+ GrBackendObject backendHandle = context->getGpu()->createTestingOnlyBackendTexture(
+ nullptr, 8, 8, kRGBA_8888_GrPixelConfig, true, mipMapped);
+ if (isWrapped) {
+ GrBackend backend = context->contextPriv().getBackend();
+ GrBackendTexture backendTex = GrTest::CreateBackendTexture(backend,
+ kSize,
+ kSize,
+ kRGBA_8888_GrPixelConfig,
+ mipMapped,
+ backendHandle);
+
+ surface = SkSurface::MakeFromBackendTexture(context,
+ backendTex,
+ kTopLeft_GrSurfaceOrigin,
+ 0,
+ nullptr,
+ nullptr);
+ } else {
+ SkImageInfo info = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType);
+ surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0,
+ kTopLeft_GrSurfaceOrigin, nullptr,
+ willUseMips);
+ }
+ REPORTER_ASSERT(reporter, surface);
+ if (!surface) {
+ context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
+ }
+ SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
+ GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy();
+ REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
+
+ texProxy->instantiate(context->resourceProvider());
+ GrTexture* texture = texProxy->priv().peekTexture();
+ REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped());
+
+ sk_sp<SkImage> image = surface->makeImageSnapshot();
+ REPORTER_ASSERT(reporter, image);
+ if (!image) {
+ context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
+ }
+ texProxy = as_IB(image)->peekProxy();
+ REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
+
+ texProxy->instantiate(context->resourceProvider());
+ texture = texProxy->priv().peekTexture();
+ REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped());
+
+ // Must flush the context to make sure all the cmds (copies, etc.) from above are sent
+ // to the gpu before we delete the backendHandle.
+ context->flush();
+ context->getGpu()->deleteTestingOnlyBackendTexture(backendHandle);
+ }
+ }
+}
#endif
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 33a02ca943..dbf01ab029 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -81,7 +81,7 @@ static void test_path(skiatest::Reporter* reporter,
sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 0,
- kTopLeft_GrSurfaceOrigin));
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 6c414df9bb..b622f3767a 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -425,6 +425,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
kRGBA_8888_GrPixelConfig,
nullptr,
0,
+ GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;