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

Side by Side Diff: tests/CanvasTest.cpp

Issue 2202203003: not much point to SK_SUPPORT_PDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « samplecode/SampleApp.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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 TEST_STEP(DescribeTopLayer, DescribeTopLayerTestStep); 538 TEST_STEP(DescribeTopLayer, DescribeTopLayerTestStep);
539 539
540 540
541 class CanvasTestingAccess { 541 class CanvasTestingAccess {
542 public: 542 public:
543 static bool SameState(const SkCanvas* canvas1, const SkCanvas* canvas2) { 543 static bool SameState(const SkCanvas* canvas1, const SkCanvas* canvas2) {
544 SkCanvas::LayerIter layerIter1(const_cast<SkCanvas*>(canvas1), false); 544 SkCanvas::LayerIter layerIter1(const_cast<SkCanvas*>(canvas1), false);
545 SkCanvas::LayerIter layerIter2(const_cast<SkCanvas*>(canvas2), false); 545 SkCanvas::LayerIter layerIter2(const_cast<SkCanvas*>(canvas2), false);
546 while (!layerIter1.done() && !layerIter2.done()) { 546 while (!layerIter1.done() && !layerIter2.done()) {
547 if (layerIter1.matrix() != layerIter2.matrix()) { 547 if (layerIter1.matrix() != layerIter2.matrix()) {
548 return false; 548 return false;
549 } 549 }
550 if (layerIter1.clip() != layerIter2.clip()) { 550 if (layerIter1.clip() != layerIter2.clip()) {
551 return false; 551 return false;
552 } 552 }
553 if (layerIter1.paint() != layerIter2.paint()) { 553 if (layerIter1.paint() != layerIter2.paint()) {
554 return false; 554 return false;
555 } 555 }
556 if (layerIter1.x() != layerIter2.x()) { 556 if (layerIter1.x() != layerIter2.x()) {
557 return false; 557 return false;
558 } 558 }
559 if (layerIter1.y() != layerIter2.y()) { 559 if (layerIter1.y() != layerIter2.y()) {
560 return false; 560 return false;
561 } 561 }
562 layerIter1.next(); 562 layerIter1.next();
563 layerIter2.next(); 563 layerIter2.next();
564 } 564 }
565 if (!layerIter1.done()) { 565 if (!layerIter1.done()) {
566 return false; 566 return false;
567 } 567 }
(...skipping 27 matching lines...) Expand all
595 SkIRect deviceBounds1, deviceBounds2; 595 SkIRect deviceBounds1, deviceBounds2;
596 REPORTER_ASSERT_MESSAGE(reporter, 596 REPORTER_ASSERT_MESSAGE(reporter,
597 canvas1->getClipDeviceBounds(&deviceBounds1) == 597 canvas1->getClipDeviceBounds(&deviceBounds1) ==
598 canvas2->getClipDeviceBounds(&deviceBounds2), 598 canvas2->getClipDeviceBounds(&deviceBounds2),
599 testStep->assertMessage()); 599 testStep->assertMessage());
600 REPORTER_ASSERT_MESSAGE(reporter, deviceBounds1 == deviceBounds2, testStep-> assertMessage()); 600 REPORTER_ASSERT_MESSAGE(reporter, deviceBounds1 == deviceBounds2, testStep-> assertMessage());
601 REPORTER_ASSERT_MESSAGE(reporter, canvas1->getTotalMatrix() == 601 REPORTER_ASSERT_MESSAGE(reporter, canvas1->getTotalMatrix() ==
602 canvas2->getTotalMatrix(), testStep->assertMessage()); 602 canvas2->getTotalMatrix(), testStep->assertMessage());
603 REPORTER_ASSERT_MESSAGE(reporter, equal_clips(*canvas1, *canvas2), testStep- >assertMessage()); 603 REPORTER_ASSERT_MESSAGE(reporter, equal_clips(*canvas1, *canvas2), testStep- >assertMessage());
604 604
605 REPORTER_ASSERT_MESSAGE(reporter, 605 REPORTER_ASSERT_MESSAGE(reporter,
606 CanvasTestingAccess::SameState(canvas1, canvas2), 606 CanvasTestingAccess::SameState(canvas1, canvas2),
607 testStep->assertMessage()); 607 testStep->assertMessage());
608 } 608 }
609 609
610 static void TestPdfDevice(skiatest::Reporter* reporter, 610 static void TestPdfDevice(skiatest::Reporter* reporter,
611 const TestData& d, 611 const TestData& d,
612 CanvasTestStep* testStep) { 612 CanvasTestStep* testStep) {
613 SkDynamicMemoryWStream outStream; 613 SkDynamicMemoryWStream outStream;
614 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream)); 614 sk_sp<SkDocument> doc(SkDocument::MakePDF(&outStream));
615 #if SK_SUPPORT_PDF
616 REPORTER_ASSERT(reporter, doc); 615 REPORTER_ASSERT(reporter, doc);
617 #else
618 REPORTER_ASSERT(reporter, !doc);
619 #endif // SK_SUPPORT_PDF
620 if (!doc) { 616 if (!doc) {
621 return; 617 return;
622 } 618 }
623 SkCanvas* canvas = doc->beginPage(SkIntToScalar(d.fWidth), 619 SkCanvas* canvas = doc->beginPage(SkIntToScalar(d.fWidth),
624 SkIntToScalar(d.fHeight)); 620 SkIntToScalar(d.fHeight));
625 REPORTER_ASSERT(reporter, canvas); 621 REPORTER_ASSERT(reporter, canvas);
626 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); 622 testStep->setAssertMessageFormat(kPdfAssertMessageFormat);
627 testStep->draw(canvas, d, reporter); 623 testStep->draw(canvas, d, reporter);
628 624
629 REPORTER_ASSERT(reporter, doc->close()); 625 REPORTER_ASSERT(reporter, doc->close());
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 SkPaint paint; 880 SkPaint paint;
885 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); 881 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED));
886 882
887 canvas.save(); 883 canvas.save();
888 canvas.clipRect(SkRect::MakeWH(55, 55)); 884 canvas.clipRect(SkRect::MakeWH(55, 55));
889 canvas.translate(10, 20); 885 canvas.translate(10, 20);
890 canvas.drawRect(SkRect::MakeWH(50, 50), paint); 886 canvas.drawRect(SkRect::MakeWH(50, 50), paint);
891 canvas.restore(); 887 canvas.restore();
892 } 888 }
893 889
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698