Remove SK_SUPPORT_GPU checks in tool-only code
Most of this is (obviously) not necessary to do, but once
I started, I figured I'd just get it all. Tools (nanobench,
DM, skiaserve), all GMs, benches, and unit tests, plus support
code (command line parsing and config stuff).
This is almost entirely mechanical.
Bug: skia:
Change-Id: I209500f8df8c5bd43f8298ff26440d1c4d7425fb
Reviewed-on: https://skia-review.googlesource.com/131153
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 965298a..bb5291c 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -6,19 +6,7 @@
*/
#include <functional>
-#include "SkCanvas.h"
-#include "SkData.h"
-#include "SkDevice.h"
-#include "SkImage_Base.h"
-#include "SkOverdrawCanvas.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkRRect.h"
-#include "SkSurface.h"
-#include "SkUtils.h"
-#include "Test.h"
-
-#if SK_SUPPORT_GPU
+#include <initializer_list>
#include <vector>
#include "GrContext.h"
#include "GrContextPriv.h"
@@ -27,14 +15,23 @@
#include "GrRenderTargetContext.h"
#include "GrResourceProvider.h"
#include "GrTest.h"
+#include "SkCanvas.h"
+#include "SkData.h"
+#include "SkDevice.h"
#include "SkGpuDevice.h"
+#include "SkImage_Base.h"
#include "SkImage_Gpu.h"
+#include "SkOverdrawCanvas.h"
+#include "SkPath.h"
+#include "SkRegion.h"
+#include "SkRRect.h"
+#include "SkSurface.h"
#include "SkSurface_Gpu.h"
-#endif
+#include "SkUtils.h"
+#include "Test.h"
#include "sk_tool_utils.h"
-#include <initializer_list>
static void release_direct_surface_storage(void* pixels, void* context) {
SkASSERT(pixels == context);
@@ -60,7 +57,6 @@
release_direct_surface_storage,
storage);
}
-#if SK_SUPPORT_GPU
static sk_sp<SkSurface> create_gpu_surface(GrContext* context, SkAlphaType at = kPremul_SkAlphaType,
SkImageInfo* requestedInfo = nullptr) {
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
@@ -78,7 +74,6 @@
}
return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
}
-#endif
DEF_TEST(SurfaceEmpty, reporter) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
@@ -86,15 +81,12 @@
REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRasterDirect(info, nullptr, 0));
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, ctxInfo) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
REPORTER_ASSERT(reporter, nullptr ==
SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo, info));
}
-#endif
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, reporter, ctxInfo) {
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
static constexpr int kSize = 10;
@@ -210,7 +202,6 @@
REPORTER_ASSERT(reporter, sampleCnt == max, "Exected: %d, actual: %d", max, sampleCnt);
}
}
-#endif
static void test_canvas_peek(skiatest::Reporter* reporter,
sk_sp<SkSurface>& surface,
@@ -246,7 +237,6 @@
test_canvas_peek(reporter, surface, requestInfo, true);
}
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, ctxInfo) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
SkImageInfo requestInfo;
@@ -254,7 +244,6 @@
test_canvas_peek(reporter, surface, requestInfo, false);
}
}
-#endif
static void test_snapshot_alphatype(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
SkAlphaType expectedAlphaType) {
@@ -275,7 +264,6 @@
}
}
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceSnapshotAlphaType_Gpu, reporter, ctxInfo) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
// GPU doesn't support creating unpremul surfaces, so only test opaque + premul
@@ -331,9 +319,6 @@
}
}
}
-#endif
-
-#if SK_SUPPORT_GPU
template<typename Type, Type(SkSurface::*func)(SkSurface::BackendHandleAccess)>
static void test_backend_unique_id(skiatest::Reporter* reporter, SkSurface* surface) {
@@ -374,7 +359,6 @@
}
}
}
-#endif
// Verify that the right canvas commands trigger a copy on write.
static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface) {
@@ -454,14 +438,12 @@
DEF_TEST(SurfaceCopyOnWrite, reporter) {
test_copy_on_write(reporter, create_surface().get());
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCopyOnWrite_Gpu, reporter, ctxInfo) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
test_copy_on_write(reporter, surface.get());
}
}
-#endif
static void test_writable_after_snapshot_release(skiatest::Reporter* reporter,
SkSurface* surface) {
@@ -476,16 +458,13 @@
DEF_TEST(SurfaceWriteableAfterSnapshotRelease, reporter) {
test_writable_after_snapshot_release(reporter, create_surface().get());
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWriteableAfterSnapshotRelease_Gpu, reporter, ctxInfo) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
test_writable_after_snapshot_release(reporter, surface.get());
}
}
-#endif
-#if SK_SUPPORT_GPU
static void test_crbug263329(skiatest::Reporter* reporter,
SkSurface* surface1,
SkSurface* surface2) {
@@ -525,7 +504,6 @@
test_crbug263329(reporter, surface1.get(), surface2.get());
}
}
-#endif
DEF_TEST(SurfaceGetTexture, reporter) {
auto surface(create_surface());
@@ -534,7 +512,6 @@
surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
REPORTER_ASSERT(reporter, !as_IB(image)->isTextureBacked());
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
@@ -549,9 +526,6 @@
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(backendTex, backendTex2));
}
}
-#endif
-
-#if SK_SUPPORT_GPU
static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) {
SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get();
@@ -591,7 +565,6 @@
REPORTER_ASSERT(reporter, budgeted == is_budgeted(image));
}
}
-#endif
static void test_no_canvas1(skiatest::Reporter* reporter,
SkSurface* surface,
@@ -627,7 +600,6 @@
}
}
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceNoCanvas_Gpu, reporter, ctxInfo) {
SkSurface::ContentChangeMode modes[] =
{ SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentChangeMode};
@@ -640,7 +612,6 @@
}
}
}
-#endif
static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
SkPixmap surfacePM;
@@ -691,7 +662,6 @@
}
}
-#if SK_SUPPORT_GPU
static sk_sp<SkSurface> create_gpu_surface_backend_texture(
GrContext* context, int sampleCnt, uint32_t color, GrBackendTexture* outTexture) {
GrGpu* gpu = context->contextPriv().getGpu();
@@ -920,7 +890,6 @@
}
}
}
-#endif
static void test_surface_creation_and_snapshot_with_color_space(
skiatest::Reporter* reporter,
@@ -991,7 +960,6 @@
surfaceMaker);
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) {
auto context = ctxInfo.grContext();
@@ -1039,7 +1007,6 @@
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
}
-#endif
static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
SkOverdrawCanvas canvas(surface->getCanvas());
@@ -1060,13 +1027,11 @@
test_overdraw_surface(r, surface.get());
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(OverdrawSurface_Gpu, r, ctxInfo) {
GrContext* context = ctxInfo.grContext();
sk_sp<SkSurface> surface = create_gpu_surface(context);
test_overdraw_surface(r, surface.get());
}
-#endif
DEF_TEST(Surface_null, r) {
REPORTER_ASSERT(r, SkSurface::MakeNull(0, 0) == nullptr);