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

Side by Side 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 unified diff | Download patch
« src/core/SkSpecialSurface.h ('K') | « tests/SpecialImageTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file
6 */
7
8 #include "SkCanvas.h"
9 #include "SkSpecialImage.h"
10 #include "SkSpecialSurface.h"
11 #include "Test.h"
12
13 #if SK_SUPPORT_GPU
14 #include "GrContext.h"
15 #endif
16
17 // This needs to be a non-power-of-2 to exercise the gpu's loose fit behavior
18 static const int kWidthHeight = 10;
19
20 // Exercise the public API of SkSpecialSurface (e.g., getCanvas, newImageSnapsho t)
21 static void test_surface(SkSpecialSurface* surf, skiatest::Reporter* reporter) {
22
23 REPORTER_ASSERT(reporter, kWidthHeight == surf->width());
24 REPORTER_ASSERT(reporter, kWidthHeight == surf->height());
25
26 SkCanvas* canvas = surf->getCanvas();
27 SK_ALWAYSBREAK(canvas);
28
29 canvas->clear(SK_ColorRED);
30
31 SkAutoTUnref<SkSpecialImage> img(surf->newImageSnapshot());
32 REPORTER_ASSERT(reporter, img);
33
34 REPORTER_ASSERT(reporter, kWidthHeight == img->width());
35 REPORTER_ASSERT(reporter, kWidthHeight == img->height());
36
37 REPORTER_ASSERT(reporter, !surf->getCanvas());
38 }
39
40 DEF_TEST(SpecialSurface_Raster, reporter) {
41
42 SkImageInfo info = SkImageInfo::MakeN32(kWidthHeight, kWidthHeight, kOpaque_ SkAlphaType);
43 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::New(info));
44
45 test_surface(surf, reporter);
46 }
47
48 #if SK_SUPPORT_GPU
49 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu, reporter, context) {
50 GrSurfaceDesc desc;
51 desc.fConfig = kSkia8888_GrPixelConfig;
52 desc.fFlags = kRenderTarget_GrSurfaceFlag;
53 desc.fWidth = kWidthHeight;
54 desc.fHeight = kWidthHeight;
55
56 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::New(context, desc));
57
58 test_surface(surf, reporter);
59 }
60
61 #endif
OLDNEW
« 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