Update tests for a V1-only skgpu::v1::SurfaceDrawContext
Bug: skia:11837
Change-Id: If8dd864d6cd8bc5ab9569fbab40866e1810dbc27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434162
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gn/tests.gni b/gn/tests.gni
index b1c5c5c..f88123f6 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -34,7 +34,6 @@
"$_tests/CanvasStateTest.cpp",
"$_tests/CanvasTest.cpp",
"$_tests/ChecksumTest.cpp",
- "$_tests/ClearTest.cpp",
"$_tests/ClipBoundsTest.cpp",
"$_tests/ClipCubicTest.cpp",
"$_tests/ClipStackTest.cpp",
@@ -54,11 +53,9 @@
"$_tests/CopySurfaceTest.cpp",
"$_tests/CubicMapTest.cpp",
"$_tests/CullTestTest.cpp",
- "$_tests/DMSAATest.cpp",
"$_tests/DashPathEffectTest.cpp",
"$_tests/DataRefTest.cpp",
"$_tests/DebugLayerManagerTest.cpp",
- "$_tests/DefaultPathRendererTest.cpp",
"$_tests/DeferredDisplayListTest.cpp",
"$_tests/DequeTest.cpp",
"$_tests/DescriptorTest.cpp",
@@ -103,7 +100,6 @@
"$_tests/GrDDLImageTest.cpp",
"$_tests/GrFinishedFlushTest.cpp",
"$_tests/GrMemoryPoolTest.cpp",
- "$_tests/GrMipMappedTest.cpp",
"$_tests/GrOpListFlushTest.cpp",
"$_tests/GrPathUtilsTest.cpp",
"$_tests/GrPorterDuffTest.cpp",
@@ -140,7 +136,6 @@
"$_tests/JSONTest.cpp",
"$_tests/LListTest.cpp",
"$_tests/LRUCacheTest.cpp",
- "$_tests/LazyProxyTest.cpp",
"$_tests/M44Test.cpp",
"$_tests/MD5Test.cpp",
"$_tests/MallocPixelRefTest.cpp",
@@ -190,8 +185,6 @@
"$_tests/PointTest.cpp",
"$_tests/PolyUtilsTest.cpp",
"$_tests/PremulAlphaRoundTripTest.cpp",
- "$_tests/PrimitiveProcessorTest.cpp",
- "$_tests/ProcessorTest.cpp",
"$_tests/PromiseImageTest.cpp",
"$_tests/ProxyConversionTest.cpp",
"$_tests/ProxyRefTest.cpp",
@@ -248,7 +241,6 @@
"$_tests/SkRemoteGlyphCacheTest.cpp",
"$_tests/SkResourceCacheTest.cpp",
"$_tests/SkRuntimeEffectTest.cpp",
- "$_tests/SkSLCross.cpp",
"$_tests/SkSLDSLErrorLineNumbers.cpp",
"$_tests/SkSLDSLOnlyTest.cpp",
"$_tests/SkSLDSLTest.cpp",
@@ -403,13 +395,21 @@
skgpu_v1_tests_sources = [
"$_tests/BulkRectTest.cpp",
+ "$_tests/ClearTest.cpp",
+ "$_tests/DMSAATest.cpp",
+ "$_tests/DefaultPathRendererTest.cpp",
"$_tests/GrClipStackTest.cpp",
"$_tests/GrMeshTest.cpp",
+ "$_tests/GrMipMappedTest.cpp",
"$_tests/GrPipelineDynamicStateTest.cpp",
"$_tests/GrThreadSafeCacheTest.cpp",
+ "$_tests/LazyProxyTest.cpp",
"$_tests/OpChainTest.cpp",
"$_tests/PathRendererCacheTests.cpp",
+ "$_tests/PrimitiveProcessorTest.cpp",
+ "$_tests/ProcessorTest.cpp",
"$_tests/ProgramsTest.cpp",
+ "$_tests/SkSLCross.cpp",
"$_tests/SurfaceDrawContextTest.cpp",
"$_tests/TextureOpTest.cpp",
]
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index f81a16d..f73a7ed 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -34,7 +34,6 @@
#include "src/gpu/GrResourceCache.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
@@ -877,6 +876,7 @@
#if SK_GPU_V1
#include "src/gpu/GrClipStackClip.h"
#include "src/gpu/GrReducedClip.h"
+#include "src/gpu/v1/SurfaceDrawContext_v1.h"
typedef GrReducedClip::ElementList ElementList;
typedef GrReducedClip::InitialState InitialState;
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 0afea0e..23d7ad4 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -18,11 +18,10 @@
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
-#include "src/gpu/GrSurfaceContext.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrSurfaceProxy.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
#include "tools/gpu/ProxyUtils.h"
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 2bf76aa..d11a836 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -36,7 +36,6 @@
#include "src/gpu/GrRenderTargetProxy.h"
#include "src/gpu/GrTextureProxy.h"
#include "src/gpu/gl/GrGLDefines.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "src/image/SkImage_GpuBase.h"
#include "src/image/SkSurface_Gpu.h"
#include "tests/Test.h"
diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp
index 6348881..ca47778 100644
--- a/tests/DrawOpAtlasTest.cpp
+++ b/tests/DrawOpAtlasTest.cpp
@@ -34,7 +34,6 @@
#include "src/gpu/ops/GrDrawOp.h"
#include "src/gpu/ops/GrOp.h"
#include "src/gpu/text/GrAtlasManager.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
@@ -187,6 +186,9 @@
check(reporter, atlas.get(), 1, 4, 1);
}
+#if SK_GPU_V1
+#include "src/gpu/v1/SurfaceDrawContext_v1.h"
+
// This test verifies that the GrAtlasTextOp::onPrepare method correctly handles a failure
// when allocating an atlas page.
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo) {
@@ -242,6 +244,7 @@
op->prepare(&flushState);
flushState.setOpArgs(nullptr);
}
+#endif // SK_GPU_V1
void test_atlas_config(skiatest::Reporter* reporter, int maxTextureSize, size_t maxBytes,
GrMaskFormat maskFormat, SkISize expectedDimensions,
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index a1017bb..43e0e6f 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -9,11 +9,11 @@
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrShaderCaps.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxyPriv.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLUtil.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/GrContextFactory.h"
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 22e20c1..9244c0f 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -18,9 +18,9 @@
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrResourceProvider.h"
+#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/SkGr.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/BackendTextureImageFactory.h"
@@ -286,25 +286,25 @@
// Try creating the texture as a deferred proxy.
{
- std::unique_ptr<GrSurfaceContext> sdc;
- if (renderable == GrRenderable::kYes) {
- sdc = skgpu::v1::SurfaceDrawContext::Make(
- dContext, combo.fColorType, nullptr, fit,
- {desc.fWidth, desc.fHeight}, SkSurfaceProps(), 1,
- GrMipmapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
- } else {
- GrImageInfo info(combo.fColorType,
- kUnknown_SkAlphaType,
- nullptr,
- {desc.fHeight, desc.fHeight});
- sdc = GrSurfaceContext::Make(dContext, info, combo.fFormat, fit);
- }
- if (!sdc) {
+ GrImageInfo info(combo.fColorType,
+ GrColorTypeHasAlpha(combo.fColorType)
+ ? kPremul_SkAlphaType
+ : kOpaque_SkAlphaType,
+ nullptr,
+ {desc.fHeight, desc.fHeight});
+
+ auto sc = GrSurfaceContext::Make(dContext,
+ info,
+ combo.fFormat,
+ fit,
+ kTopLeft_GrSurfaceOrigin,
+ renderable);
+ if (!sc) {
continue;
}
readback.erase(kClearColor);
- if (sdc->readPixels(dContext, readback, {0, 0})) {
+ if (sc->readPixels(dContext, readback, {0, 0})) {
for (int i = 0; i < kSize * kSize; ++i) {
if (!checkColor(combo, readback.addr32()[i])) {
break;
diff --git a/tests/ReadWritePixelsGpuTest.cpp b/tests/ReadWritePixelsGpuTest.cpp
index ecde9d6..890363e 100644
--- a/tests/ReadWritePixelsGpuTest.cpp
+++ b/tests/ReadWritePixelsGpuTest.cpp
@@ -15,8 +15,8 @@
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceContext.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/effects/GrTextureEffect.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/ToolUtils.h"
@@ -1178,13 +1178,11 @@
// TODO: Update this when read pixels supports reading back levels to read
// directly rather than using minimizing draws.
- auto dst = skgpu::v1::SurfaceDrawContext::Make(direct,
- info.colorType(),
- info.refColorSpace(),
- SkBackingFit::kExact,
- info.dimensions(),
- SkSurfaceProps());
- SkASSERT(dst);
+ auto dstSC = GrSurfaceContext::Make(direct, info,
+ SkBackingFit::kExact,
+ kBottomLeft_GrSurfaceOrigin,
+ GrRenderable::kYes);
+ SkASSERT(dstSC);
GrSamplerState sampler(SkFilterMode::kNearest, SkMipmapMode::kNearest);
for (int i = 1; i <= 1; ++i) {
auto te = GrTextureEffect::Make(sc->readSurfaceView(),
@@ -1192,13 +1190,14 @@
SkMatrix::I(),
sampler,
*direct->priv().caps());
- dst->fillRectToRectWithFP(SkIRect::MakeSize(sc->dimensions()),
- SkIRect::MakeSize(levels[i].dimensions()),
- std::move(te));
+ dstSC->asFillContext()->fillRectToRectWithFP(
+ SkIRect::MakeSize(sc->dimensions()),
+ SkIRect::MakeSize(levels[i].dimensions()),
+ std::move(te));
GrImageInfo readInfo =
- dst->imageInfo().makeDimensions(levels[i].dimensions());
+ dstSC->imageInfo().makeDimensions(levels[i].dimensions());
GrPixmap read = GrPixmap::Allocate(readInfo);
- if (!dst->readPixels(direct, read, {0, 0})) {
+ if (!dstSC->readPixels(direct, read, {0, 0})) {
continue;
}
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index de28c2c..1ecdac9 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -11,10 +11,10 @@
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/GrTextureEffect.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLUtil.h"
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index 03c9e46..5be6261 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -13,7 +13,6 @@
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/SkGr.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
// using anonymous namespace because these functions are used as template params.
@@ -191,14 +190,19 @@
static std::unique_ptr<GrSurfaceContext> make_surface_context(Encoding contextEncoding,
GrRecordingContext* rContext,
skiatest::Reporter* reporter) {
- auto surfaceContext = skgpu::v1::SurfaceDrawContext::Make(
- rContext, GrColorType::kRGBA_8888, encoding_as_color_space(contextEncoding),
- SkBackingFit::kExact, {kW, kH}, SkSurfaceProps(), 1, GrMipmapped::kNo, GrProtected::kNo,
- kBottomLeft_GrSurfaceOrigin, SkBudgeted::kNo);
- if (!surfaceContext) {
+ GrImageInfo info(GrColorType::kRGBA_8888,
+ kPremul_SkAlphaType,
+ encoding_as_color_space(contextEncoding),
+ kW, kH);
+
+ auto sc = GrSurfaceContext::Make(rContext, info,
+ SkBackingFit::kExact,
+ kBottomLeft_GrSurfaceOrigin,
+ GrRenderable::kYes);
+ if (!sc) {
ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding));
}
- return std::move(surfaceContext);
+ return sc;
}
static void test_write_read(Encoding contextEncoding, Encoding writeEncoding, Encoding readEncoding,
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 431e36b..57a0ff1 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -25,7 +25,7 @@
#include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrResourceProvider.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkImage_Gpu.h"
#include "src/image/SkSurface_Gpu.h"
diff --git a/tests/TriangulatingPathRendererTests.cpp b/tests/TriangulatingPathRendererTests.cpp
index b9eaa92..9d45b05 100644
--- a/tests/TriangulatingPathRendererTests.cpp
+++ b/tests/TriangulatingPathRendererTests.cpp
@@ -16,7 +16,6 @@
#include "src/gpu/GrStyle.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/geometry/GrStyledShape.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "src/shaders/SkShaderBase.h"
#include "tools/ToolUtils.h"
#include <map>
@@ -486,6 +485,7 @@
#if SK_GPU_V1
#include "src/gpu/ops/GrTriangulatingPathRenderer.h"
+#include "src/gpu/v1/SurfaceDrawContext_v1.h"
// A simple concave path. Test this with a non-invertible matrix.
static SkPath create_path_17() {
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index 296291c..cc06457 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -18,7 +18,6 @@
#include "include/gpu/vk/GrVkVulkan.h"
#include "src/gpu/GrTexture.h"
#include "src/gpu/GrTextureProxy.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "src/gpu/vk/GrVkGpu.h"
#include "src/gpu/vk/GrVkImageLayout.h"
#include "src/gpu/vk/GrVkTexture.h"
diff --git a/tests/WrappedSurfaceCopyOnWriteTest.cpp b/tests/WrappedSurfaceCopyOnWriteTest.cpp
index 215b9f3..2725cf4 100644
--- a/tests/WrappedSurfaceCopyOnWriteTest.cpp
+++ b/tests/WrappedSurfaceCopyOnWriteTest.cpp
@@ -13,8 +13,8 @@
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrSurfaceFillContext.h"
#include "src/gpu/GrSurfaceProxy.h"
-#include "src/gpu/v1/SurfaceDrawContext_v1.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "tools/gpu/BackendSurfaceFactory.h"
@@ -82,26 +82,27 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkipCopyTaskTest, reporter, ctxInfo) {
GrDirectContext* dContext = ctxInfo.directContext();
- auto dst = skgpu::v1::SurfaceDrawContext::Make(dContext,
- GrColorType::kRGBA_8888,
- /*color space*/ nullptr,
- SkBackingFit::kExact,
- {10, 10},
- SkSurfaceProps());
- dst->clear(SkPMColor4f{1, 0, 0, 1});
+ GrImageInfo info(GrColorType::kRGBA_8888,
+ kPremul_SkAlphaType,
+ /*color space*/ nullptr,
+ 10, 10);
- auto src = skgpu::v1::SurfaceDrawContext::Make(dContext,
- GrColorType::kRGBA_8888,
- /*color space*/ nullptr,
- SkBackingFit::kExact,
- {10, 10},
- SkSurfaceProps());
- src->clear(SkPMColor4f{0, 0, 1, 1});
+ auto dstSC = GrSurfaceContext::Make(dContext, info,
+ SkBackingFit::kExact,
+ kBottomLeft_GrSurfaceOrigin,
+ GrRenderable::kYes);
+ dstSC->asFillContext()->clear(SkPMColor4f{1, 0, 0, 1});
+
+ auto srcSC = GrSurfaceContext::Make(dContext, info,
+ SkBackingFit::kExact,
+ kBottomLeft_GrSurfaceOrigin,
+ GrRenderable::kYes);
+ srcSC->asFillContext()->clear(SkPMColor4f{0, 0, 1, 1});
sk_sp<GrRenderTask> task =
- dContext->priv().drawingManager()->newCopyRenderTask(src->asSurfaceProxyRef(),
+ dContext->priv().drawingManager()->newCopyRenderTask(srcSC->asSurfaceProxyRef(),
SkIRect::MakeWH(10, 10),
- dst->asSurfaceProxyRef(),
+ dstSC->asSurfaceProxyRef(),
{0, 0},
kTopLeft_GrSurfaceOrigin);
@@ -114,7 +115,7 @@
SkAutoPixmapStorage pixels;
pixels.alloc(SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
- dst->readPixels(dContext, pixels, {0, 0});
+ dstSC->readPixels(dContext, pixels, {0, 0});
float kTol[4] = {};
std::function<ComparePixmapsErrorReporter> errorReporter(
[&](int x, int y, const float diffs[4]) {
@@ -124,6 +125,9 @@
CheckSolidPixels(SkColor4f{1, 0, 0, 1}, pixels, kTol, errorReporter);
}
+#if SK_GPU_V1
+#include "src/gpu/v1/SurfaceDrawContext_v1.h"
+
// Make sure GrOpsTask are skippable
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkipOpsTaskTest, reporter, ctxInfo) {
GrDirectContext* dContext = ctxInfo.directContext();
@@ -164,3 +168,4 @@
});
CheckSolidPixels(SkColor4f{1, 0, 0, 1}, pixels, kTol, errorReporter);
}
+#endif // SK_GPU_V1