OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * There is another macro called SIMPLE_TEST_STEP_WITH_ASSERT that | 42 * There is another macro called SIMPLE_TEST_STEP_WITH_ASSERT that |
43 * works the same way as SIMPLE_TEST_STEP, and additionally verifies | 43 * works the same way as SIMPLE_TEST_STEP, and additionally verifies |
44 * that the invoked method returns a non-zero value. | 44 * that the invoked method returns a non-zero value. |
45 */ | 45 */ |
46 #include "SkBitmap.h" | 46 #include "SkBitmap.h" |
47 #include "SkCanvas.h" | 47 #include "SkCanvas.h" |
48 #include "SkDeferredCanvas.h" | 48 #include "SkDeferredCanvas.h" |
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 "SkPDFCanon.h" |
52 #include "SkPDFDevice.h" | 53 #include "SkPDFDevice.h" |
53 #include "SkPDFDocument.h" | 54 #include "SkPDFDocument.h" |
54 #include "SkPaint.h" | 55 #include "SkPaint.h" |
55 #include "SkPath.h" | 56 #include "SkPath.h" |
56 #include "SkPicture.h" | 57 #include "SkPicture.h" |
57 #include "SkPictureRecord.h" | 58 #include "SkPictureRecord.h" |
58 #include "SkPictureRecorder.h" | 59 #include "SkPictureRecorder.h" |
59 #include "SkRect.h" | 60 #include "SkRect.h" |
60 #include "SkRegion.h" | 61 #include "SkRegion.h" |
61 #include "SkShader.h" | 62 #include "SkShader.h" |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 testStep->assertMessage()); | 552 testStep->assertMessage()); |
552 REPORTER_ASSERT_MESSAGE(reporter, layerIter2.done(), | 553 REPORTER_ASSERT_MESSAGE(reporter, layerIter2.done(), |
553 testStep->assertMessage()); | 554 testStep->assertMessage()); |
554 | 555 |
555 } | 556 } |
556 | 557 |
557 static void TestPdfDevice(skiatest::Reporter* reporter, | 558 static void TestPdfDevice(skiatest::Reporter* reporter, |
558 const TestData& d, | 559 const TestData& d, |
559 CanvasTestStep* testStep) { | 560 CanvasTestStep* testStep) { |
560 SkISize pageSize = SkISize::Make(d.fWidth, d.fHeight); | 561 SkISize pageSize = SkISize::Make(d.fWidth, d.fHeight); |
561 SkPDFDevice device(pageSize, pageSize, SkMatrix::I()); | 562 SkPDFCanon canon; |
562 SkCanvas canvas(&device); | 563 SkAutoTUnref<SkPDFDevice> pdfDevice( |
| 564 SkPDFDevice::Create(pageSize, 72.0f, &canon)); |
| 565 SkCanvas canvas(pdfDevice.get()); |
563 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); | 566 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); |
564 testStep->draw(&canvas, d, reporter); | 567 testStep->draw(&canvas, d, reporter); |
565 SkPDFDocument doc; | 568 SkPDFDocument doc; |
566 doc.appendPage(&device); | 569 doc.appendPage(pdfDevice.get()); |
567 SkDynamicMemoryWStream stream; | 570 SkDynamicMemoryWStream stream; |
568 doc.emitPDF(&stream); | 571 doc.emitPDF(&stream); |
569 } | 572 } |
570 | 573 |
571 // The following class groups static functions that need to access | 574 // The following class groups static functions that need to access |
572 // the privates members of SkDeferredCanvas | 575 // the privates members of SkDeferredCanvas |
573 class SkDeferredCanvasTester { | 576 class SkDeferredCanvasTester { |
574 public: | 577 public: |
575 static void TestDeferredCanvasStateConsistency( | 578 static void TestDeferredCanvasStateConsistency( |
576 skiatest::Reporter* reporter, | 579 skiatest::Reporter* reporter, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 744 |
742 n = canvas.saveLayer(NULL, NULL); | 745 n = canvas.saveLayer(NULL, NULL); |
743 REPORTER_ASSERT(reporter, 2 == n); | 746 REPORTER_ASSERT(reporter, 2 == n); |
744 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); | 747 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); |
745 | 748 |
746 canvas.restore(); | 749 canvas.restore(); |
747 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); | 750 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); |
748 canvas.restore(); | 751 canvas.restore(); |
749 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); | 752 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); |
750 } | 753 } |
OLD | NEW |