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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 REPORTER_ASSERT(reporter, getSurfacePixelPtr(alternateSurface, useGpu) != pi
xels2); | 818 REPORTER_ASSERT(reporter, getSurfacePixelPtr(alternateSurface, useGpu) != pi
xels2); |
819 } | 819 } |
820 | 820 |
821 static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
r) { | 821 static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
r) { |
822 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100)); | 822 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100)); |
823 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); | 823 SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()
)); |
824 | 824 |
825 NotificationCounter notificationCounter; | 825 NotificationCounter notificationCounter; |
826 canvas->setNotificationClient(¬ificationCounter); | 826 canvas->setNotificationClient(¬ificationCounter); |
827 | 827 |
828 SkAutoTUnref<SkBaseDevice> secondaryDevice(canvas->createCompatibleDevice( | 828 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
829 SkBitmap::kARGB_8888_Config, 10, 10, false)); | 829 SkAutoTUnref<SkSurface> secondarySurface(canvas->newSurface(info)); |
830 SkCanvas secondaryCanvas(secondaryDevice.get()); | 830 |
831 SkRect rect = SkRect::MakeWH(5, 5); | 831 SkRect rect = SkRect::MakeWH(5, 5); |
832 SkPaint paint; | 832 SkPaint paint; |
833 // After spawning a compatible canvas: | 833 // After spawning a compatible canvas: |
834 // 1) Verify that secondary canvas is usable and does not report to the noti
fication client. | 834 // 1) Verify that secondary canvas is usable and does not report to the noti
fication client. |
835 secondaryCanvas.drawRect(rect, paint); | 835 surface->getCanvas()->drawRect(rect, paint); |
836 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); | 836 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 0); |
837 // 2) Verify that original canvas is usable and still reports to the notific
ation client. | 837 // 2) Verify that original canvas is usable and still reports to the notific
ation client. |
838 canvas->drawRect(rect, paint); | 838 canvas->drawRect(rect, paint); |
839 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); | 839 REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount
== 1); |
840 } | 840 } |
841 | 841 |
842 DEF_GPUTEST(DeferredCanvas, reporter, factory) { | 842 DEF_GPUTEST(DeferredCanvas, reporter, factory) { |
843 TestDeferredCanvasBitmapAccess(reporter); | 843 TestDeferredCanvasBitmapAccess(reporter); |
844 TestDeferredCanvasFlush(reporter); | 844 TestDeferredCanvasFlush(reporter); |
845 TestDeferredCanvasFreshFrame(reporter); | 845 TestDeferredCanvasFreshFrame(reporter); |
846 TestDeferredCanvasMemoryLimit(reporter); | 846 TestDeferredCanvasMemoryLimit(reporter); |
847 TestDeferredCanvasBitmapCaching(reporter); | 847 TestDeferredCanvasBitmapCaching(reporter); |
848 TestDeferredCanvasSkip(reporter); | 848 TestDeferredCanvasSkip(reporter); |
849 TestDeferredCanvasBitmapShaderNoLeak(reporter); | 849 TestDeferredCanvasBitmapShaderNoLeak(reporter); |
850 TestDeferredCanvasBitmapSizeThreshold(reporter); | 850 TestDeferredCanvasBitmapSizeThreshold(reporter); |
851 TestDeferredCanvasCreateCompatibleDevice(reporter); | 851 TestDeferredCanvasCreateCompatibleDevice(reporter); |
852 TestDeferredCanvasWritePixelsToSurface(reporter); | 852 TestDeferredCanvasWritePixelsToSurface(reporter); |
853 TestDeferredCanvasSurface(reporter, NULL); | 853 TestDeferredCanvasSurface(reporter, NULL); |
854 TestDeferredCanvasSetSurface(reporter, NULL); | 854 TestDeferredCanvasSetSurface(reporter, NULL); |
855 if (NULL != factory) { | 855 if (NULL != factory) { |
856 TestDeferredCanvasSurface(reporter, factory); | 856 TestDeferredCanvasSurface(reporter, factory); |
857 TestDeferredCanvasSetSurface(reporter, factory); | 857 TestDeferredCanvasSetSurface(reporter, factory); |
858 } | 858 } |
859 } | 859 } |
OLD | NEW |