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

Side by Side Diff: tests/CanvasTest.cpp

Issue 349213006: don't create explicit bitmapdevice when not needed (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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 * 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 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 }; 798 };
799 799
800 // unused 800 // unused
801 static void TestProxyCanvasStateConsistency( 801 static void TestProxyCanvasStateConsistency(
802 skiatest::Reporter* reporter, 802 skiatest::Reporter* reporter,
803 CanvasTestStep* testStep, 803 CanvasTestStep* testStep,
804 const SkCanvas& referenceCanvas) { 804 const SkCanvas& referenceCanvas) {
805 805
806 SkBitmap indirectStore; 806 SkBitmap indirectStore;
807 createBitmap(&indirectStore, 0xFFFFFFFF); 807 createBitmap(&indirectStore, 0xFFFFFFFF);
808 SkBitmapDevice indirectDevice(indirectStore); 808 SkCanvas indirectCanvas(indirectStore);
809 SkCanvas indirectCanvas(&indirectDevice);
810 SkProxyCanvas proxyCanvas(&indirectCanvas); 809 SkProxyCanvas proxyCanvas(&indirectCanvas);
811 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat); 810 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
812 testStep->draw(&proxyCanvas, reporter); 811 testStep->draw(&proxyCanvas, reporter);
813 // Verify that the SkProxyCanvas reports consitent state 812 // Verify that the SkProxyCanvas reports consitent state
814 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat); 813 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat);
815 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas, 814 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas,
816 testStep); 815 testStep);
817 // Verify that the indirect canvas reports consitent state 816 // Verify that the indirect canvas reports consitent state
818 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat); 817 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat);
819 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas, 818 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas,
820 testStep); 819 testStep);
821 } 820 }
822 821
823 // unused 822 // unused
824 static void TestNWayCanvasStateConsistency( 823 static void TestNWayCanvasStateConsistency(
825 skiatest::Reporter* reporter, 824 skiatest::Reporter* reporter,
826 CanvasTestStep* testStep, 825 CanvasTestStep* testStep,
827 const SkCanvas& referenceCanvas) { 826 const SkCanvas& referenceCanvas) {
828 827
829 SkBitmap indirectStore1; 828 SkBitmap indirectStore1;
830 createBitmap(&indirectStore1, 0xFFFFFFFF); 829 createBitmap(&indirectStore1, 0xFFFFFFFF);
831 SkBitmapDevice indirectDevice1(indirectStore1); 830 SkCanvas indirectCanvas1(indirectStore1);
832 SkCanvas indirectCanvas1(&indirectDevice1);
833 831
834 SkBitmap indirectStore2; 832 SkBitmap indirectStore2;
835 createBitmap(&indirectStore2, 0xFFFFFFFF); 833 createBitmap(&indirectStore2, 0xFFFFFFFF);
836 SkBitmapDevice indirectDevice2(indirectStore2); 834 SkCanvas indirectCanvas2(indirectStore2);
837 SkCanvas indirectCanvas2(&indirectDevice2);
838 835
839 SkISize canvasSize = referenceCanvas.getDeviceSize(); 836 SkISize canvasSize = referenceCanvas.getDeviceSize();
840 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height()); 837 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height());
841 nWayCanvas.addCanvas(&indirectCanvas1); 838 nWayCanvas.addCanvas(&indirectCanvas1);
842 nWayCanvas.addCanvas(&indirectCanvas2); 839 nWayCanvas.addCanvas(&indirectCanvas2);
843 840
844 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat); 841 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat);
845 testStep->draw(&nWayCanvas, reporter); 842 testStep->draw(&nWayCanvas, reporter);
846 // Verify that the SkProxyCanvas reports consitent state 843 // Verify that the SkProxyCanvas reports consitent state
847 testStep->setAssertMessageFormat(kNWayStateAssertMessageFormat); 844 testStep->setAssertMessageFormat(kNWayStateAssertMessageFormat);
(...skipping 11 matching lines...) Expand all
859 /* 856 /*
860 * This sub-test verifies that the test step passes when executed 857 * This sub-test verifies that the test step passes when executed
861 * with SkCanvas and with classes derrived from SkCanvas. It also verifies 858 * with SkCanvas and with classes derrived from SkCanvas. It also verifies
862 * that the all canvas derivatives report the same state as an SkCanvas 859 * that the all canvas derivatives report the same state as an SkCanvas
863 * after having executed the test step. 860 * after having executed the test step.
864 */ 861 */
865 static void TestOverrideStateConsistency(skiatest::Reporter* reporter, 862 static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
866 CanvasTestStep* testStep) { 863 CanvasTestStep* testStep) {
867 SkBitmap referenceStore; 864 SkBitmap referenceStore;
868 createBitmap(&referenceStore, 0xFFFFFFFF); 865 createBitmap(&referenceStore, 0xFFFFFFFF);
869 SkBitmapDevice referenceDevice(referenceStore); 866 SkCanvas referenceCanvas(referenceStore);
870 SkCanvas referenceCanvas(&referenceDevice);
871 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat); 867 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
872 testStep->draw(&referenceCanvas, reporter); 868 testStep->draw(&referenceCanvas, reporter);
873 869
874 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false); 870 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false);
875 871
876 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true); 872 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true);
877 873
878 // The following test code is disabled because SkProxyCanvas is 874 // The following test code is disabled because SkProxyCanvas is
879 // missing a lot of virtual overrides on get* methods, which are used 875 // missing a lot of virtual overrides on get* methods, which are used
880 // to verify canvas state. 876 // to verify canvas state.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 if (testStepArray()[testStep]->enablePdfTesting()) { 944 if (testStepArray()[testStep]->enablePdfTesting()) {
949 TestPdfDevice(reporter, testStepArray()[testStep]); 945 TestPdfDevice(reporter, testStepArray()[testStep]);
950 } 946 }
951 } 947 }
952 948
953 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 949 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
954 kTestBitmap.reset(); 950 kTestBitmap.reset();
955 951
956 test_newraster(reporter); 952 test_newraster(reporter);
957 } 953 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698