OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 /* Description: | 9 /* Description: |
10 * This test defines a series of elementatry test steps that perform | 10 * This test defines a series of elementatry test steps that perform |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 class SkDeferredCanvasTester { | 770 class SkDeferredCanvasTester { |
771 public: | 771 public: |
772 static void TestDeferredCanvasStateConsistency( | 772 static void TestDeferredCanvasStateConsistency( |
773 skiatest::Reporter* reporter, | 773 skiatest::Reporter* reporter, |
774 CanvasTestStep* testStep, | 774 CanvasTestStep* testStep, |
775 const SkCanvas& referenceCanvas, bool silent) { | 775 const SkCanvas& referenceCanvas, bool silent) { |
776 | 776 |
777 SkBitmap deferredStore; | 777 SkBitmap deferredStore; |
778 createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); | 778 createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); |
779 SkDevice deferredDevice(deferredStore); | 779 SkDevice deferredDevice(deferredStore); |
780 SkDeferredCanvas deferredCanvas(&deferredDevice); | 780 SkAutoTUnref<SkDeferredCanvas> deferredCanvas( |
| 781 #if SK_DEFERRED_CANVAS_USES_FACTORIES |
| 782 SkDeferredCanvas::Create(&deferredDevice)); |
| 783 #else |
| 784 SkNEW_ARGS(SkDeferredCanvas, (&deferredDevice))); |
| 785 #endif |
781 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); | 786 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); |
782 testStep->draw(&deferredCanvas, reporter); | 787 testStep->draw(deferredCanvas, reporter); |
783 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); | 788 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); |
784 AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas, | 789 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas, |
785 testStep); | 790 testStep); |
786 | 791 |
787 if (silent) { | 792 if (silent) { |
788 deferredCanvas.silentFlush(); | 793 deferredCanvas->silentFlush(); |
789 } else { | 794 } else { |
790 deferredCanvas.flush(); | 795 deferredCanvas->flush(); |
791 } | 796 } |
792 | 797 |
793 testStep->setAssertMessageFormat( | 798 testStep->setAssertMessageFormat( |
794 silent ? kDeferredPostSilentFlushPlaybackAssertMessageFormat : | 799 silent ? kDeferredPostSilentFlushPlaybackAssertMessageFormat : |
795 kDeferredPostFlushPlaybackAssertMessageFormat); | 800 kDeferredPostFlushPlaybackAssertMessageFormat); |
796 AssertCanvasStatesEqual(reporter, | 801 AssertCanvasStatesEqual(reporter, |
797 deferredCanvas.immediateCanvas(), | 802 deferredCanvas->immediateCanvas(), |
798 &referenceCanvas, testStep); | 803 &referenceCanvas, testStep); |
799 | 804 |
800 // Verified that deferred canvas state is not affected by flushing | 805 // Verified that deferred canvas state is not affected by flushing |
801 // pending draw operations | 806 // pending draw operations |
802 | 807 |
803 // The following test code is commented out because it currently fails. | 808 // The following test code is commented out because it currently fails. |
804 // Issue: http://code.google.com/p/skia/issues/detail?id=496 | 809 // Issue: http://code.google.com/p/skia/issues/detail?id=496 |
805 /* | 810 /* |
806 testStep->setAssertMessageFormat(kDeferredPostFlushAssertMessageFormat); | 811 testStep->setAssertMessageFormat(kDeferredPostFlushAssertMessageFormat); |
807 AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas, | 812 AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 TestPdfDevice(reporter, testStepArray()[testStep]); | 928 TestPdfDevice(reporter, testStepArray()[testStep]); |
924 } | 929 } |
925 } | 930 } |
926 | 931 |
927 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) | 932 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) |
928 kTestBitmap.reset(); | 933 kTestBitmap.reset(); |
929 } | 934 } |
930 | 935 |
931 #include "TestClassDef.h" | 936 #include "TestClassDef.h" |
932 DEFINE_TESTCLASS("Canvas", TestCanvasClass, TestCanvas) | 937 DEFINE_TESTCLASS("Canvas", TestCanvasClass, TestCanvas) |
OLD | NEW |