junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | #include "Test.h" |
| 9 | #include "SkBitmap.h" |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 10 | #include "SkBitmapProcShader.h" |
junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 11 | #include "SkDeferredCanvas.h" |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 12 | #include "SkDevice.h" |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 13 | #include "SkGradientShader.h" |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 14 | #include "SkShader.h" |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 15 | #include "SkSurface.h" |
| 16 | #if SK_SUPPORT_GPU |
| 17 | #include "GrContextFactory.h" |
| 18 | #else |
| 19 | class GrContextFactory; |
| 20 | #endif |
junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 21 | |
junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 22 | static const int gWidth = 2; |
| 23 | static const int gHeight = 2; |
| 24 | |
| 25 | static void create(SkBitmap* bm, SkBitmap::Config config, SkColor color) { |
| 26 | bm->setConfig(config, gWidth, gHeight); |
| 27 | bm->allocPixels(); |
| 28 | bm->eraseColor(color); |
| 29 | } |
| 30 | |
| 31 | static void TestDeferredCanvasBitmapAccess(skiatest::Reporter* reporter) { |
| 32 | SkBitmap store; |
| 33 | |
| 34 | create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 35 | SkDevice device(store); |
| 36 | SkDeferredCanvas canvas(&device); |
| 37 | |
| 38 | canvas.clear(0x00000000); |
| 39 | |
| 40 | SkAutoLockPixels alp(store); |
| 41 | REPORTER_ASSERT(reporter, store.getColor(0,0) == 0xFFFFFFFF); //verify that clear was deferred |
| 42 | SkBitmap accessed = canvas.getDevice()->accessBitmap(false); |
| 43 | REPORTER_ASSERT(reporter, store.getColor(0,0) == 0x00000000); //verify that clear was executed |
| 44 | REPORTER_ASSERT(reporter, accessed.pixelRef() == store.pixelRef()); |
| 45 | } |
| 46 | |
| 47 | static void TestDeferredCanvasFlush(skiatest::Reporter* reporter) { |
| 48 | SkBitmap store; |
| 49 | |
| 50 | create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 51 | SkDevice device(store); |
| 52 | SkDeferredCanvas canvas(&device); |
| 53 | |
| 54 | canvas.clear(0x00000000); |
| 55 | |
| 56 | SkAutoLockPixels alp(store); |
| 57 | REPORTER_ASSERT(reporter, store.getColor(0,0) == 0xFFFFFFFF); //verify that clear was deferred |
| 58 | canvas.flush(); |
| 59 | REPORTER_ASSERT(reporter, store.getColor(0,0) == 0x00000000); //verify that clear was executed |
| 60 | } |
| 61 | |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 62 | static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) { |
| 63 | SkBitmap store; |
| 64 | SkRect fullRect; |
| 65 | fullRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(gWidth), |
| 66 | SkIntToScalar(gHeight)); |
| 67 | SkRect partialRect; |
junov@chromium.org | b1e218e | 2012-02-13 22:27:58 +0000 | [diff] [blame] | 68 | partialRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 69 | SkIntToScalar(1), SkIntToScalar(1)); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 70 | create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 71 | SkDevice device(store); |
| 72 | SkDeferredCanvas canvas(&device); |
| 73 | |
| 74 | // verify that frame is intially fresh |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 75 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 76 | // no clearing op since last call to isFreshFrame -> not fresh |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 77 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 78 | |
| 79 | // Verify that clear triggers a fresh frame |
| 80 | canvas.clear(0x00000000); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 81 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 82 | |
| 83 | // Verify that clear with saved state triggers a fresh frame |
| 84 | canvas.save(SkCanvas::kMatrixClip_SaveFlag); |
| 85 | canvas.clear(0x00000000); |
| 86 | canvas.restore(); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 87 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 88 | |
| 89 | // Verify that clear within a layer does NOT trigger a fresh frame |
| 90 | canvas.saveLayer(NULL, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag); |
| 91 | canvas.clear(0x00000000); |
| 92 | canvas.restore(); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 93 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 94 | |
| 95 | // Verify that a clear with clipping triggers a fresh frame |
| 96 | // (clear is not affected by clipping) |
| 97 | canvas.save(SkCanvas::kMatrixClip_SaveFlag); |
| 98 | canvas.clipRect(partialRect, SkRegion::kIntersect_Op, false); |
| 99 | canvas.clear(0x00000000); |
| 100 | canvas.restore(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 101 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 102 | |
| 103 | // Verify that full frame rects with different forms of opaque paint |
| 104 | // trigger frames to be marked as fresh |
| 105 | { |
| 106 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 107 | paint.setStyle(SkPaint::kFill_Style); |
| 108 | paint.setAlpha(255); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 109 | canvas.drawRect(fullRect, paint); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 110 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 111 | } |
skia.committer@gmail.com | 5b6f916 | 2012-10-12 02:01:15 +0000 | [diff] [blame] | 112 | { |
junov@chromium.org | 8cef67a | 2012-10-11 20:19:15 +0000 | [diff] [blame] | 113 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 114 | paint.setStyle(SkPaint::kFill_Style); |
| 115 | paint.setAlpha(255); |
junov@chromium.org | 8cef67a | 2012-10-11 20:19:15 +0000 | [diff] [blame] | 116 | paint.setXfermodeMode(SkXfermode::kSrcIn_Mode); |
| 117 | canvas.drawRect(fullRect, paint); |
| 118 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
| 119 | } |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 120 | { |
| 121 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 122 | paint.setStyle(SkPaint::kFill_Style); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 123 | SkBitmap bmp; |
| 124 | create(&bmp, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 125 | bmp.setIsOpaque(true); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 126 | SkShader* shader = SkShader::CreateBitmapShader(bmp, |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 127 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
| 128 | paint.setShader(shader)->unref(); |
| 129 | canvas.drawRect(fullRect, paint); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 130 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | // Verify that full frame rects with different forms of non-opaque paint |
| 134 | // do not trigger frames to be marked as fresh |
| 135 | { |
| 136 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 137 | paint.setStyle(SkPaint::kFill_Style); |
| 138 | paint.setAlpha(254); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 139 | canvas.drawRect(fullRect, paint); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 140 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 141 | } |
| 142 | { |
| 143 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 144 | paint.setStyle(SkPaint::kFill_Style); |
| 145 | // Defining a cone that partially overlaps the canvas |
| 146 | const SkPoint pt1 = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0)); |
| 147 | const SkScalar r1 = SkIntToScalar(1); |
| 148 | const SkPoint pt2 = SkPoint::Make(SkIntToScalar(10), SkIntToScalar(0)); |
| 149 | const SkScalar r2 = SkIntToScalar(5); |
| 150 | const SkColor colors[2] = {SK_ColorWHITE, SK_ColorWHITE}; |
| 151 | const SkScalar pos[2] = {0, SK_Scalar1}; |
| 152 | SkShader* shader = SkGradientShader::CreateTwoPointConical( |
| 153 | pt1, r1, pt2, r2, colors, pos, 2, SkShader::kClamp_TileMode, NULL); |
| 154 | paint.setShader(shader)->unref(); |
| 155 | canvas.drawRect(fullRect, paint); |
| 156 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
| 157 | } |
| 158 | { |
| 159 | SkPaint paint; |
| 160 | paint.setStyle(SkPaint::kFill_Style); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 161 | SkBitmap bmp; |
| 162 | create(&bmp, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
| 163 | bmp.setIsOpaque(false); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 164 | SkShader* shader = SkShader::CreateBitmapShader(bmp, |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 165 | SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); |
| 166 | paint.setShader(shader)->unref(); |
| 167 | canvas.drawRect(fullRect, paint); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 168 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | // Verify that incomplete coverage does not trigger a fresh frame |
| 172 | { |
| 173 | SkPaint paint; |
| 174 | paint.setStyle(SkPaint::kFill_Style); |
| 175 | paint.setAlpha(255); |
| 176 | canvas.drawRect(partialRect, paint); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 177 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | // Verify that incomplete coverage due to clipping does not trigger a fresh |
| 181 | // frame |
| 182 | { |
| 183 | canvas.save(SkCanvas::kMatrixClip_SaveFlag); |
| 184 | canvas.clipRect(partialRect, SkRegion::kIntersect_Op, false); |
| 185 | SkPaint paint; |
| 186 | paint.setStyle(SkPaint::kFill_Style); |
| 187 | paint.setAlpha(255); |
| 188 | canvas.drawRect(fullRect, paint); |
junov@chromium.org | 41e850f | 2012-12-10 21:24:38 +0000 | [diff] [blame] | 189 | canvas.restore(); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 190 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 191 | } |
junov@chromium.org | 8f0ca06 | 2012-12-13 16:30:39 +0000 | [diff] [blame] | 192 | { |
| 193 | canvas.save(SkCanvas::kMatrixClip_SaveFlag); |
| 194 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 195 | paint.setStyle(SkPaint::kFill_Style); |
| 196 | paint.setAlpha(255); |
junov@chromium.org | 8f0ca06 | 2012-12-13 16:30:39 +0000 | [diff] [blame] | 197 | SkPath path; |
| 198 | path.addCircle(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(2)); |
| 199 | canvas.clipPath(path, SkRegion::kIntersect_Op, false); |
| 200 | canvas.drawRect(fullRect, paint); |
| 201 | canvas.restore(); |
| 202 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
| 203 | } |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 204 | |
| 205 | // Verify that stroked rect does not trigger a fresh frame |
| 206 | { |
| 207 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 208 | paint.setStyle(SkPaint::kStroke_Style); |
| 209 | paint.setAlpha(255); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 210 | canvas.drawRect(fullRect, paint); |
junov@chromium.org | 88e2914 | 2012-08-07 16:48:22 +0000 | [diff] [blame] | 211 | REPORTER_ASSERT(reporter, !canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 212 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 213 | |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 214 | // Verify kSrcMode triggers a fresh frame even with transparent color |
| 215 | { |
| 216 | SkPaint paint; |
commit-bot@chromium.org | 3fbab82 | 2013-03-20 00:49:57 +0000 | [diff] [blame] | 217 | paint.setStyle(SkPaint::kFill_Style); |
| 218 | paint.setAlpha(100); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 219 | paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 220 | canvas.drawRect(fullRect, paint); |
junov@chromium.org | 41e850f | 2012-12-10 21:24:38 +0000 | [diff] [blame] | 221 | REPORTER_ASSERT(reporter, canvas.isFreshFrame()); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
junov@chromium.org | bfeddae | 2012-07-23 13:35:14 +0000 | [diff] [blame] | 225 | class MockDevice : public SkDevice { |
| 226 | public: |
| 227 | MockDevice(const SkBitmap& bm) : SkDevice(bm) { |
| 228 | fDrawBitmapCallCount = 0; |
| 229 | } |
| 230 | virtual void drawBitmap(const SkDraw&, const SkBitmap&, |
| 231 | const SkIRect*, |
| 232 | const SkMatrix&, const SkPaint&) { |
| 233 | fDrawBitmapCallCount++; |
| 234 | } |
| 235 | |
| 236 | int fDrawBitmapCallCount; |
| 237 | }; |
| 238 | |
| 239 | // Verifies that the deferred canvas triggers a flush when its memory |
| 240 | // limit is exceeded |
| 241 | static void TestDeferredCanvasMemoryLimit(skiatest::Reporter* reporter) { |
| 242 | SkBitmap store; |
| 243 | store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 244 | store.allocPixels(); |
| 245 | MockDevice mockDevice(store); |
| 246 | SkDeferredCanvas canvas(&mockDevice); |
| 247 | canvas.setMaxRecordingStorage(160000); |
| 248 | |
| 249 | SkBitmap sourceImage; |
| 250 | // 100 by 100 image, takes 40,000 bytes in memory |
| 251 | sourceImage.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 252 | sourceImage.allocPixels(); |
| 253 | |
junov@chromium.org | b10a6bd | 2012-07-25 17:27:13 +0000 | [diff] [blame] | 254 | for (int i = 0; i < 5; i++) { |
junov@chromium.org | bfeddae | 2012-07-23 13:35:14 +0000 | [diff] [blame] | 255 | sourceImage.notifyPixelsChanged(); // to force re-serialization |
| 256 | canvas.drawBitmap(sourceImage, 0, 0, NULL); |
| 257 | } |
| 258 | |
scroggo@google.com | 15011ee | 2012-07-26 20:03:32 +0000 | [diff] [blame] | 259 | REPORTER_ASSERT(reporter, mockDevice.fDrawBitmapCallCount == 4); |
junov@chromium.org | bfeddae | 2012-07-23 13:35:14 +0000 | [diff] [blame] | 260 | } |
| 261 | |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 262 | class NotificationCounter : public SkDeferredCanvas::NotificationClient { |
| 263 | public: |
| 264 | NotificationCounter() { |
junov@google.com | 52a00ca | 2012-10-01 15:27:14 +0000 | [diff] [blame] | 265 | fPrepareForDrawCount = fStorageAllocatedChangedCount = |
| 266 | fFlushedDrawCommandsCount = fSkippedPendingDrawCommandsCount = 0; |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | virtual void prepareForDraw() SK_OVERRIDE { |
| 270 | fPrepareForDrawCount++; |
| 271 | } |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 272 | virtual void storageAllocatedForRecordingChanged(size_t) SK_OVERRIDE { |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 273 | fStorageAllocatedChangedCount++; |
| 274 | } |
| 275 | virtual void flushedDrawCommands() SK_OVERRIDE { |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 276 | fFlushedDrawCommandsCount++; |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 277 | } |
junov@google.com | 52a00ca | 2012-10-01 15:27:14 +0000 | [diff] [blame] | 278 | virtual void skippedPendingDrawCommands() SK_OVERRIDE { |
| 279 | fSkippedPendingDrawCommandsCount++; |
| 280 | } |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 281 | |
| 282 | int fPrepareForDrawCount; |
| 283 | int fStorageAllocatedChangedCount; |
| 284 | int fFlushedDrawCommandsCount; |
junov@google.com | 52a00ca | 2012-10-01 15:27:14 +0000 | [diff] [blame] | 285 | int fSkippedPendingDrawCommandsCount; |
robertphillips@google.com | 5990397 | 2013-02-07 21:02:23 +0000 | [diff] [blame] | 286 | |
| 287 | private: |
| 288 | typedef SkDeferredCanvas::NotificationClient INHERITED; |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 289 | }; |
| 290 | |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 291 | static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) { |
| 292 | SkBitmap store; |
| 293 | store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 294 | store.allocPixels(); |
| 295 | SkDevice device(store); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 296 | NotificationCounter notificationCounter; |
junov@chromium.org | d433c4e | 2012-08-17 14:50:16 +0000 | [diff] [blame] | 297 | SkDeferredCanvas canvas(&device); |
| 298 | canvas.setNotificationClient(¬ificationCounter); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 299 | |
| 300 | const int imageCount = 2; |
| 301 | SkBitmap sourceImages[imageCount]; |
| 302 | for (int i = 0; i < imageCount; i++) |
| 303 | { |
| 304 | sourceImages[i].setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 305 | sourceImages[i].allocPixels(); |
| 306 | } |
| 307 | |
| 308 | size_t bitmapSize = sourceImages[0].getSize(); |
| 309 | |
| 310 | canvas.drawBitmap(sourceImages[0], 0, 0, NULL); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 311 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fStorageAllocatedChangedCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 312 | // stored bitmap + drawBitmap command |
| 313 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() > bitmapSize); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 314 | |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 315 | // verify that nothing can be freed at this point |
bsalomon@google.com | 100abf4 | 2012-09-05 17:40:04 +0000 | [diff] [blame] | 316 | REPORTER_ASSERT(reporter, 0 == canvas.freeMemoryIfPossible(~0U)); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 317 | |
| 318 | // verify that flush leaves image in cache |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 319 | REPORTER_ASSERT(reporter, 0 == notificationCounter.fFlushedDrawCommandsCount); |
| 320 | REPORTER_ASSERT(reporter, 0 == notificationCounter.fPrepareForDrawCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 321 | canvas.flush(); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 322 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount); |
| 323 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fPrepareForDrawCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 324 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() >= bitmapSize); |
| 325 | |
| 326 | // verify that after a flush, cached image can be freed |
bsalomon@google.com | 100abf4 | 2012-09-05 17:40:04 +0000 | [diff] [blame] | 327 | REPORTER_ASSERT(reporter, canvas.freeMemoryIfPossible(~0U) >= bitmapSize); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 328 | |
| 329 | // Verify that caching works for avoiding multiple copies of the same bitmap |
| 330 | canvas.drawBitmap(sourceImages[0], 0, 0, NULL); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 331 | REPORTER_ASSERT(reporter, 2 == notificationCounter.fStorageAllocatedChangedCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 332 | canvas.drawBitmap(sourceImages[0], 0, 0, NULL); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 333 | REPORTER_ASSERT(reporter, 2 == notificationCounter.fStorageAllocatedChangedCount); |
| 334 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 335 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() < 2 * bitmapSize); |
| 336 | |
| 337 | // Verify partial eviction based on bytesToFree |
| 338 | canvas.drawBitmap(sourceImages[1], 0, 0, NULL); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 339 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 340 | canvas.flush(); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 341 | REPORTER_ASSERT(reporter, 2 == notificationCounter.fFlushedDrawCommandsCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 342 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() > 2 * bitmapSize); |
| 343 | size_t bytesFreed = canvas.freeMemoryIfPossible(1); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 344 | REPORTER_ASSERT(reporter, 2 == notificationCounter.fFlushedDrawCommandsCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 345 | REPORTER_ASSERT(reporter, bytesFreed >= bitmapSize); |
| 346 | REPORTER_ASSERT(reporter, bytesFreed < 2*bitmapSize); |
| 347 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 348 | // Verifiy that partial purge works, image zero is in cache but not reffed by |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 349 | // a pending draw, while image 1 is locked-in. |
bsalomon@google.com | 100abf4 | 2012-09-05 17:40:04 +0000 | [diff] [blame] | 350 | canvas.freeMemoryIfPossible(~0U); |
junov@chromium.org | 9ed02b9 | 2012-08-14 13:36:26 +0000 | [diff] [blame] | 351 | REPORTER_ASSERT(reporter, 2 == notificationCounter.fFlushedDrawCommandsCount); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 352 | canvas.drawBitmap(sourceImages[0], 0, 0, NULL); |
| 353 | canvas.flush(); |
| 354 | canvas.drawBitmap(sourceImages[1], 0, 0, NULL); |
bsalomon@google.com | 100abf4 | 2012-09-05 17:40:04 +0000 | [diff] [blame] | 355 | bytesFreed = canvas.freeMemoryIfPossible(~0U); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 356 | // only one bitmap should have been freed. |
| 357 | REPORTER_ASSERT(reporter, bytesFreed >= bitmapSize); |
| 358 | REPORTER_ASSERT(reporter, bytesFreed < 2*bitmapSize); |
| 359 | // Clear for next test |
| 360 | canvas.flush(); |
bsalomon@google.com | 100abf4 | 2012-09-05 17:40:04 +0000 | [diff] [blame] | 361 | canvas.freeMemoryIfPossible(~0U); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 362 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() < bitmapSize); |
| 363 | |
| 364 | // Verify the image cache is sensitive to genID bumps |
| 365 | canvas.drawBitmap(sourceImages[1], 0, 0, NULL); |
| 366 | sourceImages[1].notifyPixelsChanged(); |
| 367 | canvas.drawBitmap(sourceImages[1], 0, 0, NULL); |
| 368 | REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() > 2*bitmapSize); |
junov@google.com | 52a00ca | 2012-10-01 15:27:14 +0000 | [diff] [blame] | 369 | |
| 370 | // Verify that nothing in this test caused commands to be skipped |
| 371 | REPORTER_ASSERT(reporter, 0 == notificationCounter.fSkippedPendingDrawCommandsCount); |
| 372 | } |
| 373 | |
| 374 | static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) { |
| 375 | SkBitmap store; |
| 376 | store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 377 | store.allocPixels(); |
| 378 | SkDevice device(store); |
| 379 | NotificationCounter notificationCounter; |
| 380 | SkDeferredCanvas canvas(&device); |
| 381 | canvas.setNotificationClient(¬ificationCounter); |
| 382 | canvas.clear(0x0); |
| 383 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawCommandsCount); |
| 384 | REPORTER_ASSERT(reporter, 0 == notificationCounter.fFlushedDrawCommandsCount); |
| 385 | canvas.flush(); |
| 386 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawCommandsCount); |
| 387 | REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount); |
| 388 | |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 389 | } |
junov@chromium.org | bfeddae | 2012-07-23 13:35:14 +0000 | [diff] [blame] | 390 | |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 391 | static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) { |
| 392 | // This is a regression test for crbug.com/155875 |
| 393 | // This test covers a code path that inserts bitmaps into the bitmap heap through the |
| 394 | // flattening of SkBitmapProcShaders. The refcount in the bitmap heap is maintained through |
| 395 | // the flattening and unflattening of the shader. |
| 396 | SkBitmap store; |
| 397 | store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 398 | store.allocPixels(); |
| 399 | SkDevice device(store); |
| 400 | SkDeferredCanvas canvas(&device); |
| 401 | // test will fail if nbIterations is not in sync with |
| 402 | // BITMAPS_TO_KEEP in SkGPipeWrite.cpp |
| 403 | const int nbIterations = 5; |
| 404 | size_t bytesAllocated = 0; |
| 405 | for(int pass = 0; pass < 2; ++pass) { |
| 406 | for(int i = 0; i < nbIterations; ++i) { |
| 407 | SkPaint paint; |
| 408 | SkBitmap paintPattern; |
| 409 | paintPattern.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); |
| 410 | paintPattern.allocPixels(); |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 411 | paint.setShader(SkNEW_ARGS(SkBitmapProcShader, |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 412 | (paintPattern, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)))->unref(); |
| 413 | canvas.drawPaint(paint); |
| 414 | canvas.flush(); |
| 415 | |
| 416 | // In the first pass, memory allocation should be monotonically increasing as |
| 417 | // the bitmap heap slots fill up. In the second pass memory allocation should be |
| 418 | // stable as bitmap heap slots get recycled. |
| 419 | size_t newBytesAllocated = canvas.storageAllocatedForRecording(); |
| 420 | if (pass == 0) { |
| 421 | REPORTER_ASSERT(reporter, newBytesAllocated > bytesAllocated); |
| 422 | bytesAllocated = newBytesAllocated; |
| 423 | } else { |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 424 | REPORTER_ASSERT(reporter, newBytesAllocated == bytesAllocated); |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | } |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 428 | // All cached resources should be evictable since last canvas call was flush() |
reed@google.com | 2b57dc6 | 2013-01-08 13:23:32 +0000 | [diff] [blame] | 429 | canvas.freeMemoryIfPossible(~0U); |
skia.committer@gmail.com | 989a95e | 2012-10-18 02:01:23 +0000 | [diff] [blame] | 430 | REPORTER_ASSERT(reporter, 0 == canvas.storageAllocatedForRecording()); |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 431 | } |
| 432 | |
sugoi@google.com | 7775fd5 | 2012-11-21 15:47:04 +0000 | [diff] [blame] | 433 | static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter) { |
| 434 | SkBitmap store; |
| 435 | store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 436 | store.allocPixels(); |
skia.committer@gmail.com | 1c9c0d3 | 2012-11-22 02:02:41 +0000 | [diff] [blame] | 437 | |
sugoi@google.com | 7775fd5 | 2012-11-21 15:47:04 +0000 | [diff] [blame] | 438 | SkBitmap sourceImage; |
| 439 | // 100 by 100 image, takes 40,000 bytes in memory |
| 440 | sourceImage.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 441 | sourceImage.allocPixels(); |
| 442 | |
| 443 | // 1 under : should not store the image |
| 444 | { |
| 445 | SkDevice device(store); |
| 446 | SkDeferredCanvas canvas(&device); |
| 447 | canvas.setBitmapSizeThreshold(39999); |
| 448 | canvas.drawBitmap(sourceImage, 0, 0, NULL); |
| 449 | size_t newBytesAllocated = canvas.storageAllocatedForRecording(); |
| 450 | REPORTER_ASSERT(reporter, newBytesAllocated == 0); |
| 451 | } |
| 452 | |
| 453 | // exact value : should store the image |
| 454 | { |
| 455 | SkDevice device(store); |
| 456 | SkDeferredCanvas canvas(&device); |
| 457 | canvas.setBitmapSizeThreshold(40000); |
| 458 | canvas.drawBitmap(sourceImage, 0, 0, NULL); |
| 459 | size_t newBytesAllocated = canvas.storageAllocatedForRecording(); |
| 460 | REPORTER_ASSERT(reporter, newBytesAllocated > 0); |
| 461 | } |
| 462 | |
| 463 | // 1 over : should still store the image |
| 464 | { |
| 465 | SkDevice device(store); |
| 466 | SkDeferredCanvas canvas(&device); |
| 467 | canvas.setBitmapSizeThreshold(40001); |
| 468 | canvas.drawBitmap(sourceImage, 0, 0, NULL); |
| 469 | size_t newBytesAllocated = canvas.storageAllocatedForRecording(); |
| 470 | REPORTER_ASSERT(reporter, newBytesAllocated > 0); |
| 471 | } |
| 472 | } |
| 473 | |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 474 | |
| 475 | typedef void* PixelPtr; |
| 476 | // Returns an opaque pointer which, either points to a GrTexture or RAM pixel |
| 477 | // buffer. Used to test pointer equality do determine whether a surface points |
| 478 | // to the same pixel data storage as before. |
junov@chromium.org | 3c5ec8d | 2013-04-12 13:34:47 +0000 | [diff] [blame] | 479 | static PixelPtr getSurfacePixelPtr(SkSurface* surface, bool useGpu) { |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 480 | return useGpu ? surface->getCanvas()->getDevice()->accessBitmap(false).getTexture() : |
| 481 | surface->getCanvas()->getDevice()->accessBitmap(false).getPixels(); |
| 482 | } |
| 483 | |
| 484 | static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFactory* factory) { |
| 485 | SkImage::Info imageSpec = { |
| 486 | 10, // width |
| 487 | 10, // height |
| 488 | SkImage::kPMColor_ColorType, |
| 489 | SkImage::kPremul_AlphaType |
| 490 | }; |
| 491 | SkSurface* surface; |
| 492 | bool useGpu = NULL != factory; |
| 493 | #if SK_SUPPORT_GPU |
| 494 | if (useGpu) { |
| 495 | GrContext* context = factory->get(GrContextFactory::kNative_GLContextType); |
| 496 | surface = SkSurface::NewRenderTarget(context, imageSpec); |
| 497 | } else { |
| 498 | surface = SkSurface::NewRaster(imageSpec); |
| 499 | } |
| 500 | #else |
| 501 | SkASSERT(!useGpu); |
| 502 | surface = SkSurface::NewRaster(imageSpec); |
| 503 | #endif |
| 504 | SkASSERT(NULL != surface); |
| 505 | SkAutoTUnref<SkSurface> aur(surface); |
| 506 | SkDeferredCanvas canvas(surface); |
| 507 | |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 508 | SkImage* image1 = canvas.newImageSnapshot(); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 509 | SkAutoTUnref<SkImage> aur_i1(image1); |
| 510 | PixelPtr pixels1 = getSurfacePixelPtr(surface, useGpu); |
| 511 | // The following clear would normally trigger a copy on write, but |
| 512 | // it won't because rendering is deferred. |
| 513 | canvas.clear(SK_ColorBLACK); |
| 514 | // Obtaining a snapshot directly from the surface (as opposed to the |
| 515 | // SkDeferredCanvas) will not trigger a flush of deferred draw operations |
| 516 | // and will therefore return the same image as the previous snapshot. |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 517 | SkImage* image2 = surface->newImageSnapshot(); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 518 | SkAutoTUnref<SkImage> aur_i2(image2); |
| 519 | // Images identical because of deferral |
| 520 | REPORTER_ASSERT(reporter, image1->uniqueID() == image2->uniqueID()); |
| 521 | // Now we obtain a snpshot via the deferred canvas, which triggers a flush. |
| 522 | // Because there is a pending clear, this will generate a different image. |
junov@chromium.org | 5ee449a | 2013-04-12 20:20:50 +0000 | [diff] [blame] | 523 | SkImage* image3 = canvas.newImageSnapshot(); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 524 | SkAutoTUnref<SkImage> aur_i3(image3); |
| 525 | REPORTER_ASSERT(reporter, image1->uniqueID() != image3->uniqueID()); |
| 526 | // Verify that backing store is now a different buffer because of copy on |
| 527 | // write |
| 528 | PixelPtr pixels2 = getSurfacePixelPtr(surface, useGpu); |
| 529 | REPORTER_ASSERT(reporter, pixels1 != pixels2); |
junov@chromium.org | 9becf00 | 2013-04-15 18:15:23 +0000 | [diff] [blame^] | 530 | // Verify copy-on write with a draw operation that gets deferred by |
| 531 | // the in order draw buffer. |
| 532 | SkPaint paint; |
| 533 | canvas.drawPaint(paint); |
| 534 | SkImage* image4 = canvas.newImageSnapshot(); // implicit flush |
| 535 | SkAutoTUnref<SkImage> aur_i4(image4); |
| 536 | REPORTER_ASSERT(reporter, image4->uniqueID() != image3->uniqueID()); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 537 | PixelPtr pixels3 = getSurfacePixelPtr(surface, useGpu); |
junov@chromium.org | 9becf00 | 2013-04-15 18:15:23 +0000 | [diff] [blame^] | 538 | REPORTER_ASSERT(reporter, pixels2 != pixels3); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 539 | // Verify that a direct canvas flush with a pending draw does not trigger |
| 540 | // a copy on write when the surface is not sharing its buffer with an |
| 541 | // SkImage. |
junov@chromium.org | 9becf00 | 2013-04-15 18:15:23 +0000 | [diff] [blame^] | 542 | canvas.clear(SK_ColorWHITE); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 543 | canvas.flush(); |
| 544 | PixelPtr pixels4 = getSurfacePixelPtr(surface, useGpu); |
junov@chromium.org | 9becf00 | 2013-04-15 18:15:23 +0000 | [diff] [blame^] | 545 | canvas.drawPaint(paint); |
| 546 | canvas.flush(); |
| 547 | PixelPtr pixels5 = getSurfacePixelPtr(surface, useGpu); |
| 548 | REPORTER_ASSERT(reporter, pixels4 == pixels5); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* factory) { |
junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 552 | TestDeferredCanvasBitmapAccess(reporter); |
| 553 | TestDeferredCanvasFlush(reporter); |
junov@chromium.org | 8f9ecbd | 2012-02-13 21:53:45 +0000 | [diff] [blame] | 554 | TestDeferredCanvasFreshFrame(reporter); |
junov@chromium.org | bfeddae | 2012-07-23 13:35:14 +0000 | [diff] [blame] | 555 | TestDeferredCanvasMemoryLimit(reporter); |
junov@chromium.org | 2e14ba8 | 2012-08-07 14:26:57 +0000 | [diff] [blame] | 556 | TestDeferredCanvasBitmapCaching(reporter); |
junov@google.com | 52a00ca | 2012-10-01 15:27:14 +0000 | [diff] [blame] | 557 | TestDeferredCanvasSkip(reporter); |
junov@chromium.org | ce65f38 | 2012-10-17 19:36:09 +0000 | [diff] [blame] | 558 | TestDeferredCanvasBitmapShaderNoLeak(reporter); |
sugoi@google.com | 7775fd5 | 2012-11-21 15:47:04 +0000 | [diff] [blame] | 559 | TestDeferredCanvasBitmapSizeThreshold(reporter); |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 560 | TestDeferredCanvasSurface(reporter, NULL); |
| 561 | if (NULL != factory) { |
| 562 | TestDeferredCanvasSurface(reporter, factory); |
| 563 | } |
junov@chromium.org | 1f9767c | 2012-02-07 16:27:57 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | #include "TestClassDef.h" |
junov@chromium.org | 67d7422 | 2013-04-12 13:33:01 +0000 | [diff] [blame] | 567 | DEFINE_GPUTESTCLASS("DeferredCanvas", TestDeferredCanvasClass, TestDeferredCanvas) |