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