Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: tests/CanvasTest.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // the privates members of SkDeferredCanvas 772 // the privates members of SkDeferredCanvas
773 class SkDeferredCanvasTester { 773 class SkDeferredCanvasTester {
774 public: 774 public:
775 static void TestDeferredCanvasStateConsistency( 775 static void TestDeferredCanvasStateConsistency(
776 skiatest::Reporter* reporter, 776 skiatest::Reporter* reporter,
777 CanvasTestStep* testStep, 777 CanvasTestStep* testStep,
778 const SkCanvas& referenceCanvas, bool silent) { 778 const SkCanvas& referenceCanvas, bool silent) {
779 779
780 SkBitmap deferredStore; 780 SkBitmap deferredStore;
781 createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); 781 createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
782 SkDevice deferredDevice(deferredStore); 782 SkBitmapDevice deferredDevice(deferredStore);
783 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(& deferredDevice)); 783 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(& deferredDevice));
784 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); 784 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat);
785 testStep->draw(deferredCanvas, reporter); 785 testStep->draw(deferredCanvas, reporter);
786 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); 786 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat);
787 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas, 787 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas,
788 testStep); 788 testStep);
789 789
790 if (silent) { 790 if (silent) {
791 deferredCanvas->silentFlush(); 791 deferredCanvas->silentFlush();
792 } else { 792 } else {
(...skipping 21 matching lines...) Expand all
814 }; 814 };
815 815
816 // unused 816 // unused
817 static void TestProxyCanvasStateConsistency( 817 static void TestProxyCanvasStateConsistency(
818 skiatest::Reporter* reporter, 818 skiatest::Reporter* reporter,
819 CanvasTestStep* testStep, 819 CanvasTestStep* testStep,
820 const SkCanvas& referenceCanvas) { 820 const SkCanvas& referenceCanvas) {
821 821
822 SkBitmap indirectStore; 822 SkBitmap indirectStore;
823 createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); 823 createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
824 SkDevice indirectDevice(indirectStore); 824 SkBitmapDevice indirectDevice(indirectStore);
825 SkCanvas indirectCanvas(&indirectDevice); 825 SkCanvas indirectCanvas(&indirectDevice);
826 SkProxyCanvas proxyCanvas(&indirectCanvas); 826 SkProxyCanvas proxyCanvas(&indirectCanvas);
827 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat); 827 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
828 testStep->draw(&proxyCanvas, reporter); 828 testStep->draw(&proxyCanvas, reporter);
829 // Verify that the SkProxyCanvas reports consitent state 829 // Verify that the SkProxyCanvas reports consitent state
830 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat); 830 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat);
831 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas, 831 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas,
832 testStep); 832 testStep);
833 // Verify that the indirect canvas reports consitent state 833 // Verify that the indirect canvas reports consitent state
834 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat); 834 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat);
835 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas, 835 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas,
836 testStep); 836 testStep);
837 } 837 }
838 838
839 // unused 839 // unused
840 static void TestNWayCanvasStateConsistency( 840 static void TestNWayCanvasStateConsistency(
841 skiatest::Reporter* reporter, 841 skiatest::Reporter* reporter,
842 CanvasTestStep* testStep, 842 CanvasTestStep* testStep,
843 const SkCanvas& referenceCanvas) { 843 const SkCanvas& referenceCanvas) {
844 844
845 SkBitmap indirectStore1; 845 SkBitmap indirectStore1;
846 createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); 846 createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
847 SkDevice indirectDevice1(indirectStore1); 847 SkBitmapDevice indirectDevice1(indirectStore1);
848 SkCanvas indirectCanvas1(&indirectDevice1); 848 SkCanvas indirectCanvas1(&indirectDevice1);
849 849
850 SkBitmap indirectStore2; 850 SkBitmap indirectStore2;
851 createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); 851 createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
852 SkDevice indirectDevice2(indirectStore2); 852 SkBitmapDevice indirectDevice2(indirectStore2);
853 SkCanvas indirectCanvas2(&indirectDevice2); 853 SkCanvas indirectCanvas2(&indirectDevice2);
854 854
855 SkISize canvasSize = referenceCanvas.getDeviceSize(); 855 SkISize canvasSize = referenceCanvas.getDeviceSize();
856 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height()); 856 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height());
857 nWayCanvas.addCanvas(&indirectCanvas1); 857 nWayCanvas.addCanvas(&indirectCanvas1);
858 nWayCanvas.addCanvas(&indirectCanvas2); 858 nWayCanvas.addCanvas(&indirectCanvas2);
859 859
860 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat); 860 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat);
861 testStep->draw(&nWayCanvas, reporter); 861 testStep->draw(&nWayCanvas, reporter);
862 // Verify that the SkProxyCanvas reports consitent state 862 // Verify that the SkProxyCanvas reports consitent state
(...skipping 12 matching lines...) Expand all
875 /* 875 /*
876 * This sub-test verifies that the test step passes when executed 876 * This sub-test verifies that the test step passes when executed
877 * with SkCanvas and with classes derrived from SkCanvas. It also verifies 877 * with SkCanvas and with classes derrived from SkCanvas. It also verifies
878 * that the all canvas derivatives report the same state as an SkCanvas 878 * that the all canvas derivatives report the same state as an SkCanvas
879 * after having executed the test step. 879 * after having executed the test step.
880 */ 880 */
881 static void TestOverrideStateConsistency(skiatest::Reporter* reporter, 881 static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
882 CanvasTestStep* testStep) { 882 CanvasTestStep* testStep) {
883 SkBitmap referenceStore; 883 SkBitmap referenceStore;
884 createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); 884 createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
885 SkDevice referenceDevice(referenceStore); 885 SkBitmapDevice referenceDevice(referenceStore);
886 SkCanvas referenceCanvas(&referenceDevice); 886 SkCanvas referenceCanvas(&referenceDevice);
887 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat); 887 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
888 testStep->draw(&referenceCanvas, reporter); 888 testStep->draw(&referenceCanvas, reporter);
889 889
890 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false); 890 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false);
891 891
892 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true); 892 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true);
893 893
894 // The following test code is disabled because SkProxyCanvas is 894 // The following test code is disabled because SkProxyCanvas is
895 // missing a lot of virtual overrides on get* methods, which are used 895 // missing a lot of virtual overrides on get* methods, which are used
(...skipping 30 matching lines...) Expand all
926 TestPdfDevice(reporter, testStepArray()[testStep]); 926 TestPdfDevice(reporter, testStepArray()[testStep]);
927 } 927 }
928 } 928 }
929 929
930 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 930 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
931 kTestBitmap.reset(); 931 kTestBitmap.reset();
932 } 932 }
933 933
934 #include "TestClassDef.h" 934 #include "TestClassDef.h"
935 DEFINE_TESTCLASS("Canvas", TestCanvasClass, TestCanvas) 935 DEFINE_TESTCLASS("Canvas", TestCanvasClass, TestCanvas)
OLDNEW
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698