junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | */ |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 7 | |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 8 | #include "SkCanvas.h" |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 9 | #include "SkData.h" |
| 10 | #include "SkImageEncoder.h" |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 11 | #include "SkRRect.h" |
| 12 | #include "SkSurface.h" |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 13 | #include "SkUtils.h" |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 14 | #include "Test.h" |
| 15 | |
| 16 | #if SK_SUPPORT_GPU |
| 17 | #include "GrContextFactory.h" |
| 18 | #else |
| 19 | class GrContextFactory; |
| 20 | class GrContext; |
| 21 | #endif |
| 22 | |
| 23 | enum SurfaceType { |
| 24 | kRaster_SurfaceType, |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 25 | kRasterDirect_SurfaceType, |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 26 | kGpu_SurfaceType, |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 27 | kGpuScratch_SurfaceType, |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
reed | 982542d | 2014-06-27 06:48:14 -0700 | [diff] [blame] | 30 | static void release_storage(void* pixels, void* context) { |
| 31 | SkASSERT(pixels == context); |
| 32 | sk_free(pixels); |
| 33 | } |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 34 | |
| 35 | static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context, |
| 36 | SkImageInfo* requestedInfo = NULL) { |
reed | 982542d | 2014-06-27 06:48:14 -0700 | [diff] [blame] | 37 | static const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 38 | |
| 39 | if (requestedInfo) { |
| 40 | *requestedInfo = info; |
| 41 | } |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 42 | |
| 43 | switch (surfaceType) { |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 44 | case kRaster_SurfaceType: |
| 45 | return SkSurface::NewRaster(info); |
reed | 982542d | 2014-06-27 06:48:14 -0700 | [diff] [blame] | 46 | case kRasterDirect_SurfaceType: { |
| 47 | const size_t rowBytes = info.minRowBytes(); |
| 48 | void* storage = sk_malloc_throw(info.getSafeSize(rowBytes)); |
| 49 | return SkSurface::NewRasterDirectReleaseProc(info, storage, rowBytes, |
| 50 | release_storage, storage); |
| 51 | } |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 52 | case kGpu_SurfaceType: |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 53 | return SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0, NULL); |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 54 | case kGpuScratch_SurfaceType: |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 55 | return SkSurface::NewRenderTarget(context, SkSurface::kYes_Budgeted, info, 0, NULL); |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 56 | } |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 57 | return NULL; |
| 58 | } |
| 59 | |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 60 | enum ImageType { |
| 61 | kRasterCopy_ImageType, |
| 62 | kRasterData_ImageType, |
| 63 | kGpu_ImageType, |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 64 | kCodec_ImageType, |
| 65 | }; |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 66 | |
reed | b2497c2 | 2014-12-31 12:31:43 -0800 | [diff] [blame] | 67 | #include "SkImageGenerator.h" |
| 68 | |
| 69 | class EmptyGenerator : public SkImageGenerator { |
reed | 3ef71e3 | 2015-03-19 08:31:14 -0700 | [diff] [blame^] | 70 | public: |
| 71 | EmptyGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(0, 0)) {} |
reed | b2497c2 | 2014-12-31 12:31:43 -0800 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | static void test_empty_image(skiatest::Reporter* reporter) { |
| 75 | const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType); |
| 76 | |
| 77 | REPORTER_ASSERT(reporter, NULL == SkImage::NewRasterCopy(info, NULL, 0)); |
| 78 | REPORTER_ASSERT(reporter, NULL == SkImage::NewRasterData(info, NULL, 0)); |
| 79 | REPORTER_ASSERT(reporter, NULL == SkImage::NewFromGenerator(SkNEW(EmptyGenerator))); |
| 80 | } |
| 81 | |
| 82 | static void test_empty_surface(skiatest::Reporter* reporter, GrContext* ctx) { |
| 83 | const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType); |
| 84 | |
| 85 | REPORTER_ASSERT(reporter, NULL == SkSurface::NewRaster(info)); |
| 86 | REPORTER_ASSERT(reporter, NULL == SkSurface::NewRasterDirect(info, NULL, 0)); |
| 87 | if (ctx) { |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 88 | REPORTER_ASSERT(reporter, NULL == |
| 89 | SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, NULL)); |
reed | b2497c2 | 2014-12-31 12:31:43 -0800 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 93 | static void test_image(skiatest::Reporter* reporter) { |
| 94 | SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); |
| 95 | size_t rowBytes = info.minRowBytes(); |
| 96 | size_t size = info.getSafeSize(rowBytes); |
reed | 9594da1 | 2014-09-12 12:12:27 -0700 | [diff] [blame] | 97 | SkData* data = SkData::NewUninitialized(size); |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 98 | |
mtklein | bbb61d7 | 2014-11-24 13:09:39 -0800 | [diff] [blame] | 99 | REPORTER_ASSERT(reporter, data->unique()); |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 100 | SkImage* image = SkImage::NewRasterData(info, data, rowBytes); |
mtklein | bbb61d7 | 2014-11-24 13:09:39 -0800 | [diff] [blame] | 101 | REPORTER_ASSERT(reporter, !data->unique()); |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 102 | image->unref(); |
mtklein | bbb61d7 | 2014-11-24 13:09:39 -0800 | [diff] [blame] | 103 | REPORTER_ASSERT(reporter, data->unique()); |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 104 | data->unref(); |
| 105 | } |
| 106 | |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 107 | static SkImage* createImage(ImageType imageType, GrContext* context, SkColor color) { |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 108 | const SkPMColor pmcolor = SkPreMultiplyColor(color); |
| 109 | const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
| 110 | const size_t rowBytes = info.minRowBytes(); |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 111 | const size_t size = rowBytes * info.height(); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 112 | |
reed | 9594da1 | 2014-09-12 12:12:27 -0700 | [diff] [blame] | 113 | SkAutoTUnref<SkData> data(SkData::NewUninitialized(size)); |
| 114 | void* addr = data->writable_data(); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 115 | sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2)); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 116 | |
| 117 | switch (imageType) { |
| 118 | case kRasterCopy_ImageType: |
| 119 | return SkImage::NewRasterCopy(info, addr, rowBytes); |
| 120 | case kRasterData_ImageType: |
| 121 | return SkImage::NewRasterData(info, data, rowBytes); |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 122 | case kGpu_ImageType: { |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 123 | SkAutoTUnref<SkSurface> surf( |
| 124 | SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info, 0)); |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 125 | surf->getCanvas()->clear(color); |
| 126 | return surf->newImageSnapshot(); |
| 127 | } |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 128 | case kCodec_ImageType: { |
| 129 | SkBitmap bitmap; |
commit-bot@chromium.org | 00f8d6c | 2014-05-29 15:57:20 +0000 | [diff] [blame] | 130 | bitmap.installPixels(info, addr, rowBytes); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 131 | SkAutoTUnref<SkData> src( |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 132 | SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100)); |
reed | 5965c8a | 2015-01-07 18:04:45 -0800 | [diff] [blame] | 133 | return SkImage::NewFromData(src); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | SkASSERT(false); |
| 137 | return NULL; |
| 138 | } |
| 139 | |
reed | 96472de | 2014-12-10 09:53:42 -0800 | [diff] [blame] | 140 | static void set_pixels(SkPMColor pixels[], int count, SkPMColor color) { |
| 141 | sk_memset32(pixels, color, count); |
| 142 | } |
| 143 | static bool has_pixels(const SkPMColor pixels[], int count, SkPMColor expected) { |
| 144 | for (int i = 0; i < count; ++i) { |
| 145 | if (pixels[i] != expected) { |
| 146 | return false; |
| 147 | } |
| 148 | } |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | static void test_image_readpixels(skiatest::Reporter* reporter, SkImage* image, |
| 153 | SkPMColor expected) { |
| 154 | const SkPMColor notExpected = ~expected; |
| 155 | |
| 156 | const int w = 2, h = 2; |
| 157 | const size_t rowBytes = w * sizeof(SkPMColor); |
| 158 | SkPMColor pixels[w*h]; |
| 159 | |
| 160 | SkImageInfo info; |
| 161 | |
| 162 | info = SkImageInfo::MakeUnknown(w, h); |
| 163 | REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, 0)); |
| 164 | |
| 165 | // out-of-bounds should fail |
| 166 | info = SkImageInfo::MakeN32Premul(w, h); |
| 167 | REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, -w, 0)); |
| 168 | REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, -h)); |
| 169 | REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, image->width(), 0)); |
| 170 | REPORTER_ASSERT(reporter, !image->readPixels(info, pixels, rowBytes, 0, image->height())); |
| 171 | |
| 172 | // top-left should succeed |
| 173 | set_pixels(pixels, w*h, notExpected); |
| 174 | REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, 0, 0)); |
| 175 | REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected)); |
| 176 | |
| 177 | // bottom-right should succeed |
| 178 | set_pixels(pixels, w*h, notExpected); |
| 179 | REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, |
| 180 | image->width() - w, image->height() - h)); |
| 181 | REPORTER_ASSERT(reporter, has_pixels(pixels, w*h, expected)); |
| 182 | |
| 183 | // partial top-left should succeed |
| 184 | set_pixels(pixels, w*h, notExpected); |
| 185 | REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, -1, -1)); |
| 186 | REPORTER_ASSERT(reporter, pixels[3] == expected); |
| 187 | REPORTER_ASSERT(reporter, has_pixels(pixels, w*h - 1, notExpected)); |
| 188 | |
| 189 | // partial bottom-right should succeed |
| 190 | set_pixels(pixels, w*h, notExpected); |
| 191 | REPORTER_ASSERT(reporter, image->readPixels(info, pixels, rowBytes, |
| 192 | image->width() - 1, image->height() - 1)); |
| 193 | REPORTER_ASSERT(reporter, pixels[0] == expected); |
| 194 | REPORTER_ASSERT(reporter, has_pixels(&pixels[1], w*h - 1, notExpected)); |
| 195 | } |
| 196 | |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 197 | static void test_imagepeek(skiatest::Reporter* reporter, GrContextFactory* factory) { |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 198 | static const struct { |
| 199 | ImageType fType; |
| 200 | bool fPeekShouldSucceed; |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 201 | const char* fName; |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 202 | } gRec[] = { |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 203 | { kRasterCopy_ImageType, true, "RasterCopy" }, |
| 204 | { kRasterData_ImageType, true, "RasterData" }, |
| 205 | { kGpu_ImageType, false, "Gpu" }, |
| 206 | { kCodec_ImageType, false, "Codec" }, |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 207 | }; |
skia.committer@gmail.com | 02d6f54 | 2014-02-14 03:02:05 +0000 | [diff] [blame] | 208 | |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 209 | const SkColor color = SK_ColorRED; |
| 210 | const SkPMColor pmcolor = SkPreMultiplyColor(color); |
skia.committer@gmail.com | 02d6f54 | 2014-02-14 03:02:05 +0000 | [diff] [blame] | 211 | |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 212 | GrContext* ctx = NULL; |
| 213 | #if SK_SUPPORT_GPU |
| 214 | ctx = factory->get(GrContextFactory::kNative_GLContextType); |
| 215 | #endif |
| 216 | |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 217 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 218 | SkImageInfo info; |
| 219 | size_t rowBytes; |
skia.committer@gmail.com | 02d6f54 | 2014-02-14 03:02:05 +0000 | [diff] [blame] | 220 | |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 221 | SkAutoTUnref<SkImage> image(createImage(gRec[i].fType, ctx, color)); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 222 | if (!image.get()) { |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 223 | SkDebugf("failed to createImage[%d] %s\n", i, gRec[i].fName); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 224 | continue; // gpu may not be enabled |
| 225 | } |
| 226 | const void* addr = image->peekPixels(&info, &rowBytes); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 227 | bool success = SkToBool(addr); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 228 | REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success); |
| 229 | if (success) { |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 230 | REPORTER_ASSERT(reporter, 10 == info.width()); |
| 231 | REPORTER_ASSERT(reporter, 10 == info.height()); |
| 232 | REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType()); |
| 233 | REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() || |
| 234 | kOpaque_SkAlphaType == info.alphaType()); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 235 | REPORTER_ASSERT(reporter, info.minRowBytes() <= rowBytes); |
| 236 | REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr); |
| 237 | } |
reed | 96472de | 2014-12-10 09:53:42 -0800 | [diff] [blame] | 238 | |
| 239 | test_image_readpixels(reporter, image, pmcolor); |
reed@google.com | 4f7c615 | 2014-02-06 14:11:56 +0000 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 243 | static void test_canvaspeek(skiatest::Reporter* reporter, |
| 244 | GrContextFactory* factory) { |
| 245 | static const struct { |
| 246 | SurfaceType fType; |
| 247 | bool fPeekShouldSucceed; |
| 248 | } gRec[] = { |
| 249 | { kRaster_SurfaceType, true }, |
| 250 | { kRasterDirect_SurfaceType, true }, |
| 251 | #if SK_SUPPORT_GPU |
| 252 | { kGpu_SurfaceType, false }, |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 253 | { kGpuScratch_SurfaceType, false }, |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 254 | #endif |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 255 | }; |
| 256 | |
| 257 | const SkColor color = SK_ColorRED; |
| 258 | const SkPMColor pmcolor = SkPreMultiplyColor(color); |
| 259 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 260 | int cnt; |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 261 | #if SK_SUPPORT_GPU |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 262 | cnt = GrContextFactory::kGLContextTypeCnt; |
| 263 | #else |
| 264 | cnt = 1; |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 265 | #endif |
| 266 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 267 | for (int i= 0; i < cnt; ++i) { |
| 268 | GrContext* context = NULL; |
| 269 | #if SK_SUPPORT_GPU |
| 270 | GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i; |
| 271 | if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
| 272 | continue; |
| 273 | } |
| 274 | context = factory->get(glCtxType); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 275 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 276 | if (NULL == context) { |
| 277 | continue; |
| 278 | } |
| 279 | #endif |
| 280 | for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 281 | SkImageInfo info, requestInfo; |
| 282 | size_t rowBytes; |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 283 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 284 | SkAutoTUnref<SkSurface> surface(createSurface(gRec[i].fType, context, |
| 285 | &requestInfo)); |
| 286 | surface->getCanvas()->clear(color); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 287 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 288 | const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 289 | bool success = SkToBool(addr); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 290 | REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 291 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 292 | SkImageInfo info2; |
| 293 | size_t rb2; |
| 294 | const void* addr2 = surface->peekPixels(&info2, &rb2); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 295 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 296 | if (success) { |
| 297 | REPORTER_ASSERT(reporter, requestInfo == info); |
| 298 | REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= rowBytes); |
| 299 | REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr); |
| 300 | |
| 301 | REPORTER_ASSERT(reporter, addr2 == addr); |
| 302 | REPORTER_ASSERT(reporter, info2 == info); |
| 303 | REPORTER_ASSERT(reporter, rb2 == rowBytes); |
| 304 | } else { |
| 305 | REPORTER_ASSERT(reporter, NULL == addr2); |
| 306 | } |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 311 | static void TestSurfaceCopyOnWrite(skiatest::Reporter* reporter, SurfaceType surfaceType, |
| 312 | GrContext* context) { |
| 313 | // Verify that the right canvas commands trigger a copy on write |
| 314 | SkSurface* surface = createSurface(surfaceType, context); |
| 315 | SkAutoTUnref<SkSurface> aur_surface(surface); |
| 316 | SkCanvas* canvas = surface->getCanvas(); |
| 317 | |
| 318 | const SkRect testRect = |
| 319 | SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 320 | SkIntToScalar(4), SkIntToScalar(5)); |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 321 | SkPath testPath; |
| 322 | testPath.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 323 | SkIntToScalar(2), SkIntToScalar(1))); |
| 324 | |
| 325 | const SkIRect testIRect = SkIRect::MakeXYWH(0, 0, 2, 1); |
| 326 | |
| 327 | SkRegion testRegion; |
| 328 | testRegion.setRect(testIRect); |
| 329 | |
| 330 | |
| 331 | const SkColor testColor = 0x01020304; |
| 332 | const SkPaint testPaint; |
| 333 | const SkPoint testPoints[3] = { |
| 334 | {SkIntToScalar(0), SkIntToScalar(0)}, |
| 335 | {SkIntToScalar(2), SkIntToScalar(1)}, |
| 336 | {SkIntToScalar(0), SkIntToScalar(2)} |
| 337 | }; |
| 338 | const size_t testPointCount = 3; |
| 339 | |
| 340 | SkBitmap testBitmap; |
mike@reedtribe.org | deee496 | 2014-02-13 14:41:43 +0000 | [diff] [blame] | 341 | testBitmap.allocN32Pixels(10, 10); |
robertphillips@google.com | d1ce77d | 2013-10-09 12:51:09 +0000 | [diff] [blame] | 342 | testBitmap.eraseColor(0); |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 343 | |
| 344 | SkRRect testRRect; |
| 345 | testRRect.setRectXY(testRect, SK_Scalar1, SK_Scalar1); |
| 346 | |
| 347 | SkString testText("Hello World"); |
| 348 | const SkPoint testPoints2[] = { |
| 349 | { SkIntToScalar(0), SkIntToScalar(1) }, |
| 350 | { SkIntToScalar(1), SkIntToScalar(1) }, |
| 351 | { SkIntToScalar(2), SkIntToScalar(1) }, |
| 352 | { SkIntToScalar(3), SkIntToScalar(1) }, |
| 353 | { SkIntToScalar(4), SkIntToScalar(1) }, |
| 354 | { SkIntToScalar(5), SkIntToScalar(1) }, |
| 355 | { SkIntToScalar(6), SkIntToScalar(1) }, |
| 356 | { SkIntToScalar(7), SkIntToScalar(1) }, |
| 357 | { SkIntToScalar(8), SkIntToScalar(1) }, |
| 358 | { SkIntToScalar(9), SkIntToScalar(1) }, |
| 359 | { SkIntToScalar(10), SkIntToScalar(1) }, |
| 360 | }; |
| 361 | |
| 362 | #define EXPECT_COPY_ON_WRITE(command) \ |
| 363 | { \ |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 364 | SkImage* imageBefore = surface->newImageSnapshot(); \ |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 365 | SkAutoTUnref<SkImage> aur_before(imageBefore); \ |
| 366 | canvas-> command ; \ |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 367 | SkImage* imageAfter = surface->newImageSnapshot(); \ |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 368 | SkAutoTUnref<SkImage> aur_after(imageAfter); \ |
| 369 | REPORTER_ASSERT(reporter, imageBefore != imageAfter); \ |
| 370 | } |
| 371 | |
| 372 | EXPECT_COPY_ON_WRITE(clear(testColor)) |
| 373 | EXPECT_COPY_ON_WRITE(drawPaint(testPaint)) |
| 374 | EXPECT_COPY_ON_WRITE(drawPoints(SkCanvas::kPoints_PointMode, testPointCount, testPoints, \ |
| 375 | testPaint)) |
| 376 | EXPECT_COPY_ON_WRITE(drawOval(testRect, testPaint)) |
| 377 | EXPECT_COPY_ON_WRITE(drawRect(testRect, testPaint)) |
| 378 | EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint)) |
| 379 | EXPECT_COPY_ON_WRITE(drawPath(testPath, testPaint)) |
| 380 | EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0)) |
| 381 | EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, NULL, testRect)) |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 382 | EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, NULL)) |
| 383 | EXPECT_COPY_ON_WRITE(drawSprite(testBitmap, 0, 0, NULL)) |
| 384 | EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testPaint)) |
| 385 | EXPECT_COPY_ON_WRITE(drawPosText(testText.c_str(), testText.size(), testPoints2, \ |
| 386 | testPaint)) |
| 387 | EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testPath, NULL, \ |
| 388 | testPaint)) |
| 389 | } |
| 390 | |
junov@chromium.org | af05835 | 2013-04-03 15:03:26 +0000 | [diff] [blame] | 391 | static void TestSurfaceWritableAfterSnapshotRelease(skiatest::Reporter* reporter, |
| 392 | SurfaceType surfaceType, |
| 393 | GrContext* context) { |
| 394 | // This test succeeds by not triggering an assertion. |
| 395 | // The test verifies that the surface remains writable (usable) after |
| 396 | // acquiring and releasing a snapshot without triggering a copy on write. |
commit-bot@chromium.org | 4d24b74 | 2013-07-25 23:29:40 +0000 | [diff] [blame] | 397 | SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); |
junov@chromium.org | af05835 | 2013-04-03 15:03:26 +0000 | [diff] [blame] | 398 | SkCanvas* canvas = surface->getCanvas(); |
| 399 | canvas->clear(1); |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 400 | surface->newImageSnapshot()->unref(); // Create and destroy SkImage |
commit-bot@chromium.org | 4d24b74 | 2013-07-25 23:29:40 +0000 | [diff] [blame] | 401 | canvas->clear(2); // Must not assert internally |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 402 | } |
junov@chromium.org | da90474 | 2013-05-01 22:38:16 +0000 | [diff] [blame] | 403 | |
junov@chromium.org | b516a41 | 2013-05-01 22:49:59 +0000 | [diff] [blame] | 404 | #if SK_SUPPORT_GPU |
commit-bot@chromium.org | 4d24b74 | 2013-07-25 23:29:40 +0000 | [diff] [blame] | 405 | static void Test_crbug263329(skiatest::Reporter* reporter, |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 406 | SurfaceType surfaceType, |
commit-bot@chromium.org | 4d24b74 | 2013-07-25 23:29:40 +0000 | [diff] [blame] | 407 | GrContext* context) { |
| 408 | // This is a regression test for crbug.com/263329 |
| 409 | // Bug was caused by onCopyOnWrite releasing the old surface texture |
| 410 | // back to the scratch texture pool even though the texture is used |
| 411 | // by and active SkImage_Gpu. |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 412 | SkAutoTUnref<SkSurface> surface1(createSurface(surfaceType, context)); |
| 413 | SkAutoTUnref<SkSurface> surface2(createSurface(surfaceType, context)); |
commit-bot@chromium.org | 4d24b74 | 2013-07-25 23:29:40 +0000 | [diff] [blame] | 414 | SkCanvas* canvas1 = surface1->getCanvas(); |
| 415 | SkCanvas* canvas2 = surface2->getCanvas(); |
| 416 | canvas1->clear(1); |
| 417 | SkAutoTUnref<SkImage> image1(surface1->newImageSnapshot()); |
| 418 | // Trigger copy on write, new backing is a scratch texture |
| 419 | canvas1->clear(2); |
| 420 | SkAutoTUnref<SkImage> image2(surface1->newImageSnapshot()); |
| 421 | // Trigger copy on write, old backing should not be returned to scratch |
| 422 | // pool because it is held by image2 |
| 423 | canvas1->clear(3); |
| 424 | |
| 425 | canvas2->clear(4); |
| 426 | SkAutoTUnref<SkImage> image3(surface2->newImageSnapshot()); |
| 427 | // Trigger copy on write on surface2. The new backing store should not |
| 428 | // be recycling a texture that is held by an existing image. |
| 429 | canvas2->clear(5); |
| 430 | SkAutoTUnref<SkImage> image4(surface2->newImageSnapshot()); |
| 431 | REPORTER_ASSERT(reporter, image4->getTexture() != image3->getTexture()); |
| 432 | // The following assertion checks crbug.com/263329 |
| 433 | REPORTER_ASSERT(reporter, image4->getTexture() != image2->getTexture()); |
| 434 | REPORTER_ASSERT(reporter, image4->getTexture() != image1->getTexture()); |
| 435 | REPORTER_ASSERT(reporter, image3->getTexture() != image2->getTexture()); |
| 436 | REPORTER_ASSERT(reporter, image3->getTexture() != image1->getTexture()); |
| 437 | REPORTER_ASSERT(reporter, image2->getTexture() != image1->getTexture()); |
| 438 | } |
| 439 | |
junov@chromium.org | da90474 | 2013-05-01 22:38:16 +0000 | [diff] [blame] | 440 | static void TestGetTexture(skiatest::Reporter* reporter, |
| 441 | SurfaceType surfaceType, |
| 442 | GrContext* context) { |
| 443 | SkAutoTUnref<SkSurface> surface(createSurface(surfaceType, context)); |
| 444 | SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
| 445 | GrTexture* texture = image->getTexture(); |
commit-bot@chromium.org | d8a57af | 2014-03-19 21:19:16 +0000 | [diff] [blame] | 446 | if (surfaceType == kGpu_SurfaceType || surfaceType == kGpuScratch_SurfaceType) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 447 | REPORTER_ASSERT(reporter, texture); |
junov@chromium.org | da90474 | 2013-05-01 22:38:16 +0000 | [diff] [blame] | 448 | REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle()); |
| 449 | } else { |
| 450 | REPORTER_ASSERT(reporter, NULL == texture); |
| 451 | } |
| 452 | surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode); |
| 453 | REPORTER_ASSERT(reporter, image->getTexture() == texture); |
| 454 | } |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 455 | |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 456 | #include "GrGpuResourcePriv.h" |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 457 | #include "SkGpuDevice.h" |
| 458 | #include "SkImage_Gpu.h" |
| 459 | #include "SkSurface_Gpu.h" |
| 460 | |
| 461 | SkSurface::Budgeted is_budgeted(SkSurface* surf) { |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 462 | return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted() ? |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 463 | SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted; |
| 464 | } |
| 465 | |
| 466 | SkSurface::Budgeted is_budgeted(SkImage* image) { |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 467 | return ((SkImage_Gpu*)image)->getTexture()->resourcePriv().isBudgeted() ? |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 468 | SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted; |
| 469 | } |
| 470 | |
| 471 | static void test_surface_budget(skiatest::Reporter* reporter, GrContext* context) { |
| 472 | SkImageInfo info = SkImageInfo::MakeN32Premul(8,8); |
| 473 | for (int i = 0; i < 2; ++i) { |
| 474 | SkSurface::Budgeted sbudgeted = i ? SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted; |
| 475 | for (int j = 0; j < 2; ++j) { |
| 476 | SkSurface::Budgeted ibudgeted = j ? SkSurface::kYes_Budgeted : SkSurface::kNo_Budgeted; |
| 477 | SkAutoTUnref<SkSurface> |
| 478 | surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0)); |
| 479 | SkASSERT(surface); |
| 480 | REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 481 | |
mtklein | 31ff298 | 2015-01-24 11:27:27 -0800 | [diff] [blame] | 482 | SkAutoTUnref<SkImage> image(surface->newImageSnapshot(ibudgeted)); |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 483 | |
| 484 | // Initially the image shares a texture with the surface, and the surface decides |
| 485 | // whether it is budgeted or not. |
| 486 | REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 487 | REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image)); |
| 488 | |
| 489 | // Now trigger copy-on-write |
| 490 | surface->getCanvas()->clear(SK_ColorBLUE); |
| 491 | |
| 492 | // They don't share a texture anymore. They should each have made their own budget |
| 493 | // decision. |
| 494 | REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface)); |
| 495 | REPORTER_ASSERT(reporter, ibudgeted == is_budgeted(image)); |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
junov@chromium.org | b516a41 | 2013-05-01 22:49:59 +0000 | [diff] [blame] | 500 | #endif |
junov@chromium.org | da90474 | 2013-05-01 22:38:16 +0000 | [diff] [blame] | 501 | |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 502 | static void TestSurfaceNoCanvas(skiatest::Reporter* reporter, |
| 503 | SurfaceType surfaceType, |
commit-bot@chromium.org | c4c9870 | 2013-04-22 14:28:01 +0000 | [diff] [blame] | 504 | GrContext* context, |
| 505 | SkSurface::ContentChangeMode mode) { |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 506 | // Verifies the robustness of SkSurface for handling use cases where calls |
| 507 | // are made before a canvas is created. |
| 508 | { |
| 509 | // Test passes by not asserting |
| 510 | SkSurface* surface = createSurface(surfaceType, context); |
| 511 | SkAutoTUnref<SkSurface> aur_surface(surface); |
commit-bot@chromium.org | c4c9870 | 2013-04-22 14:28:01 +0000 | [diff] [blame] | 512 | surface->notifyContentWillChange(mode); |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 513 | SkDEBUGCODE(surface->validate();) |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 514 | } |
| 515 | { |
| 516 | SkSurface* surface = createSurface(surfaceType, context); |
| 517 | SkAutoTUnref<SkSurface> aur_surface(surface); |
| 518 | SkImage* image1 = surface->newImageSnapshot(); |
| 519 | SkAutoTUnref<SkImage> aur_image1(image1); |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 520 | SkDEBUGCODE(image1->validate();) |
| 521 | SkDEBUGCODE(surface->validate();) |
commit-bot@chromium.org | c4c9870 | 2013-04-22 14:28:01 +0000 | [diff] [blame] | 522 | surface->notifyContentWillChange(mode); |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 523 | SkDEBUGCODE(image1->validate();) |
| 524 | SkDEBUGCODE(surface->validate();) |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 525 | SkImage* image2 = surface->newImageSnapshot(); |
| 526 | SkAutoTUnref<SkImage> aur_image2(image2); |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 527 | SkDEBUGCODE(image2->validate();) |
| 528 | SkDEBUGCODE(surface->validate();) |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 529 | REPORTER_ASSERT(reporter, image1 != image2); |
| 530 | } |
skia.committer@gmail.com | 45fb8b6 | 2013-04-17 07:00:56 +0000 | [diff] [blame] | 531 | |
junov@chromium.org | acea3ef | 2013-04-16 19:41:09 +0000 | [diff] [blame] | 532 | } |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 533 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 534 | DEF_GPUTEST(Surface, reporter, factory) { |
reed@google.com | 999da9c | 2014-02-06 13:43:07 +0000 | [diff] [blame] | 535 | test_image(reporter); |
| 536 | |
junov@chromium.org | af05835 | 2013-04-03 15:03:26 +0000 | [diff] [blame] | 537 | TestSurfaceCopyOnWrite(reporter, kRaster_SurfaceType, NULL); |
junov@chromium.org | af05835 | 2013-04-03 15:03:26 +0000 | [diff] [blame] | 538 | TestSurfaceWritableAfterSnapshotRelease(reporter, kRaster_SurfaceType, NULL); |
commit-bot@chromium.org | c4c9870 | 2013-04-22 14:28:01 +0000 | [diff] [blame] | 539 | TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kDiscard_ContentChangeMode); |
| 540 | TestSurfaceNoCanvas(reporter, kRaster_SurfaceType, NULL, SkSurface::kRetain_ContentChangeMode); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 541 | |
reed | b2497c2 | 2014-12-31 12:31:43 -0800 | [diff] [blame] | 542 | test_empty_image(reporter); |
| 543 | test_empty_surface(reporter, NULL); |
| 544 | |
reed | 67f2eb4 | 2014-12-10 06:54:06 -0800 | [diff] [blame] | 545 | test_imagepeek(reporter, factory); |
commit-bot@chromium.org | c3bd8af | 2014-02-13 17:14:46 +0000 | [diff] [blame] | 546 | test_canvaspeek(reporter, factory); |
| 547 | |
junov@chromium.org | b516a41 | 2013-05-01 22:49:59 +0000 | [diff] [blame] | 548 | #if SK_SUPPORT_GPU |
junov@chromium.org | da90474 | 2013-05-01 22:38:16 +0000 | [diff] [blame] | 549 | TestGetTexture(reporter, kRaster_SurfaceType, NULL); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 550 | if (factory) { |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 551 | for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
| 552 | GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i; |
| 553 | if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
| 554 | continue; |
| 555 | } |
| 556 | GrContext* context = factory->get(glCtxType); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 557 | if (context) { |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 558 | Test_crbug263329(reporter, kGpu_SurfaceType, context); |
| 559 | Test_crbug263329(reporter, kGpuScratch_SurfaceType, context); |
| 560 | TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context); |
| 561 | TestSurfaceCopyOnWrite(reporter, kGpuScratch_SurfaceType, context); |
| 562 | TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context); |
| 563 | TestSurfaceWritableAfterSnapshotRelease(reporter, kGpuScratch_SurfaceType, context); |
| 564 | TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode); |
| 565 | TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode); |
| 566 | TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); |
| 567 | TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); |
| 568 | TestGetTexture(reporter, kGpu_SurfaceType, context); |
| 569 | TestGetTexture(reporter, kGpuScratch_SurfaceType, context); |
reed | b2497c2 | 2014-12-31 12:31:43 -0800 | [diff] [blame] | 570 | test_empty_surface(reporter, context); |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 571 | test_surface_budget(reporter, context); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 572 | } |
robertphillips@google.com | 3bddb38 | 2013-11-12 13:51:03 +0000 | [diff] [blame] | 573 | } |
junov@chromium.org | af05835 | 2013-04-03 15:03:26 +0000 | [diff] [blame] | 574 | } |
junov@chromium.org | 995beb6 | 2013-03-28 13:49:22 +0000 | [diff] [blame] | 575 | #endif |
| 576 | } |