| 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowByt
es); | 647 const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowByt
es); |
| 648 REPORTER_ASSERT(reporter, addr); | 648 REPORTER_ASSERT(reporter, addr); |
| 649 REPORTER_ASSERT(reporter, info == info2); | 649 REPORTER_ASSERT(reporter, info == info2); |
| 650 REPORTER_ASSERT(reporter, minRowBytes == rowBytes); | 650 REPORTER_ASSERT(reporter, minRowBytes == rowBytes); |
| 651 for (int y = 0; y < info.height(); ++y) { | 651 for (int y = 0; y < info.height(); ++y) { |
| 652 for (int x = 0; x < info.width(); ++x) { | 652 for (int x = 0; x < info.width(); ++x) { |
| 653 REPORTER_ASSERT(reporter, 0 == addr[x]); | 653 REPORTER_ASSERT(reporter, 0 == addr[x]); |
| 654 } | 654 } |
| 655 addr = (const SkPMColor*)((const char*)addr + rowBytes); | 655 addr = (const SkPMColor*)((const char*)addr + rowBytes); |
| 656 } | 656 } |
| 657 SkDELETE(canvas); | 657 delete canvas; |
| 658 | 658 |
| 659 // now try a deliberately bad info | 659 // now try a deliberately bad info |
| 660 info = info.makeWH(-1, info.height()); | 660 info = info.makeWH(-1, info.height()); |
| 661 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); | 661 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); |
| 662 | 662 |
| 663 // too big | 663 // too big |
| 664 info = info.makeWH(1 << 30, 1 << 30); | 664 info = info.makeWH(1 << 30, 1 << 30); |
| 665 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); | 665 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); |
| 666 | 666 |
| 667 // not a valid pixel type | 667 // not a valid pixel type |
| 668 info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType()); | 668 info = SkImageInfo::Make(10, 10, kUnknown_SkColorType, info.alphaType()); |
| 669 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); | 669 REPORTER_ASSERT(reporter, NULL == SkCanvas::NewRasterDirect(info, baseAddr,
minRowBytes)); |
| 670 | 670 |
| 671 // We should succeed with a zero-sized valid info | 671 // We should succeed with a zero-sized valid info |
| 672 info = SkImageInfo::MakeN32Premul(0, 0); | 672 info = SkImageInfo::MakeN32Premul(0, 0); |
| 673 canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes); | 673 canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes); |
| 674 REPORTER_ASSERT(reporter, canvas); | 674 REPORTER_ASSERT(reporter, canvas); |
| 675 SkDELETE(canvas); | 675 delete canvas; |
| 676 } | 676 } |
| 677 | 677 |
| 678 DEF_TEST(Canvas, reporter) { | 678 DEF_TEST(Canvas, reporter) { |
| 679 TestData d; | 679 TestData d; |
| 680 | 680 |
| 681 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { | 681 for (int testStep = 0; testStep < testStepArray().count(); testStep++) { |
| 682 TestOverrideStateConsistency(reporter, d, testStepArray()[testStep]); | 682 TestOverrideStateConsistency(reporter, d, testStepArray()[testStep]); |
| 683 if (testStepArray()[testStep]->enablePdfTesting()) { | 683 if (testStepArray()[testStep]->enablePdfTesting()) { |
| 684 TestPdfDevice(reporter, d, testStepArray()[testStep]); | 684 TestPdfDevice(reporter, d, testStepArray()[testStep]); |
| 685 } | 685 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); | 749 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
| 750 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); | 750 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
| 751 REPORTER_ASSERT(reporter, clip1 == clip2); | 751 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 752 | 752 |
| 753 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); | 753 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); |
| 754 filterCanvas.scale(0.75f, 0.5f); | 754 filterCanvas.scale(0.75f, 0.5f); |
| 755 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); | 755 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa
trix()); |
| 756 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); | 756 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl
ipBounds(&clip2)); |
| 757 REPORTER_ASSERT(reporter, clip1 == clip2); | 757 REPORTER_ASSERT(reporter, clip1 == clip2); |
| 758 } | 758 } |
| OLD | NEW |