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

Side by Side Diff: tests/CanvasTest.cpp

Issue 614773004: Add tests for SkCanvas::drawImage[Rect]() Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 "test step %s, SkProxyCanvas indirect canvas state consistency"; 145 "test step %s, SkProxyCanvas indirect canvas state consistency";
146 static const char* const kNWayStateAssertMessageFormat = 146 static const char* const kNWayStateAssertMessageFormat =
147 "test step %s, SkNWayCanvas state consistency"; 147 "test step %s, SkNWayCanvas state consistency";
148 static const char* const kNWayIndirect1StateAssertMessageFormat = 148 static const char* const kNWayIndirect1StateAssertMessageFormat =
149 "test step %s, SkNWayCanvas indirect canvas 1 state consistency"; 149 "test step %s, SkNWayCanvas indirect canvas 1 state consistency";
150 static const char* const kNWayIndirect2StateAssertMessageFormat = 150 static const char* const kNWayIndirect2StateAssertMessageFormat =
151 "test step %s, SkNWayCanvas indirect canvas 2 state consistency"; 151 "test step %s, SkNWayCanvas indirect canvas 2 state consistency";
152 static const char* const kPdfAssertMessageFormat = 152 static const char* const kPdfAssertMessageFormat =
153 "PDF sanity check failed %s"; 153 "PDF sanity check failed %s";
154 154
155 static void createBitmap(SkBitmap* bm, SkColor color) { 155 static void create_bitmap(SkBitmap* bm, SkColor color) {
156 bm->allocN32Pixels(kWidth, kHeight); 156 bm->allocN32Pixels(kWidth, kHeight);
157 bm->eraseColor(color); 157 bm->eraseColor(color);
158 } 158 }
159 159
160 static SkSurface* createSurface(SkColor color) { 160 static SkSurface* create_surface(SkColor color) {
161 SkSurface* surface = SkSurface::NewRasterPMColor(kWidth, kHeight); 161 SkSurface* surface = SkSurface::NewRasterPMColor(kWidth, kHeight);
162 surface->getCanvas()->clear(color); 162 surface->getCanvas()->clear(color);
163 return surface; 163 return surface;
164 } 164 }
165 165
166 class CanvasTestStep; 166 class CanvasTestStep;
167 static SkTDArray<CanvasTestStep*>& testStepArray() { 167 static SkTDArray<CanvasTestStep*>& testStepArray() {
168 static SkTDArray<CanvasTestStep*> theTests; 168 static SkTDArray<CanvasTestStep*> theTests;
169 return theTests; 169 return theTests;
170 } 170 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 const SkColor kTestColor = 0x01020304; 242 const SkColor kTestColor = 0x01020304;
243 const SkPaint kTestPaint; 243 const SkPaint kTestPaint;
244 const SkPoint kTestPoints[3] = { 244 const SkPoint kTestPoints[3] = {
245 {SkIntToScalar(0), SkIntToScalar(0)}, 245 {SkIntToScalar(0), SkIntToScalar(0)},
246 {SkIntToScalar(2), SkIntToScalar(1)}, 246 {SkIntToScalar(2), SkIntToScalar(1)},
247 {SkIntToScalar(0), SkIntToScalar(2)} 247 {SkIntToScalar(0), SkIntToScalar(2)}
248 }; 248 };
249 const size_t kTestPointCount = 3; 249 const size_t kTestPointCount = 3;
250 static SkBitmap testBitmap() { 250 static SkBitmap testBitmap() {
251 SkBitmap bitmap; 251 SkBitmap bitmap;
252 createBitmap(&bitmap, 0x05060708); 252 create_bitmap(&bitmap, 0x05060708);
253 return bitmap; 253 return bitmap;
254 } 254 }
255 SkBitmap kTestBitmap; // cannot be created during static init 255 SkBitmap kTestBitmap; // cannot be created during static init
256 SkString kTestText("Hello World"); 256 SkString kTestText("Hello World");
257 SkPoint kTestPoints2[] = { 257 SkPoint kTestPoints2[] = {
258 { SkIntToScalar(0), SkIntToScalar(1) }, 258 { SkIntToScalar(0), SkIntToScalar(1) },
259 { SkIntToScalar(1), SkIntToScalar(1) }, 259 { SkIntToScalar(1), SkIntToScalar(1) },
260 { SkIntToScalar(2), SkIntToScalar(1) }, 260 { SkIntToScalar(2), SkIntToScalar(1) },
261 { SkIntToScalar(3), SkIntToScalar(1) }, 261 { SkIntToScalar(3), SkIntToScalar(1) },
262 { SkIntToScalar(4), SkIntToScalar(1) }, 262 { SkIntToScalar(4), SkIntToScalar(1) },
263 { SkIntToScalar(5), SkIntToScalar(1) }, 263 { SkIntToScalar(5), SkIntToScalar(1) },
264 { SkIntToScalar(6), SkIntToScalar(1) }, 264 { SkIntToScalar(6), SkIntToScalar(1) },
265 { SkIntToScalar(7), SkIntToScalar(1) }, 265 { SkIntToScalar(7), SkIntToScalar(1) },
266 { SkIntToScalar(8), SkIntToScalar(1) }, 266 { SkIntToScalar(8), SkIntToScalar(1) },
267 { SkIntToScalar(9), SkIntToScalar(1) }, 267 { SkIntToScalar(9), SkIntToScalar(1) },
268 { SkIntToScalar(10), SkIntToScalar(1) }, 268 { SkIntToScalar(10), SkIntToScalar(1) },
269 }; 269 };
270 270 SkSurface* kTestSurface;
271 SkImage* kTestImage;
reed1 2014/09/30 13:44:55 ugh -- can we find a way to not use these globals?
Rémi Piotaix 2014/09/30 15:44:50 Seems that we can't. The use of the same bitmap/im
271 272
272 /////////////////////////////////////////////////////////////////////////////// 273 ///////////////////////////////////////////////////////////////////////////////
273 // Macros for defining test steps 274 // Macros for defining test steps
274 275
275 #define TEST_STEP(NAME, FUNCTION) \ 276 #define TEST_STEP(NAME, FUNCTION) \
276 class NAME##_TestStep : public CanvasTestStep{ \ 277 class NAME##_TestStep : public CanvasTestStep{ \
277 public: \ 278 public: \
278 virtual void draw(SkCanvas* canvas, skiatest::Reporter* reporter) { \ 279 virtual void draw(SkCanvas* canvas, skiatest::Reporter* reporter) { \
279 FUNCTION (canvas, reporter, this); \ 280 FUNCTION (canvas, reporter, this); \
280 } \ 281 } \
281 virtual const char* name() const {return #NAME ;} \ 282 virtual const char* name() const {return #NAME ;} \
282 }; \ 283 }; \
283 static NAME##_TestStep NAME##_TestStepInstance; 284 static NAME##_TestStep NAME##_TestStepInstance;
284 285
285 #define TEST_STEP_NO_PDF(NAME, FUNCTION) \ 286 #define TEST_STEP_NO_PDF(NAME, FUNCTION) \
286 class NAME##_TestStep : public CanvasTestStep{ \ 287 class NAME##_TestStep : public CanvasTestStep{ \
287 public: \ 288 public: \
288 NAME##_TestStep() : CanvasTestStep(false) {} \ 289 NAME##_TestStep() : CanvasTestStep(false) {} \
289 virtual void draw(SkCanvas* canvas, skiatest::Reporter* reporter) { \ 290 virtual void draw(SkCanvas* canvas, skiatest::Reporter* reporter) { \
290 FUNCTION (canvas, reporter, this); \ 291 FUNCTION (canvas, reporter, this); \
291 } \ 292 } \
292 virtual const char* name() const {return #NAME ;} \ 293 virtual const char* name() const {return #NAME ;} \
293 }; \ 294 }; \
294 static NAME##_TestStep NAME##_TestStepInstance; 295 static NAME##_TestStep NAME##_TestStepInstance;
295 296
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 SIMPLE_TEST_STEP(DrawPosText, drawPosText(kTestText.c_str(), 357 SIMPLE_TEST_STEP(DrawPosText, drawPosText(kTestText.c_str(),
357 kTestText.size(), kTestPoints2, kTestPaint)); 358 kTestText.size(), kTestPoints2, kTestPaint));
358 SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(kTestText.c_str(), 359 SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(kTestText.c_str(),
359 kTestText.size(), kTestPath, NULL, kTestPaint)); 360 kTestText.size(), kTestPath, NULL, kTestPaint));
360 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(), 361 SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(),
361 kTestText.size(), kTestPath, &kTestMatrix, kTestPaint)); 362 kTestText.size(), kTestPath, &kTestMatrix, kTestPaint));
362 SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size())); 363 SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size()));
363 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str())); 364 SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str()));
364 SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str())); 365 SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str()));
365 SIMPLE_TEST_STEP(EndGroup, endCommentGroup()); 366 SIMPLE_TEST_STEP(EndGroup, endCommentGroup());
367 SIMPLE_TEST_STEP(DrawImage, drawImage(kTestImage, 0, 0));
368 SIMPLE_TEST_STEP(DrawImageRect, drawImageRect(kTestImage, 0, SkRect::MakeWH(kWid th, kHeight)));
366 369
367 /////////////////////////////////////////////////////////////////////////////// 370 ///////////////////////////////////////////////////////////////////////////////
368 // Complex test steps 371 // Complex test steps
369 372
370 static void SaveMatrixClipStep(SkCanvas* canvas, 373 static void SaveMatrixClipStep(SkCanvas* canvas,
371 skiatest::Reporter* reporter, 374 skiatest::Reporter* reporter,
372 CanvasTestStep* testStep) { 375 CanvasTestStep* testStep) {
373 int saveCount = canvas->getSaveCount(); 376 int saveCount = canvas->getSaveCount();
374 canvas->save(); 377 canvas->save();
375 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); 378 canvas->translate(SkIntToScalar(1), SkIntToScalar(2));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts, 459 canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts,
457 NULL, NULL, NULL, 0, paint); 460 NULL, NULL, NULL, 0, paint);
458 } 461 }
459 // NYI: issue 240. 462 // NYI: issue 240.
460 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep); 463 TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep);
461 464
462 static void DrawPictureTestStep(SkCanvas* canvas, 465 static void DrawPictureTestStep(SkCanvas* canvas,
463 skiatest::Reporter*, 466 skiatest::Reporter*,
464 CanvasTestStep*) { 467 CanvasTestStep*) {
465 SkPictureRecorder recorder; 468 SkPictureRecorder recorder;
466 SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight), 469 SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT oScalar(kHeight),
467 NULL, 0); 470 NULL, 0);
468 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1)); 471 testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
469 testCanvas->clipRect(kTestRect); 472 testCanvas->clipRect(kTestRect);
470 testCanvas->drawRect(kTestRect, kTestPaint); 473 testCanvas->drawRect(kTestRect, kTestPaint);
471 SkAutoTUnref<SkPicture> testPicture(recorder.endRecording()); 474 SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
472 475
473 canvas->drawPicture(testPicture); 476 canvas->drawPicture(testPicture);
474 } 477 }
475 TEST_STEP(DrawPicture, DrawPictureTestStep); 478 TEST_STEP(DrawPicture, DrawPictureTestStep);
476 479
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 public: 685 public:
683 686
684 static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter, 687 static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter,
685 CanvasTestStep* testStep, 688 CanvasTestStep* testStep,
686 uint32_t recordFlags) { 689 uint32_t recordFlags) {
687 // Verify that when a test step is executed twice, no extra resources 690 // Verify that when a test step is executed twice, no extra resources
688 // are flattened during the second execution 691 // are flattened during the second execution
689 testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat); 692 testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
690 SkPictureRecorder referenceRecorder; 693 SkPictureRecorder referenceRecorder;
691 SkCanvas* referenceCanvas = 694 SkCanvas* referenceCanvas =
692 referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth), 695 referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
693 SkIntToScalar(kHeight), 696 SkIntToScalar(kHeight),
694 NULL, recordFlags); 697 NULL, recordFlags);
695 testStep->draw(referenceCanvas, reporter); 698 testStep->draw(referenceCanvas, reporter);
696 699
697 SkPictureRecorder testRecorder; 700 SkPictureRecorder testRecorder;
698 SkCanvas* testCanvas = 701 SkCanvas* testCanvas =
699 testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth), 702 testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
700 SkIntToScalar(kHeight), 703 SkIntToScalar(kHeight),
701 NULL, recordFlags); 704 NULL, recordFlags);
702 testStep->draw(testCanvas, reporter); 705 testStep->draw(testCanvas, reporter);
703 testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat); 706 testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
704 testStep->draw(testCanvas, reporter); 707 testStep->draw(testCanvas, reporter);
705 708
706 SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referen ceCanvas); 709 SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referen ceCanvas);
707 SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas); 710 SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas);
708 testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat); 711 testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat);
709 AssertFlattenedObjectsEqual(referenceRecord, testRecord, 712 AssertFlattenedObjectsEqual(referenceRecord, testRecord,
710 reporter, testStep); 713 reporter, testStep);
(...skipping 15 matching lines...) Expand all
726 729
727 // The following class groups static functions that need to access 730 // The following class groups static functions that need to access
728 // the privates members of SkDeferredCanvas 731 // the privates members of SkDeferredCanvas
729 class SkDeferredCanvasTester { 732 class SkDeferredCanvasTester {
730 public: 733 public:
731 static void TestDeferredCanvasStateConsistency( 734 static void TestDeferredCanvasStateConsistency(
732 skiatest::Reporter* reporter, 735 skiatest::Reporter* reporter,
733 CanvasTestStep* testStep, 736 CanvasTestStep* testStep,
734 const SkCanvas& referenceCanvas, bool silent) { 737 const SkCanvas& referenceCanvas, bool silent) {
735 738
736 SkAutoTUnref<SkSurface> surface(createSurface(0xFFFFFFFF)); 739 SkAutoTUnref<SkSurface> surface(create_surface(0xFFFFFFFF));
737 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(s urface.get())); 740 SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(s urface.get()));
738 741
739 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); 742 testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat);
740 testStep->draw(deferredCanvas, reporter); 743 testStep->draw(deferredCanvas, reporter);
741 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat); 744 testStep->setAssertMessageFormat(kDeferredPreFlushAssertMessageFormat);
742 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas, 745 AssertCanvasStatesEqual(reporter, deferredCanvas, &referenceCanvas,
743 testStep); 746 testStep);
744 747
745 if (silent) { 748 if (silent) {
746 deferredCanvas->silentFlush(); 749 deferredCanvas->silentFlush();
(...skipping 21 matching lines...) Expand all
768 } 771 }
769 }; 772 };
770 773
771 // unused 774 // unused
772 static void TestProxyCanvasStateConsistency( 775 static void TestProxyCanvasStateConsistency(
773 skiatest::Reporter* reporter, 776 skiatest::Reporter* reporter,
774 CanvasTestStep* testStep, 777 CanvasTestStep* testStep,
775 const SkCanvas& referenceCanvas) { 778 const SkCanvas& referenceCanvas) {
776 779
777 SkBitmap indirectStore; 780 SkBitmap indirectStore;
778 createBitmap(&indirectStore, 0xFFFFFFFF); 781 create_bitmap(&indirectStore, 0xFFFFFFFF);
779 SkCanvas indirectCanvas(indirectStore); 782 SkCanvas indirectCanvas(indirectStore);
780 SkProxyCanvas proxyCanvas(&indirectCanvas); 783 SkProxyCanvas proxyCanvas(&indirectCanvas);
781 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat); 784 testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
782 testStep->draw(&proxyCanvas, reporter); 785 testStep->draw(&proxyCanvas, reporter);
783 // Verify that the SkProxyCanvas reports consitent state 786 // Verify that the SkProxyCanvas reports consitent state
784 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat); 787 testStep->setAssertMessageFormat(kProxyStateAssertMessageFormat);
785 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas, 788 AssertCanvasStatesEqual(reporter, &proxyCanvas, &referenceCanvas,
786 testStep); 789 testStep);
787 // Verify that the indirect canvas reports consitent state 790 // Verify that the indirect canvas reports consitent state
788 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat); 791 testStep->setAssertMessageFormat(kProxyIndirectStateAssertMessageFormat);
789 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas, 792 AssertCanvasStatesEqual(reporter, &indirectCanvas, &referenceCanvas,
790 testStep); 793 testStep);
791 } 794 }
792 795
793 // unused 796 // unused
794 static void TestNWayCanvasStateConsistency( 797 static void TestNWayCanvasStateConsistency(
795 skiatest::Reporter* reporter, 798 skiatest::Reporter* reporter,
796 CanvasTestStep* testStep, 799 CanvasTestStep* testStep,
797 const SkCanvas& referenceCanvas) { 800 const SkCanvas& referenceCanvas) {
798 801
799 SkBitmap indirectStore1; 802 SkBitmap indirectStore1;
800 createBitmap(&indirectStore1, 0xFFFFFFFF); 803 create_bitmap(&indirectStore1, 0xFFFFFFFF);
801 SkCanvas indirectCanvas1(indirectStore1); 804 SkCanvas indirectCanvas1(indirectStore1);
802 805
803 SkBitmap indirectStore2; 806 SkBitmap indirectStore2;
804 createBitmap(&indirectStore2, 0xFFFFFFFF); 807 create_bitmap(&indirectStore2, 0xFFFFFFFF);
805 SkCanvas indirectCanvas2(indirectStore2); 808 SkCanvas indirectCanvas2(indirectStore2);
806 809
807 SkISize canvasSize = referenceCanvas.getDeviceSize(); 810 SkISize canvasSize = referenceCanvas.getDeviceSize();
808 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height()); 811 SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height());
809 nWayCanvas.addCanvas(&indirectCanvas1); 812 nWayCanvas.addCanvas(&indirectCanvas1);
810 nWayCanvas.addCanvas(&indirectCanvas2); 813 nWayCanvas.addCanvas(&indirectCanvas2);
811 814
812 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat); 815 testStep->setAssertMessageFormat(kNWayDrawAssertMessageFormat);
813 testStep->draw(&nWayCanvas, reporter); 816 testStep->draw(&nWayCanvas, reporter);
814 // Verify that the SkProxyCanvas reports consitent state 817 // Verify that the SkProxyCanvas reports consitent state
(...skipping 11 matching lines...) Expand all
826 829
827 /* 830 /*
828 * This sub-test verifies that the test step passes when executed 831 * This sub-test verifies that the test step passes when executed
829 * with SkCanvas and with classes derrived from SkCanvas. It also verifies 832 * with SkCanvas and with classes derrived from SkCanvas. It also verifies
830 * that the all canvas derivatives report the same state as an SkCanvas 833 * that the all canvas derivatives report the same state as an SkCanvas
831 * after having executed the test step. 834 * after having executed the test step.
832 */ 835 */
833 static void TestOverrideStateConsistency(skiatest::Reporter* reporter, 836 static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
834 CanvasTestStep* testStep) { 837 CanvasTestStep* testStep) {
835 SkBitmap referenceStore; 838 SkBitmap referenceStore;
836 createBitmap(&referenceStore, 0xFFFFFFFF); 839 create_bitmap(&referenceStore, 0xFFFFFFFF);
837 SkCanvas referenceCanvas(referenceStore); 840 SkCanvas referenceCanvas(referenceStore);
838 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat); 841 testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
839 testStep->draw(&referenceCanvas, reporter); 842 testStep->draw(&referenceCanvas, reporter);
840 843
841 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false); 844 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, false);
842 845
843 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true); 846 SkDeferredCanvasTester::TestDeferredCanvasStateConsistency(reporter, testSte p, referenceCanvas, true);
844 847
845 // The following test code is disabled because SkProxyCanvas is 848 // The following test code is disabled because SkProxyCanvas is
846 // missing a lot of virtual overrides on get* methods, which are used 849 // missing a lot of virtual overrides on get* methods, which are used
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 info = SkImageInfo::MakeN32Premul(0, 0); 901 info = SkImageInfo::MakeN32Premul(0, 0);
899 canvas = SkCanvas::NewRaster(info); 902 canvas = SkCanvas::NewRaster(info);
900 REPORTER_ASSERT(reporter, canvas); 903 REPORTER_ASSERT(reporter, canvas);
901 SkDELETE(canvas); 904 SkDELETE(canvas);
902 } 905 }
903 906
904 DEF_TEST(Canvas, reporter) { 907 DEF_TEST(Canvas, reporter) {
905 // Init global here because bitmap pixels cannot be alocated during 908 // Init global here because bitmap pixels cannot be alocated during
906 // static initialization 909 // static initialization
907 kTestBitmap = testBitmap(); 910 kTestBitmap = testBitmap();
911 kTestSurface = create_surface(SK_ColorGREEN);
912 kTestImage = kTestSurface->newImageSnapshot();
Justin Novosad 2014/09/30 18:06:46 I guess these globals could be packaged into a loc
Rémi Piotaix 2014/10/02 18:45:24 Done here: https://codereview.chromium.org/6170930
908 913
909 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { 914 for (int testStep = 0; testStep < testStepArray().count(); testStep++) {
910 TestOverrideStateConsistency(reporter, testStepArray()[testStep]); 915 TestOverrideStateConsistency(reporter, testStepArray()[testStep]);
911 SkPictureTester::TestPictureFlattenedObjectReuse(reporter, 916 SkPictureTester::TestPictureFlattenedObjectReuse(reporter,
912 testStepArray()[testStep], 0); 917 testStepArray()[testStep], 0);
913 if (testStepArray()[testStep]->enablePdfTesting()) { 918 if (testStepArray()[testStep]->enablePdfTesting()) {
914 TestPdfDevice(reporter, testStepArray()[testStep]); 919 TestPdfDevice(reporter, testStepArray()[testStep]);
915 } 920 }
916 } 921 }
917 922
918 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global) 923 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i s a global)
919 kTestBitmap.reset(); 924 kTestBitmap.reset();
925 kTestSurface->unref();
926 kTestImage->unref();
920 927
921 test_newraster(reporter); 928 test_newraster(reporter);
922 } 929 }
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