OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file | 5 * found in the LICENSE file |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkSpecialImage.h" | 9 #include "SkSpecialImage.h" |
10 #include "SkSpecialSurface.h" | 10 #include "SkSpecialSurface.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const SkIRect imgSubset = TestingSpecialSurfaceAccess::Subset(img); | 52 const SkIRect imgSubset = TestingSpecialSurfaceAccess::Subset(img); |
53 REPORTER_ASSERT(reporter, surfSubset == imgSubset); | 53 REPORTER_ASSERT(reporter, surfSubset == imgSubset); |
54 | 54 |
55 // the canvas was invalidated by the newImageSnapshot call | 55 // the canvas was invalidated by the newImageSnapshot call |
56 REPORTER_ASSERT(reporter, !surf->getCanvas()); | 56 REPORTER_ASSERT(reporter, !surf->getCanvas()); |
57 } | 57 } |
58 | 58 |
59 DEF_TEST(SpecialSurface_Raster, reporter) { | 59 DEF_TEST(SpecialSurface_Raster, reporter) { |
60 | 60 |
61 SkImageInfo info = SkImageInfo::MakeN32(kSmallerSize, kSmallerSize, kOpaque_
SkAlphaType); | 61 SkImageInfo info = SkImageInfo::MakeN32(kSmallerSize, kSmallerSize, kOpaque_
SkAlphaType); |
62 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRaster(info)); | 62 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRaster(nullptr, inf
o)); |
63 | 63 |
64 test_surface(surf, reporter, 0); | 64 test_surface(surf, reporter, 0); |
65 } | 65 } |
66 | 66 |
67 DEF_TEST(SpecialSurface_Raster2, reporter) { | 67 DEF_TEST(SpecialSurface_Raster2, reporter) { |
68 | 68 |
69 SkBitmap bm; | 69 SkBitmap bm; |
70 bm.allocN32Pixels(kFullSize, kFullSize, true); | 70 bm.allocN32Pixels(kFullSize, kFullSize, true); |
71 | 71 |
72 const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerS
ize); | 72 const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerS
ize); |
73 | 73 |
74 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromBitmap(subset,
bm)); | 74 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromBitmap(nullptr,
subset, bm)); |
75 | 75 |
76 test_surface(surf, reporter, kPad); | 76 test_surface(surf, reporter, kPad); |
77 | 77 |
78 // TODO: check that the clear didn't escape the active region | 78 // TODO: check that the clear didn't escape the active region |
79 } | 79 } |
80 | 80 |
81 #if SK_SUPPORT_GPU | 81 #if SK_SUPPORT_GPU |
82 | 82 |
83 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, context) { | 83 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, context) { |
84 GrSurfaceDesc desc; | 84 GrSurfaceDesc desc; |
85 desc.fConfig = kSkia8888_GrPixelConfig; | 85 desc.fConfig = kSkia8888_GrPixelConfig; |
86 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 86 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
87 desc.fWidth = kSmallerSize; | 87 desc.fWidth = kSmallerSize; |
88 desc.fHeight = kSmallerSize; | 88 desc.fHeight = kSmallerSize; |
89 | 89 |
90 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRenderTarget(contex
t, desc)); | 90 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRenderTarget(nullpt
r, context, desc)); |
91 | 91 |
92 test_surface(surf, reporter, 0); | 92 test_surface(surf, reporter, 0); |
93 } | 93 } |
94 | 94 |
95 // test the more flexible factory | 95 // test the more flexible factory |
96 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu2, reporter, context) { | 96 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu2, reporter, context) { |
97 GrSurfaceDesc desc; | 97 GrSurfaceDesc desc; |
98 desc.fConfig = kSkia8888_GrPixelConfig; | 98 desc.fConfig = kSkia8888_GrPixelConfig; |
99 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 99 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
100 desc.fWidth = kFullSize; | 100 desc.fWidth = kFullSize; |
101 desc.fHeight = kFullSize; | 101 desc.fHeight = kFullSize; |
102 | 102 |
103 SkAutoTUnref<GrTexture> temp(context->textureProvider()->createApproxTexture
(desc)); | 103 SkAutoTUnref<GrTexture> temp(context->textureProvider()->createApproxTexture
(desc)); |
104 SkASSERT_RELEASE(temp); | 104 SkASSERT_RELEASE(temp); |
105 | 105 |
106 const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerS
ize); | 106 const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerS
ize); |
107 | 107 |
108 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromTexture(subset,
temp)); | 108 SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromTexture(nullptr
, subset, temp)); |
109 | 109 |
110 test_surface(surf, reporter, kPad); | 110 test_surface(surf, reporter, kPad); |
111 | 111 |
112 // TODO: check that the clear didn't escape the active region | 112 // TODO: check that the clear didn't escape the active region |
113 } | 113 } |
114 | 114 |
115 #endif | 115 #endif |
OLD | NEW |