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

Side by Side Diff: tests/CanvasTest.cpp

Issue 618303002: Remove DEPRECATED_beginRecording(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up benches Created 6 years, 2 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/core/SkPictureRecorder.cpp ('k') | tests/PictureTest.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 * 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 static const int kHeight = 2; 114 static const int kHeight = 2;
115 115
116 // Format strings that describe the test context. The %s token is where 116 // Format strings that describe the test context. The %s token is where
117 // the name of the test step is inserted. The context is required for 117 // the name of the test step is inserted. The context is required for
118 // disambiguating the error in the case of failures that are reported in 118 // disambiguating the error in the case of failures that are reported in
119 // functions that are called multiple times in different contexts (test 119 // functions that are called multiple times in different contexts (test
120 // cases and test steps). 120 // cases and test steps).
121 static const char* const kDefaultAssertMessageFormat = "%s"; 121 static const char* const kDefaultAssertMessageFormat = "%s";
122 static const char* const kCanvasDrawAssertMessageFormat = 122 static const char* const kCanvasDrawAssertMessageFormat =
123 "Drawing test step %s with SkCanvas"; 123 "Drawing test step %s with SkCanvas";
124 static const char* const kPictureDrawAssertMessageFormat =
125 "Drawing test step %s with SkPicture";
126 static const char* const kPictureSecondDrawAssertMessageFormat =
127 "Duplicate draw of test step %s with SkPicture";
128 static const char* const kDeferredDrawAssertMessageFormat = 124 static const char* const kDeferredDrawAssertMessageFormat =
129 "Drawing test step %s with SkDeferredCanvas"; 125 "Drawing test step %s with SkDeferredCanvas";
130 static const char* const kProxyDrawAssertMessageFormat = 126 static const char* const kProxyDrawAssertMessageFormat =
131 "Drawing test step %s with SkProxyCanvas"; 127 "Drawing test step %s with SkProxyCanvas";
132 static const char* const kNWayDrawAssertMessageFormat = 128 static const char* const kNWayDrawAssertMessageFormat =
133 "Drawing test step %s with SkNWayCanvas"; 129 "Drawing test step %s with SkNWayCanvas";
134 static const char* const kDeferredPreFlushAssertMessageFormat = 130 static const char* const kDeferredPreFlushAssertMessageFormat =
135 "test step %s, SkDeferredCanvas state consistency before flush"; 131 "test step %s, SkDeferredCanvas state consistency before flush";
136 static const char* const kDeferredPostFlushPlaybackAssertMessageFormat = 132 static const char* const kDeferredPostFlushPlaybackAssertMessageFormat =
137 "test step %s, SkDeferredCanvas playback canvas state consistency after flus h"; 133 "test step %s, SkDeferredCanvas playback canvas state consistency after flus h";
138 static const char* const kDeferredPostSilentFlushPlaybackAssertMessageFormat = 134 static const char* const kDeferredPostSilentFlushPlaybackAssertMessageFormat =
139 "test step %s, SkDeferredCanvas playback canvas state consistency after sile nt flush"; 135 "test step %s, SkDeferredCanvas playback canvas state consistency after sile nt flush";
140 static const char* const kPictureResourceReuseMessageFormat =
141 "test step %s, SkPicture duplicate flattened object test";
142 static const char* const kProxyStateAssertMessageFormat = 136 static const char* const kProxyStateAssertMessageFormat =
143 "test step %s, SkProxyCanvas state consistency"; 137 "test step %s, SkProxyCanvas state consistency";
144 static const char* const kProxyIndirectStateAssertMessageFormat = 138 static const char* const kProxyIndirectStateAssertMessageFormat =
145 "test step %s, SkProxyCanvas indirect canvas state consistency"; 139 "test step %s, SkProxyCanvas indirect canvas state consistency";
146 static const char* const kNWayStateAssertMessageFormat = 140 static const char* const kNWayStateAssertMessageFormat =
147 "test step %s, SkNWayCanvas state consistency"; 141 "test step %s, SkNWayCanvas state consistency";
148 static const char* const kNWayIndirect1StateAssertMessageFormat = 142 static const char* const kNWayIndirect1StateAssertMessageFormat =
149 "test step %s, SkNWayCanvas indirect canvas 1 state consistency"; 143 "test step %s, SkNWayCanvas indirect canvas 1 state consistency";
150 static const char* const kNWayIndirect2StateAssertMessageFormat = 144 static const char* const kNWayIndirect2StateAssertMessageFormat =
151 "test step %s, SkNWayCanvas indirect canvas 2 state consistency"; 145 "test step %s, SkNWayCanvas indirect canvas 2 state consistency";
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts, 450 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts,
457 NULL, NULL, NULL, 0, paint); 451 NULL, NULL, NULL, 0, paint);
458 } 452 }
459 // NYI: issue 240. 453 // NYI: issue 240.
460 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep); 454 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep);
461 455
462 static void DrawPictureTestStep(SkCanvas* canvas, 456 static void DrawPictureTestStep(SkCanvas* canvas,
463 skiatest::Reporter*, 457 skiatest::Reporter*,
464 CanvasTestStep*) { 458 CanvasTestStep*) {
465 SkPictureRecorder recorder; 459 SkPictureRecorder recorder;
466 SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight), 460 SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight),
467 NULL, 0); 461 NULL, 0);
468 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1)); 462 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
469 testCanvas->clipRect(kTestRect); 463 testCanvas->clipRect(kTestRect);
470 testCanvas->drawRect(kTestRect, kTestPaint); 464 testCanvas->drawRect(kTestRect, kTestPaint);
471 SkAutoTUnref<SkPicture> testPicture(recorder.endRecording()); 465 SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
472 466
473 canvas->drawPicture(testPicture); 467 canvas->drawPicture(testPicture);
474 } 468 }
475 TEST_STEP(DrawPicture, DrawPictureTestStep); 469 TEST_STEP(DrawPicture, DrawPictureTestStep);
476 470
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 testStep->assertMessage()); 665 testStep->assertMessage());
672 for (int i = 0; i < referenceRecord->fPathHeap->count(); ++i) { 666 for (int i = 0; i < referenceRecord->fPathHeap->count(); ++i) {
673 REPORTER_ASSERT_MESSAGE(reporter, 667 REPORTER_ASSERT_MESSAGE(reporter,
674 (*referenceRecord->fPathHeap)[i] == 668 (*referenceRecord->fPathHeap)[i] ==
675 (*testRecord->fPathHeap)[i], testStep->assertMessage()); 669 (*testRecord->fPathHeap)[i], testStep->assertMessage());
676 } 670 }
677 } 671 }
678 */ 672 */
679 673
680 } 674 }
681
682 public:
683
684 static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter,
685 CanvasTestStep* testStep,
686 uint32_t recordFlags) {
687 // Verify that when a test step is executed twice, no extra resources
688 // are flattened during the second execution
689 testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
690 SkPictureRecorder referenceRecorder;
691 SkCanvas* referenceCanvas =
692 referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
693 SkIntToScalar(kHeight),
694 NULL, recordFlags);
695 testStep->draw(referenceCanvas, reporter);
696
697 SkPictureRecorder testRecorder;
698 SkCanvas* testCanvas =
699 testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
700 SkIntToScalar(kHeight),
701 NULL, recordFlags);
702 testStep->draw(testCanvas, reporter);
703 testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
704 testStep->draw(testCanvas, reporter);
705
706 SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referen ceCanvas);
707 SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas);
708 testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat);
709 AssertFlattenedObjectsEqual(referenceRecord, testRecord,
710 reporter, testStep);
711 }
712 }; 675 };
713 676
714 static void TestPdfDevice(skiatest::Reporter* reporter, 677 static void TestPdfDevice(skiatest::Reporter* reporter,
715 CanvasTestStep* testStep) { 678 CanvasTestStep* testStep) {
716 SkISize pageSize = SkISize::Make(kWidth, kHeight); 679 SkISize pageSize = SkISize::Make(kWidth, kHeight);
717 SkPDFDevice device(pageSize, pageSize, SkMatrix::I()); 680 SkPDFDevice device(pageSize, pageSize, SkMatrix::I());
718 SkCanvas canvas(&device); 681 SkCanvas canvas(&device);
719 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); 682 testStep->setAssertMessageFormat(kPdfAssertMessageFormat);
720 testStep->draw(&canvas, reporter); 683 testStep->draw(&canvas, reporter);
721 SkPDFDocument doc; 684 SkPDFDocument doc;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 SkDELETE(canvas); 864 SkDELETE(canvas);
902 } 865 }
903 866
904 DEF_TEST(Canvas, reporter) { 867 DEF_TEST(Canvas, reporter) {
905 // Init global here because bitmap pixels cannot be alocated during 868 // Init global here because bitmap pixels cannot be alocated during
906 // static initialization 869 // static initialization
907 kTestBitmap = testBitmap(); 870 kTestBitmap = testBitmap();
908 871
909 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { 872 for (int testStep = 0; testStep < testStepArray().count(); testStep++) {
910 TestOverrideStateConsistency(reporter, testStepArray()[testStep]); 873 TestOverrideStateConsistency(reporter, testStepArray()[testStep]);
911 SkPictureTester::TestPictureFlattenedObjectReuse(reporter,
912 testStepArray()[testStep], 0);
913 if (testStepArray()[testStep]->enablePdfTesting()) { 874 if (testStepArray()[testStep]->enablePdfTesting()) {
914 TestPdfDevice(reporter, testStepArray()[testStep]); 875 TestPdfDevice(reporter, testStepArray()[testStep]);
915 } 876 }
916 } 877 }
917 878
918 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 879 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
919 kTestBitmap.reset(); 880 kTestBitmap.reset();
920 881
921 test_newraster(reporter); 882 test_newraster(reporter);
922 } 883 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecorder.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698