aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SurfaceTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/SurfaceTest.cpp')
-rw-r--r--tests/SurfaceTest.cpp59
1 files changed, 12 insertions, 47 deletions
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 965298a816..bb5291cbb3 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 @@ static sk_sp<SkSurface> create_direct_surface(SkAlphaType at = kPremul_SkAlphaTy
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 @@ static sk_sp<SkSurface> create_gpu_scratch_surface(GrContext* context,
}
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 @@ DEF_TEST(SurfaceEmpty, reporter) {
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo
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 @@ DEF_TEST(SurfaceCanvasPeek, reporter) {
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, ctxInfo) {
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 @@ DEF_TEST(SurfaceSnapshotAlphaType, reporter) {
}
}
}
-#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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendSurfaceAccessCopyOnWrite_Gpu, r
}
}
}
-#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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter,
}
}
}
-#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 @@ static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface)
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 @@ static void test_writable_after_snapshot_release(skiatest::Reporter* reporter,
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, ctxInfo) {
test_crbug263329(reporter, surface1.get(), surface2.get());
}
}
-#endif
DEF_TEST(SurfaceGetTexture, reporter) {
auto surface(create_surface());
@@ -534,7 +512,6 @@ DEF_TEST(SurfaceGetTexture, reporter) {
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) {
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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, budgeted == is_budgeted(image));
}
}
-#endif
static void test_no_canvas1(skiatest::Reporter* reporter,
SkSurface* surface,
@@ -627,7 +600,6 @@ DEF_TEST(SurfaceNoCanvas, reporter) {
}
}
}
-#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 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceNoCanvas_Gpu, reporter, ctxInfo) {
}
}
}
-#endif
static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
SkPixmap surfacePM;
@@ -691,7 +662,6 @@ DEF_TEST(surface_raster_zeroinitialized, reporter) {
}
}
-#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 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf
}
}
}
-#endif
static void test_surface_creation_and_snapshot_with_color_space(
skiatest::Reporter* reporter,
@@ -991,7 +960,6 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) {
surfaceMaker);
}
-#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) {
auto context = ctxInfo.grContext();
@@ -1039,7 +1007,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter,
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
}
-#endif
static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
SkOverdrawCanvas canvas(surface->getCanvas());
@@ -1060,13 +1027,11 @@ DEF_TEST(OverdrawSurface_Raster, r) {
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);