| 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 sourceImage.allocN32Pixels(100, 100); | 489 sourceImage.allocN32Pixels(100, 100); |
| 490 | 490 |
| 491 for (int i = 0; i < 5; i++) { | 491 for (int i = 0; i < 5; i++) { |
| 492 sourceImage.notifyPixelsChanged(); // to force re-serialization | 492 sourceImage.notifyPixelsChanged(); // to force re-serialization |
| 493 canvas->drawBitmap(sourceImage, 0, 0, NULL); | 493 canvas->drawBitmap(sourceImage, 0, 0, NULL); |
| 494 } | 494 } |
| 495 | 495 |
| 496 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount
); | 496 REPORTER_ASSERT(reporter, 1 == notificationCounter.fFlushedDrawCommandsCount
); |
| 497 } | 497 } |
| 498 | 498 |
| 499 static void TestDeferredCanvasSilentFlush(skiatest::Reporter* reporter) { |
| 500 SkAutoTUnref<SkSurface> surface(createSurface(0)); |
| 501 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); |
| 502 |
| 503 NotificationCounter notificationCounter; |
| 504 canvas->setNotificationClient(¬ificationCounter); |
| 505 |
| 506 canvas->silentFlush(); // will skip the initial clear that was recorded in c
reateSurface |
| 507 |
| 508 REPORTER_ASSERT(reporter, 0 == notificationCounter.fFlushedDrawCommandsCount
); |
| 509 REPORTER_ASSERT(reporter, 1 == notificationCounter.fSkippedPendingDrawComman
dsCount); |
| 510 } |
| 511 |
| 499 static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) { | 512 static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) { |
| 500 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100)); | 513 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100)); |
| 501 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); | 514 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); |
| 502 | 515 |
| 503 NotificationCounter notificationCounter; | 516 NotificationCounter notificationCounter; |
| 504 canvas->setNotificationClient(¬ificationCounter); | 517 canvas->setNotificationClient(¬ificationCounter); |
| 505 | 518 |
| 506 const int imageCount = 2; | 519 const int imageCount = 2; |
| 507 SkBitmap sourceImages[imageCount]; | 520 SkBitmap sourceImages[imageCount]; |
| 508 for (int i = 0; i < imageCount; i++) { | 521 for (int i = 0; i < imageCount; i++) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 surface->getCanvas()->drawRect(rect, paint); | 812 surface->getCanvas()->drawRect(rect, paint); |
| 800 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); | 813 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); |
| 801 // 2) Verify that original canvas is usable and still reports to the notific
ation client. | 814 // 2) Verify that original canvas is usable and still reports to the notific
ation client. |
| 802 canvas->drawRect(rect, paint); | 815 canvas->drawRect(rect, paint); |
| 803 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); | 816 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); |
| 804 } | 817 } |
| 805 | 818 |
| 806 DEF_GPUTEST(DeferredCanvas, reporter, factory) { | 819 DEF_GPUTEST(DeferredCanvas, reporter, factory) { |
| 807 TestDeferredCanvasBitmapAccess(reporter); | 820 TestDeferredCanvasBitmapAccess(reporter); |
| 808 TestDeferredCanvasFlush(reporter); | 821 TestDeferredCanvasFlush(reporter); |
| 822 TestDeferredCanvasSilentFlush(reporter); |
| 809 TestDeferredCanvasFreshFrame(reporter); | 823 TestDeferredCanvasFreshFrame(reporter); |
| 810 TestDeferredCanvasMemoryLimit(reporter); | 824 TestDeferredCanvasMemoryLimit(reporter); |
| 811 TestDeferredCanvasBitmapCaching(reporter); | 825 TestDeferredCanvasBitmapCaching(reporter); |
| 812 TestDeferredCanvasSkip(reporter); | 826 TestDeferredCanvasSkip(reporter); |
| 813 TestDeferredCanvasBitmapShaderNoLeak(reporter); | 827 TestDeferredCanvasBitmapShaderNoLeak(reporter); |
| 814 TestDeferredCanvasBitmapSizeThreshold(reporter); | 828 TestDeferredCanvasBitmapSizeThreshold(reporter); |
| 815 TestDeferredCanvasCreateCompatibleDevice(reporter); | 829 TestDeferredCanvasCreateCompatibleDevice(reporter); |
| 816 TestDeferredCanvasWritePixelsToSurface(reporter); | 830 TestDeferredCanvasWritePixelsToSurface(reporter); |
| 817 TestDeferredCanvasSurface(reporter, NULL); | 831 TestDeferredCanvasSurface(reporter, NULL); |
| 818 TestDeferredCanvasSetSurface(reporter, NULL); | 832 TestDeferredCanvasSetSurface(reporter, NULL); |
| 819 if (NULL != factory) { | 833 if (NULL != factory) { |
| 820 TestDeferredCanvasSurface(reporter, factory); | 834 TestDeferredCanvasSurface(reporter, factory); |
| 821 TestDeferredCanvasSetSurface(reporter, factory); | 835 TestDeferredCanvasSetSurface(reporter, factory); |
| 822 } | 836 } |
| 823 } | 837 } |
| OLD | NEW |