Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(903)

Unified Diff: tests/SpecialSurfaceTest.cpp

Issue 1579323002: Add SkSpecialImage & SkSpecialSurface classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/core/SkSpecialSurface.h ('K') | « tests/SpecialImageTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SpecialSurfaceTest.cpp
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0cc10f5c342ede7ed2b54e0748790af48805e1bd
--- /dev/null
+++ b/tests/SpecialSurfaceTest.cpp
@@ -0,0 +1,61 @@
+/*
+* Copyright 2016 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file
+*/
+
+#include "SkCanvas.h"
+#include "SkSpecialImage.h"
+#include "SkSpecialSurface.h"
+#include "Test.h"
+
+#if SK_SUPPORT_GPU
+#include "GrContext.h"
+#endif
+
+// This needs to be a non-power-of-2 to exercise the gpu's loose fit behavior
+static const int kWidthHeight = 10;
+
+// Exercise the public API of SkSpecialSurface (e.g., getCanvas, newImageSnapshot)
+static void test_surface(SkSpecialSurface* surf, skiatest::Reporter* reporter) {
+
+ REPORTER_ASSERT(reporter, kWidthHeight == surf->width());
+ REPORTER_ASSERT(reporter, kWidthHeight == surf->height());
+
+ SkCanvas* canvas = surf->getCanvas();
+ SK_ALWAYSBREAK(canvas);
+
+ canvas->clear(SK_ColorRED);
+
+ SkAutoTUnref<SkSpecialImage> img(surf->newImageSnapshot());
+ REPORTER_ASSERT(reporter, img);
+
+ REPORTER_ASSERT(reporter, kWidthHeight == img->width());
+ REPORTER_ASSERT(reporter, kWidthHeight == img->height());
+
+ REPORTER_ASSERT(reporter, !surf->getCanvas());
+}
+
+DEF_TEST(SpecialSurface_Raster, reporter) {
+
+ SkImageInfo info = SkImageInfo::MakeN32(kWidthHeight, kWidthHeight, kOpaque_SkAlphaType);
+ SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::New(info));
+
+ test_surface(surf, reporter);
+}
+
+#if SK_SUPPORT_GPU
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu, reporter, context) {
+ GrSurfaceDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fWidth = kWidthHeight;
+ desc.fHeight = kWidthHeight;
+
+ SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::New(context, desc));
+
+ test_surface(surf, reporter);
+}
+
+#endif
« src/core/SkSpecialSurface.h ('K') | « tests/SpecialImageTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698