diff --git a/gm/flippity.cpp b/gm/flippity.cpp index 2c6d449aa4..25648eddd2 100644 --- a/gm/flippity.cpp +++ b/gm/flippity.cpp @@ -132,16 +132,12 @@ static sk_sp make_reference_image(GrDirectContext* context, auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; - // TODO: make MakeTextureProxyFromData return a GrSurfaceProxyView - auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, GrRenderable::kNo, origin, - bm.info(), bm.getPixels(), bm.rowBytes()); - if (!proxy) { + auto view = sk_gpu_test::MakeTextureProxyViewFromData(context, GrRenderable::kNo, origin, + bm.info(), bm.getPixels(), bm.rowBytes()); + if (!view) { return nullptr; } - GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(), - GrColorType::kRGBA_8888); - GrSurfaceProxyView view(std::move(proxy), origin, swizzle); return sk_make_sp(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view), ii.colorType(), kOpaque_SkAlphaType, nullptr); } diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 061893aa1f..162d9328a6 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -78,17 +78,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { for (const SkIRect& srcRect : kSrcRects) { for (const SkIPoint& dstPoint : kDstPoints) { for (const SkImageInfo& ii: kImageInfos) { - auto src = sk_gpu_test::MakeTextureProxyFromData( + auto srcView = sk_gpu_test::MakeTextureProxyViewFromData( dContext, sRenderable, sOrigin, ii, srcPixels.get(), kRowBytes); - auto dst = sk_gpu_test::MakeTextureProxyFromData( + auto dstView = sk_gpu_test::MakeTextureProxyViewFromData( dContext, dRenderable, dOrigin, ii, dstPixels.get(), kRowBytes); // Should always work if the color type is RGBA, but may not work // for BGRA if (ii.colorType() == kRGBA_8888_SkColorType) { - if (!src || !dst) { + if (!srcView || !dstView) { ERRORF(reporter, "Could not create surfaces for copy surface test."); continue; @@ -98,7 +98,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { kBGRA_8888_SkColorType, GrRenderable::kNo).isValid()) { continue; } - if (!src || !dst) { + if (!srcView || !dstView) { ERRORF(reporter, "Could not create surfaces for copy surface test."); continue; @@ -106,9 +106,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { } GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType()); - GrSwizzle dstSwizzle = dContext->priv().caps()->getReadSwizzle( - dst->backendFormat(), grColorType); - GrSurfaceProxyView dstView(std::move(dst), dOrigin, dstSwizzle); auto dstContext = GrSurfaceContext::Make(dContext, std::move(dstView), grColorType, @@ -116,14 +113,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { bool result = false; if (sOrigin == dOrigin) { - result = dstContext->testCopy(src.get(), srcRect, dstPoint); + result = dstContext->testCopy(srcView.proxy(), + srcRect, + dstPoint); } else if (dRenderable == GrRenderable::kYes) { SkASSERT(dstContext->asRenderTargetContext()); - GrSwizzle srcSwizzle = dContext->priv().caps()->getReadSwizzle( - src->backendFormat(), grColorType); - GrSurfaceProxyView view(std::move(src), sOrigin, srcSwizzle); result = dstContext->asRenderTargetContext()->blitTexture( - std::move(view), srcRect, dstPoint); + std::move(srcView), srcRect, dstPoint); } bool expectedResult = true; diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp index 0017c8f6fa..26117aca74 100644 --- a/tests/FloatingPointTextureTest.cpp +++ b/tests/FloatingPointTextureTest.cpp @@ -49,19 +49,16 @@ void runFPTest(skiatest::Reporter* reporter, GrDirectContext* dContext, } for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) { - auto fpProxy = sk_gpu_test::MakeTextureProxyFromData( + auto fpView = sk_gpu_test::MakeTextureProxyViewFromData( dContext, GrRenderable::kYes, origin, - {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, - controlPixelData.begin(), 0); + {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, controlPixelData.begin(), + 0); // Floating point textures are NOT supported everywhere - if (!fpProxy) { + if (!fpView) { continue; } - GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(fpProxy->backendFormat(), - colorType); - GrSurfaceProxyView view(std::move(fpProxy), origin, swizzle); - auto sContext = GrSurfaceContext::Make(dContext, std::move(view), colorType, + auto sContext = GrSurfaceContext::Make(dContext, std::move(fpView), colorType, kPremul_SkAlphaType, nullptr); REPORTER_ASSERT(reporter, sContext); @@ -70,7 +67,7 @@ void runFPTest(skiatest::Reporter* reporter, GrDirectContext* dContext, readBuffer.begin(), 0, {0, 0}); REPORTER_ASSERT(reporter, result); REPORTER_ASSERT(reporter, - 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes())); + !memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes())); } } diff --git a/tests/GrUploadPixelsTests.cpp b/tests/GrUploadPixelsTests.cpp index e935d017f3..10753d0cf8 100644 --- a/tests/GrUploadPixelsTests.cpp +++ b/tests/GrUploadPixelsTests.cpp @@ -32,13 +32,11 @@ void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* dContext, FillPixelData(kWidth, kHeight, srcBuffer.get()); auto grCT = SkColorTypeToGrColorType(ct); - auto proxy = sk_gpu_test::MakeTextureProxyFromData( + auto view = sk_gpu_test::MakeTextureProxyViewFromData( dContext, renderable, kTopLeft_GrSurfaceOrigin, {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0); - REPORTER_ASSERT(reporter, proxy); - if (proxy) { - GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT); - GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle); + REPORTER_ASSERT(reporter, view); + if (view) { auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType, nullptr); @@ -61,13 +59,11 @@ void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* dContext, REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 10, 2)); } - proxy = sk_gpu_test::MakeTextureProxyFromData( + view = sk_gpu_test::MakeTextureProxyViewFromData( dContext, renderable, kBottomLeft_GrSurfaceOrigin, {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0); - REPORTER_ASSERT(reporter, proxy); - if (proxy) { - GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), grCT); - GrSurfaceProxyView view(proxy, kBottomLeft_GrSurfaceOrigin, swizzle); + REPORTER_ASSERT(reporter, view); + if (view) { auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType, nullptr); @@ -88,7 +84,6 @@ void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* dContext, REPORTER_ASSERT(reporter, result); REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 4, 5)); - } } diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp index 5530656d36..d4136521f9 100644 --- a/tests/PackedConfigsTextureTest.cpp +++ b/tests/PackedConfigsTextureTest.cpp @@ -115,16 +115,12 @@ static void run_test(skiatest::Reporter* reporter, GrDirectContext* dContext, in for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { auto grColorType = SkColorTypeToGrColorType(colorType); - auto proxy = sk_gpu_test::MakeTextureProxyFromData( + auto view = sk_gpu_test::MakeTextureProxyViewFromData( dContext, GrRenderable::kNo, origin, - {grColorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, - controlPixelData.begin(), 0); - SkASSERT(proxy); + {grColorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, controlPixelData.begin(), + 0); + SkASSERT(view); - GrSwizzle readSwizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), - grColorType); - - GrSurfaceProxyView view(std::move(proxy), origin, readSwizzle); GrSurfaceContext sContext(dContext, std::move(view), grColorType, kPremul_SkAlphaType, nullptr); diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 74e13da90b..be4648723b 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -431,12 +431,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) { // On the GPU we will also try reading back from a non-renderable texture. for (auto origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) { for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) { - sk_sp proxy = sk_gpu_test::MakeTextureProxyFromData( + auto view = sk_gpu_test::MakeTextureProxyViewFromData( dContext, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes()); GrColorType grColorType = SkColorTypeToGrColorType(bmp.colorType()); - GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), - grColorType); - GrSurfaceProxyView view(std::move(proxy), origin, swizzle); auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grColorType, kPremul_SkAlphaType, nullptr); auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType); diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 1f4fd02437..1891dabb57 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -186,16 +186,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { auto origin = GrRenderable::kYes == renderable ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; - auto proxy = sk_gpu_test::MakeTextureProxyFromData( + auto view = sk_gpu_test::MakeTextureProxyViewFromData( dContext, renderable, origin, {info.fColorType, info.fAlphaType, nullptr, X_SIZE, Y_SIZE}, rgbaData, 0); - if (!proxy) { + if (!view) { continue; } - GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), - info.fColorType); - GrSurfaceProxyView view(std::move(proxy), origin, swizzle); auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.fColorType, kPremul_SkAlphaType, nullptr); diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index c45dcc7f08..c4ef0cfd9b 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -102,14 +102,14 @@ static void test_copy_to_surface(skiatest::Reporter* reporter, for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) { auto origin = dstContext->origin(); - auto src = sk_gpu_test::MakeTextureProxyFromData( + auto srcView = sk_gpu_test::MakeTextureProxyViewFromData( dContext, renderable, origin, {GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr, dstContext->width(), dstContext->height()}, pixels.get(), 0); // If this assert ever fails we can add a fallback to do copy as draw, but until then we can // be more restrictive. - SkAssertResult(dstContext->testCopy(src.get())); + SkAssertResult(dstContext->testCopy(srcView.proxy())); TestReadPixels(reporter, dContext, dstContext, pixels.get(), testName); } } diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp index 0c4b2e3efa..b740c631e0 100644 --- a/tools/gpu/ProxyUtils.cpp +++ b/tools/gpu/ProxyUtils.cpp @@ -21,21 +21,21 @@ namespace sk_gpu_test { -sk_sp MakeTextureProxyFromData(GrDirectContext* dContext, - GrRenderable renderable, - GrSurfaceOrigin origin, - const GrImageInfo& imageInfo, - const void* data, - size_t rowBytes) { +GrSurfaceProxyView MakeTextureProxyViewFromData(GrDirectContext* dContext, + GrRenderable renderable, + GrSurfaceOrigin origin, + const GrImageInfo& imageInfo, + const void* data, + size_t rowBytes) { if (dContext->abandoned()) { - return nullptr; + return {}; } const GrCaps* caps = dContext->priv().caps(); const GrBackendFormat format = caps->getDefaultBackendFormat(imageInfo.colorType(), renderable); if (!format.isValid()) { - return nullptr; + return {}; } GrSwizzle swizzle = caps->getReadSwizzle(format, imageInfo.colorType()); @@ -45,18 +45,18 @@ sk_sp MakeTextureProxyFromData(GrDirectContext* dContext, SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo); if (!proxy) { - return nullptr; + return {}; } GrSurfaceProxyView view(proxy, origin, swizzle); auto sContext = GrSurfaceContext::Make(dContext, std::move(view), imageInfo.colorType(), imageInfo.alphaType(), imageInfo.refColorSpace()); if (!sContext) { - return nullptr; + return {}; } if (!sContext->writePixels(dContext, imageInfo, data, rowBytes, {0, 0})) { - return nullptr; + return {}; } - return proxy; + return sContext->readSurfaceView(); } GrProgramInfo* CreateProgramInfo(const GrCaps* caps, diff --git a/tools/gpu/ProxyUtils.h b/tools/gpu/ProxyUtils.h index 4c83c202da..eace13f851 100644 --- a/tools/gpu/ProxyUtils.h +++ b/tools/gpu/ProxyUtils.h @@ -19,12 +19,12 @@ class GrProgramInfo; namespace sk_gpu_test { /** Makes a texture proxy containing the passed in color data. */ -sk_sp MakeTextureProxyFromData(GrDirectContext*, - GrRenderable, - GrSurfaceOrigin, - const GrImageInfo&, - const void* data, - size_t rowBytes); +GrSurfaceProxyView MakeTextureProxyViewFromData(GrDirectContext*, + GrRenderable, + GrSurfaceOrigin, + const GrImageInfo&, + const void* data, + size_t rowBytes); GrProgramInfo* CreateProgramInfo(const GrCaps*, SkArenaAlloc*,