From 1b35256f1166358056b2aad8ce09caa6f07912d5 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Wed, 5 Apr 2017 18:56:21 +0000 Subject: Revert "Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv (take 2)" This reverts commit aaee31f18c0845417103d84285e365575def3c40. Reason for revert: possible valgrind leak Original change's description: > Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv (take 2) > > This is in service of: https://skia-review.googlesource.com/c/11125/ (Add parallel proxyID to StencilOps & RenderTargetOpList) where I want a better choke point for texture creation to improve discard handling. > > This is a reland of: https://skia-review.googlesource.com/c/11200/ (Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv) > > Change-Id: Icd0a90d2beb483dc24ed87c3bace9c817019e148 > Reviewed-on: https://skia-review.googlesource.com/11326 > Reviewed-by: Brian Salomon > Commit-Queue: Robert Phillips > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ia0b92bf6402cb5f9607310d356f43bff2e3e75eb Reviewed-on: https://skia-review.googlesource.com/11361 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- tests/IntTextureTest.cpp | 83 ++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 49 deletions(-) (limited to 'tests/IntTextureTest.cpp') diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index eacd0617a2..8ef57318ed 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -10,7 +10,6 @@ #if SK_SUPPORT_GPU #include "GrClip.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrRenderTargetContext.h" #include "GrResourceProvider.h" #include "GrTexture.h" @@ -65,8 +64,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { levels[1].fPixels = testData.get(); levels[1].fRowBytes = (kS / 2) * sizeof(int32_t); - sk_sp temp(context->resourceProvider()->createMipMappedTexture( - desc, + sk_sp temp(context->resourceProvider()->createMipMappedTexture(desc, SkBudgeted::kYes, levels, 2)); REPORTER_ASSERT(reporter, !temp); @@ -82,21 +80,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { return; } + GrTexture* texture = proxy->instantiate(context->resourceProvider()); + REPORTER_ASSERT(reporter, texture); + if (!texture) { + return; + } + std::unique_ptr readData(new int32_t[kS * kS]); // Test that reading to a non-integer config fails. { - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_8888_GrPixelConfig, - nullptr, readData.get()); + bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_GrPixelConfig, readData.get()); REPORTER_ASSERT(reporter, !success); } { std::unique_ptr halfData(new uint16_t[4 * kS * kS]); - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_half_GrPixelConfig, - nullptr, halfData.get()); + bool success = texture->readPixels(0, 0, kS, kS, kRGBA_half_GrPixelConfig, halfData.get()); REPORTER_ASSERT(reporter, !success); } { @@ -104,10 +102,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { // we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the // implementation-dependent second format). sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get()); + bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, + readData.get()); REPORTER_ASSERT(reporter, success); if (success) { check_pixels(reporter, kS, kS, testData.get(), readData.get(), "readPixels"); @@ -115,12 +111,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } { // readPixels should fail if we attempt to use the unpremul flag with an integer texture. - bool success = context->contextPriv().readSurfacePixels( - proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get(), 0, - GrContextPriv::kUnpremul_PixelOpsFlag); + bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, + readData.get(), 0, GrContext::kUnpremul_PixelOpsFlag); REPORTER_ASSERT(reporter, !success); } @@ -133,11 +125,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { return; } + GrSurface* copySurface = dstContext->asTextureProxy()->instantiate( + context->resourceProvider()); + REPORTER_ASSERT(reporter, copySurface); + if (!copySurface) { + return; + } + sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(dstContext->asSurfaceProxy(), - nullptr, 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get()); + bool success = copySurface->readPixels(0, 0, kS, kS, + kRGBA_8888_sint_GrPixelConfig, readData.get()); REPORTER_ASSERT(reporter, success); if (success) { check_pixels(reporter, kS, kS, testData.get(), readData.get(), "copyIntegerToInteger"); @@ -171,39 +168,27 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { { // Can't write pixels from a non-int config. - bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, - 0, 0, kS/2, kS/2, - kRGBA_8888_GrPixelConfig, nullptr, - bottomRightQuarter, kRowBytes); + bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_GrPixelConfig, + bottomRightQuarter, kRowBytes); REPORTER_ASSERT(reporter, !success); } { // Can't use unpremul flag. - bool success = context->contextPriv().writeSurfacePixels( - proxy.get(), nullptr, - 0, 0, kS/2, kS/2, - kRGBA_8888_sint_GrPixelConfig, - nullptr, + bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, bottomRightQuarter, kRowBytes, - GrContextPriv::kUnpremul_PixelOpsFlag); + GrContext::kUnpremul_PixelOpsFlag); REPORTER_ASSERT(reporter, !success); } { - bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, - 0, 0, kS/2, kS/2, - kRGBA_8888_sint_GrPixelConfig, - nullptr, - bottomRightQuarter, kRowBytes); + bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, + bottomRightQuarter, kRowBytes); REPORTER_ASSERT(reporter, success); if (!success) { return; } sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get(), 0); + success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get()); REPORTER_ASSERT(reporter, success); if (!success) { return; @@ -234,10 +219,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) | ((0xFF * g) << 8) | (0xFF * r); } - context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, nullptr, - testData.get(), 0); + texture->writePixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, testData.get()); + + sk_sp intTextureProxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(texture)); + texture = nullptr; // unused from here on out sk_sp rtContext = context->makeRenderTargetContext( SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr); @@ -253,7 +238,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { for (auto filter : kNamedFilters) { sk_sp fp(GrSimpleTextureEffect::Make(context->resourceProvider(), - proxy, nullptr, + intTextureProxy, nullptr, SkMatrix::I(), filter.fMode)); REPORTER_ASSERT(reporter, fp); -- cgit v1.2.3