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

Side by Side Diff: tests/CanvasTest.cpp

Issue 886813002: Remove SkProxyCanvas. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « src/utils/SkProxyCanvas.cpp ('k') | 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "SkDevice.h" 49 #include "SkDevice.h"
50 #include "SkMatrix.h" 50 #include "SkMatrix.h"
51 #include "SkNWayCanvas.h" 51 #include "SkNWayCanvas.h"
52 #include "SkPDFDevice.h" 52 #include "SkPDFDevice.h"
53 #include "SkPDFDocument.h" 53 #include "SkPDFDocument.h"
54 #include "SkPaint.h" 54 #include "SkPaint.h"
55 #include "SkPath.h" 55 #include "SkPath.h"
56 #include "SkPicture.h" 56 #include "SkPicture.h"
57 #include "SkPictureRecord.h" 57 #include "SkPictureRecord.h"
58 #include "SkPictureRecorder.h" 58 #include "SkPictureRecorder.h"
59 #include "SkProxyCanvas.h"
60 #include "SkRect.h" 59 #include "SkRect.h"
61 #include "SkRegion.h" 60 #include "SkRegion.h"
62 #include "SkShader.h" 61 #include "SkShader.h"
63 #include "SkStream.h" 62 #include "SkStream.h"
64 #include "SkSurface.h" 63 #include "SkSurface.h"
65 #include "SkTDArray.h" 64 #include "SkTDArray.h"
66 #include "Test.h" 65 #include "Test.h"
67 66
68 static const int kWidth = 2, kHeight = 2; 67 static const int kWidth = 2, kHeight = 2;
69 68
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Format strings that describe the test context. The %s token is where 221 // Format strings that describe the test context. The %s token is where
223 // the name of the test step is inserted. The context is required for 222 // the name of the test step is inserted. The context is required for
224 // disambiguating the error in the case of failures that are reported in 223 // disambiguating the error in the case of failures that are reported in
225 // functions that are called multiple times in different contexts (test 224 // functions that are called multiple times in different contexts (test
226 // cases and test steps). 225 // cases and test steps).
227 static const char* const kDefaultAssertMessageFormat = "%s"; 226 static const char* const kDefaultAssertMessageFormat = "%s";
228 static const char* const kCanvasDrawAssertMessageFormat = 227 static const char* const kCanvasDrawAssertMessageFormat =
229 "Drawing test step %s with SkCanvas"; 228 "Drawing test step %s with SkCanvas";
230 static const char* const kDeferredDrawAssertMessageFormat = 229 static const char* const kDeferredDrawAssertMessageFormat =
231 "Drawing test step %s with SkDeferredCanvas"; 230 "Drawing test step %s with SkDeferredCanvas";
232 static const char* const kProxyDrawAssertMessageFormat =
233 "Drawing test step %s with SkProxyCanvas";
234 static const char* const kNWayDrawAssertMessageFormat = 231 static const char* const kNWayDrawAssertMessageFormat =
235 "Drawing test step %s with SkNWayCanvas"; 232 "Drawing test step %s with SkNWayCanvas";
236 static const char* const kDeferredPreFlushAssertMessageFormat = 233 static const char* const kDeferredPreFlushAssertMessageFormat =
237 "test step %s, SkDeferredCanvas state consistency before flush"; 234 "test step %s, SkDeferredCanvas state consistency before flush";
238 static const char* const kDeferredPostFlushPlaybackAssertMessageFormat = 235 static const char* const kDeferredPostFlushPlaybackAssertMessageFormat =
239 "test step %s, SkDeferredCanvas playback canvas state consistency after flus h"; 236 "test step %s, SkDeferredCanvas playback canvas state consistency after flus h";
240 static const char* const kDeferredPostSilentFlushPlaybackAssertMessageFormat = 237 static const char* const kDeferredPostSilentFlushPlaybackAssertMessageFormat =
241 "test step %s, SkDeferredCanvas playback canvas state consistency after sile nt flush"; 238 "test step %s, SkDeferredCanvas playback canvas state consistency after sile nt flush";
242 static const char* const kProxyStateAssertMessageFormat =
243 "test step %s, SkProxyCanvas state consistency";
244 static const char* const kProxyIndirectStateAssertMessageFormat =
245 "test step %s, SkProxyCanvas indirect canvas state consistency";
246 static const char* const kNWayStateAssertMessageFormat = 239 static const char* const kNWayStateAssertMessageFormat =
247 "test step %s, SkNWayCanvas state consistency"; 240 "test step %s, SkNWayCanvas state consistency";
248 static const char* const kNWayIndirect1StateAssertMessageFormat = 241 static const char* const kNWayIndirect1StateAssertMessageFormat =
249 "test step %s, SkNWayCanvas indirect canvas 1 state consistency"; 242 "test step %s, SkNWayCanvas indirect canvas 1 state consistency";
250 static const char* const kNWayIndirect2StateAssertMessageFormat = 243 static const char* const kNWayIndirect2StateAssertMessageFormat =
251 "test step %s, SkNWayCanvas indirect canvas 2 state consistency"; 244 "test step %s, SkNWayCanvas indirect canvas 2 state consistency";
252 static const char* const kPdfAssertMessageFormat = 245 static const char* const kPdfAssertMessageFormat =
253 "PDF sanity check failed %s"; 246 "PDF sanity check failed %s";
254 247
255 class CanvasTestStep; 248 class CanvasTestStep;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // Issue: http://code.google.com/p/skia/issues/detail?id=496 605 // Issue: http://code.google.com/p/skia/issues/detail?id=496
613 /* 606 /*
614 testStep->setAssertMessageFormat(kDeferredPostFlushAssertMessageFormat); 607 testStep->setAssertMessageFormat(kDeferredPostFlushAssertMessageFormat);
615 AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas, 608 AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas,
616 testStep); 609 testStep);
617 */ 610 */
618 } 611 }
619 }; 612 };
620 613
621 // unused 614 // unused
622 static void TestProxyCanvasStateConsistency(
623 skiatest::Reporter* reporter,
624 const TestData& d,
625 CanvasTestStep* testStep,
626 const SkCanvas& referenceCanvas) {
627
628 SkBitmap indirectStore;
629 createBitmap(&indirectStore, 0xFFFFFFFF);
630 SkCanvas indirectCanvas(indirectStore);
631 SkProxyCanvas proxyCanvas(&indirectCanvas);
632 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
633 testStep->draw(&proxyCanvas, d, reporter);
634 // Verify that the SkProxyCanvas reports consitent state
635 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat);
636 AssertCanvasStatesEqual(reporter, d, &proxyCanvas, &referenceCanvas, testSte p);
637 // Verify that the indirect canvas reports consitent state
638 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat);
639 AssertCanvasStatesEqual(reporter, d, &indirectCanvas, &referenceCanvas, test Step);
640 }
641
642 // unused
643 static void TestNWayCanvasStateConsistency( 615 static void TestNWayCanvasStateConsistency(
644 skiatest::Reporter* reporter, 616 skiatest::Reporter* reporter,
645 const TestData& d, 617 const TestData& d,
646 CanvasTestStep* testStep, 618 CanvasTestStep* testStep,
647 const SkCanvas& referenceCanvas) { 619 const SkCanvas& referenceCanvas) {
648 620
649 SkBitmap indirectStore1; 621 SkBitmap indirectStore1;
650 createBitmap(&indirectStore1, 0xFFFFFFFF); 622 createBitmap(&indirectStore1, 0xFFFFFFFF);
651 SkCanvas indirectCanvas1(indirectStore1); 623 SkCanvas indirectCanvas1(indirectStore1);
652 624
653 SkBitmap indirectStore2; 625 SkBitmap indirectStore2;
654 createBitmap(&indirectStore2, 0xFFFFFFFF); 626 createBitmap(&indirectStore2, 0xFFFFFFFF);
655 SkCanvas indirectCanvas2(indirectStore2); 627 SkCanvas indirectCanvas2(indirectStore2);
656 628
657 SkISize canvasSize = referenceCanvas.getDeviceSize(); 629 SkISize canvasSize = referenceCanvas.getDeviceSize();
658 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height()); 630 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height());
659 nWayCanvas.addCanvas(&indirectCanvas1); 631 nWayCanvas.addCanvas(&indirectCanvas1);
660 nWayCanvas.addCanvas(&indirectCanvas2); 632 nWayCanvas.addCanvas(&indirectCanvas2);
661 633
662 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat); 634 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat);
663 testStep->draw(&nWayCanvas, d, reporter); 635 testStep->draw(&nWayCanvas, d, reporter);
664 // Verify that the SkProxyCanvas reports consitent state 636 // Verify that the SkNWayCanvas reports consitent state
665 testStep->setAssertMessageFormat(kNWayStateAssertMessageFormat); 637 testStep->setAssertMessageFormat(kNWayStateAssertMessageFormat);
666 AssertCanvasStatesEqual(reporter, d, &nWayCanvas, &referenceCanvas, testStep ); 638 AssertCanvasStatesEqual(reporter, d, &nWayCanvas, &referenceCanvas, testStep );
667 // Verify that the indirect canvases report consitent state 639 // Verify that the indirect canvases report consitent state
668 testStep->setAssertMessageFormat(kNWayIndirect1StateAssertMessageFormat); 640 testStep->setAssertMessageFormat(kNWayIndirect1StateAssertMessageFormat);
669 AssertCanvasStatesEqual(reporter, d, &indirectCanvas1, &referenceCanvas, tes tStep); 641 AssertCanvasStatesEqual(reporter, d, &indirectCanvas1, &referenceCanvas, tes tStep);
670 testStep->setAssertMessageFormat(kNWayIndirect2StateAssertMessageFormat); 642 testStep->setAssertMessageFormat(kNWayIndirect2StateAssertMessageFormat);
671 AssertCanvasStatesEqual(reporter, d, &indirectCanvas2, &referenceCanvas, tes tStep); 643 AssertCanvasStatesEqual(reporter, d, &indirectCanvas2, &referenceCanvas, tes tStep);
672 } 644 }
673 645
674 /* 646 /*
675 * This sub-test verifies that the test step passes when executed 647 * This sub-test verifies that the test step passes when executed
676 * with SkCanvas and with classes derrived from SkCanvas. It also verifies 648 * with SkCanvas and with classes derrived from SkCanvas. It also verifies
677 * that the all canvas derivatives report the same state as an SkCanvas 649 * that the all canvas derivatives report the same state as an SkCanvas
678 * after having executed the test step. 650 * after having executed the test step.
679 */ 651 */
680 static void TestOverrideStateConsistency(skiatest::Reporter* reporter, const Tes tData& d, 652 static void TestOverrideStateConsistency(skiatest::Reporter* reporter, const Tes tData& d,
681 CanvasTestStep* testStep) { 653 CanvasTestStep* testStep) {
682 SkBitmap referenceStore; 654 SkBitmap referenceStore;
683 createBitmap(&referenceStore, 0xFFFFFFFF); 655 createBitmap(&referenceStore, 0xFFFFFFFF);
684 SkCanvas referenceCanvas(referenceStore); 656 SkCanvas referenceCanvas(referenceStore);
685 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat); 657 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
686 testStep->draw(&referenceCanvas, d, reporter); 658 testStep->draw(&referenceCanvas, d, reporter);
687 659
688 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, d, test Step, referenceCanvas, false); 660 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, d, test Step, referenceCanvas, false);
689 661
690 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, d, test Step, referenceCanvas, true); 662 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, d, test Step, referenceCanvas, true);
691 663
692 // The following test code is disabled because SkProxyCanvas is
693 // missing a lot of virtual overrides on get* methods, which are used
694 // to verify canvas state.
695 // Issue: http://code.google.com/p/skia/issues/detail?id=500
696
697 if (false) { // avoid bit rot, suppress warning
698 TestProxyCanvasStateConsistency(reporter, d, testStep, referenceCanvas);
699 }
700
701 // The following test code is disabled because SkNWayCanvas does not 664 // The following test code is disabled because SkNWayCanvas does not
702 // report correct clipping and device bounds information 665 // report correct clipping and device bounds information
703 // Issue: http://code.google.com/p/skia/issues/detail?id=501 666 // Issue: http://code.google.com/p/skia/issues/detail?id=501
704 667
705 if (false) { // avoid bit rot, suppress warning 668 if (false) { // avoid bit rot, suppress warning
706 TestNWayCanvasStateConsistency(reporter, d, testStep, referenceCanvas); 669 TestNWayCanvasStateConsistency(reporter, d, testStep, referenceCanvas);
707 } 670 }
708 671
709 if (false) { // avoid bit rot, suppress warning 672 if (false) { // avoid bit rot, suppress warning
710 test_clipVisitor(reporter, &referenceCanvas); 673 test_clipVisitor(reporter, &referenceCanvas);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 741
779 n = canvas.saveLayer(NULL, NULL); 742 n = canvas.saveLayer(NULL, NULL);
780 REPORTER_ASSERT(reporter, 2 == n); 743 REPORTER_ASSERT(reporter, 2 == n);
781 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); 744 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount());
782 745
783 canvas.restore(); 746 canvas.restore();
784 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); 747 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount());
785 canvas.restore(); 748 canvas.restore();
786 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); 749 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount());
787 } 750 }
OLDNEW
« no previous file with comments | « src/utils/SkProxyCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698