OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "../src/image/SkImagePriv.h" | 8 #include "../src/image/SkImagePriv.h" |
9 #include "../src/image/SkSurface_Base.h" | 9 #include "../src/image/SkSurface_Base.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 canvas->restore(); | 284 canvas->restore(); |
285 REPORTER_ASSERT(reporter, !canvas->isFreshFrame()); | 285 REPORTER_ASSERT(reporter, !canvas->isFreshFrame()); |
286 | 286 |
287 // Verify that a clear with clipping triggers a fresh frame | 287 // Verify that a clear with clipping triggers a fresh frame |
288 // (clear is not affected by clipping) | 288 // (clear is not affected by clipping) |
289 canvas->save(); | 289 canvas->save(); |
290 canvas->clipRect(partialRect, SkRegion::kIntersect_Op, false); | 290 canvas->clipRect(partialRect, SkRegion::kIntersect_Op, false); |
291 canvas->clear(0x00000000); | 291 canvas->clear(0x00000000); |
292 canvas->restore(); | 292 canvas->restore(); |
293 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); | 293 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); |
| 294 } |
294 | 295 |
| 296 static void TestDeferredCanvasFreshFrameWithDrawOps(skiatest::Reporter* reporter
) { |
| 297 SkRect fullRect; |
| 298 fullRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(gWidth), |
| 299 SkIntToScalar(gHeight)); |
| 300 SkRect partialRect; |
| 301 partialRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), |
| 302 SkIntToScalar(1), SkIntToScalar(1)); |
| 303 |
| 304 SkAutoTUnref<SkSurface> surface(createSurface(0xFFFFFFFF)); |
| 305 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); |
| 306 |
| 307 // We have verified that the frame is initially fresh, So It will get |
| 308 // the canvasSize, and reuse this canvasSize if the frame is not fresh. |
295 // Verify that full frame rects with different forms of opaque paint | 309 // Verify that full frame rects with different forms of opaque paint |
296 // trigger frames to be marked as fresh | 310 // trigger frames to be marked as fresh |
297 { | 311 { |
298 SkPaint paint; | 312 SkPaint paint; |
299 paint.setStyle(SkPaint::kFill_Style); | 313 paint.setStyle(SkPaint::kFill_Style); |
300 paint.setAlpha(255); | 314 paint.setAlpha(255); |
301 canvas->drawRect(fullRect, paint); | 315 canvas->drawRect(fullRect, paint); |
302 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); | 316 REPORTER_ASSERT(reporter, canvas->isFreshFrame()); |
303 } | 317 } |
304 { | 318 { |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); | 850 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); |
837 // 2) Verify that original canvas is usable and still reports to the notific
ation client. | 851 // 2) Verify that original canvas is usable and still reports to the notific
ation client. |
838 canvas->drawRect(rect, paint); | 852 canvas->drawRect(rect, paint); |
839 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); | 853 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); |
840 } | 854 } |
841 | 855 |
842 DEF_TEST(DeferredCanvas_CPU, reporter) { | 856 DEF_TEST(DeferredCanvas_CPU, reporter) { |
843 TestDeferredCanvasFlush(reporter); | 857 TestDeferredCanvasFlush(reporter); |
844 TestDeferredCanvasSilentFlush(reporter); | 858 TestDeferredCanvasSilentFlush(reporter); |
845 TestDeferredCanvasFreshFrame(reporter); | 859 TestDeferredCanvasFreshFrame(reporter); |
| 860 TestDeferredCanvasFreshFrameWithDrawOps(reporter); |
846 TestDeferredCanvasMemoryLimit(reporter); | 861 TestDeferredCanvasMemoryLimit(reporter); |
847 TestDeferredCanvasBitmapCaching(reporter); | 862 TestDeferredCanvasBitmapCaching(reporter); |
848 TestDeferredCanvasSkip(reporter); | 863 TestDeferredCanvasSkip(reporter); |
849 TestDeferredCanvasBitmapShaderNoLeak(reporter); | 864 TestDeferredCanvasBitmapShaderNoLeak(reporter); |
850 TestDeferredCanvasBitmapSizeThreshold(reporter); | 865 TestDeferredCanvasBitmapSizeThreshold(reporter); |
851 TestDeferredCanvasCreateCompatibleDevice(reporter); | 866 TestDeferredCanvasCreateCompatibleDevice(reporter); |
852 TestDeferredCanvasWritePixelsToSurface(reporter); | 867 TestDeferredCanvasWritePixelsToSurface(reporter); |
853 TestDeferredCanvasSurface(reporter, NULL); | 868 TestDeferredCanvasSurface(reporter, NULL); |
854 TestDeferredCanvasSetSurface(reporter, NULL); | 869 TestDeferredCanvasSetSurface(reporter, NULL); |
855 } | 870 } |
856 | 871 |
857 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { | 872 DEF_GPUTEST(DeferredCanvas_GPU, reporter, factory) { |
858 if (factory != NULL) { | 873 if (factory != NULL) { |
859 TestDeferredCanvasSurface(reporter, factory); | 874 TestDeferredCanvasSurface(reporter, factory); |
860 TestDeferredCanvasSetSurface(reporter, factory); | 875 TestDeferredCanvasSetSurface(reporter, factory); |
861 } | 876 } |
862 } | 877 } |
OLD | NEW |