| 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 29 matching lines...) Expand all Loading... |
| 40 * SIMPLE_TEST_STEP(MytestStep, someCanvasAPIMethod()); | 40 * SIMPLE_TEST_STEP(MytestStep, someCanvasAPIMethod()); |
| 41 * | 41 * |
| 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 "SkDocument.h" |
| 50 #include "SkMatrix.h" | 51 #include "SkMatrix.h" |
| 51 #include "SkNWayCanvas.h" | 52 #include "SkNWayCanvas.h" |
| 52 #include "SkPDFCanon.h" | |
| 53 #include "SkPDFDevice.h" | |
| 54 #include "SkPDFDocument.h" | |
| 55 #include "SkPaint.h" | 53 #include "SkPaint.h" |
| 56 #include "SkPath.h" | 54 #include "SkPath.h" |
| 57 #include "SkPicture.h" | 55 #include "SkPicture.h" |
| 58 #include "SkPictureRecord.h" | 56 #include "SkPictureRecord.h" |
| 59 #include "SkPictureRecorder.h" | 57 #include "SkPictureRecorder.h" |
| 60 #include "SkRect.h" | 58 #include "SkRect.h" |
| 61 #include "SkRegion.h" | 59 #include "SkRegion.h" |
| 62 #include "SkShader.h" | 60 #include "SkShader.h" |
| 63 #include "SkStream.h" | 61 #include "SkStream.h" |
| 64 #include "SkSurface.h" | 62 #include "SkSurface.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 REPORTER_ASSERT_MESSAGE(reporter, layerIter1.done(), | 549 REPORTER_ASSERT_MESSAGE(reporter, layerIter1.done(), |
| 552 testStep->assertMessage()); | 550 testStep->assertMessage()); |
| 553 REPORTER_ASSERT_MESSAGE(reporter, layerIter2.done(), | 551 REPORTER_ASSERT_MESSAGE(reporter, layerIter2.done(), |
| 554 testStep->assertMessage()); | 552 testStep->assertMessage()); |
| 555 | 553 |
| 556 } | 554 } |
| 557 | 555 |
| 558 static void TestPdfDevice(skiatest::Reporter* reporter, | 556 static void TestPdfDevice(skiatest::Reporter* reporter, |
| 559 const TestData& d, | 557 const TestData& d, |
| 560 CanvasTestStep* testStep) { | 558 CanvasTestStep* testStep) { |
| 561 SkISize pageSize = SkISize::Make(d.fWidth, d.fHeight); | 559 SkDynamicMemoryWStream outStream; |
| 562 SkPDFCanon canon; | 560 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream)); |
| 563 SkAutoTUnref<SkPDFDevice> pdfDevice( | 561 SkCanvas* canvas = doc->beginPage(SkIntToScalar(d.fWidth), |
| 564 SkPDFDevice::Create(pageSize, 72.0f, &canon)); | 562 SkIntToScalar(d.fHeight)); |
| 565 SkCanvas canvas(pdfDevice.get()); | 563 REPORTER_ASSERT(reporter, canvas); |
| 566 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); | 564 testStep->setAssertMessageFormat(kPdfAssertMessageFormat); |
| 567 testStep->draw(&canvas, d, reporter); | 565 testStep->draw(canvas, d, reporter); |
| 568 SkPDFDocument doc; | 566 |
| 569 doc.appendPage(pdfDevice.get()); | 567 REPORTER_ASSERT(reporter, doc->close()); |
| 570 SkDynamicMemoryWStream stream; | |
| 571 doc.emitPDF(&stream); | |
| 572 } | 568 } |
| 573 | 569 |
| 574 // The following class groups static functions that need to access | 570 // The following class groups static functions that need to access |
| 575 // the privates members of SkDeferredCanvas | 571 // the privates members of SkDeferredCanvas |
| 576 class SkDeferredCanvasTester { | 572 class SkDeferredCanvasTester { |
| 577 public: | 573 public: |
| 578 static void TestDeferredCanvasStateConsistency( | 574 static void TestDeferredCanvasStateConsistency( |
| 579 skiatest::Reporter* reporter, | 575 skiatest::Reporter* reporter, |
| 580 const TestData& d, | 576 const TestData& d, |
| 581 CanvasTestStep* testStep, | 577 CanvasTestStep* testStep, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 | 740 |
| 745 n = canvas.saveLayer(NULL, NULL); | 741 n = canvas.saveLayer(NULL, NULL); |
| 746 REPORTER_ASSERT(reporter, 2 == n); | 742 REPORTER_ASSERT(reporter, 2 == n); |
| 747 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); | 743 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); |
| 748 | 744 |
| 749 canvas.restore(); | 745 canvas.restore(); |
| 750 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); | 746 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); |
| 751 canvas.restore(); | 747 canvas.restore(); |
| 752 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); | 748 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); |
| 753 } | 749 } |
| OLD | NEW |