OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkDocument.h" | 12 #include "SkDocument.h" |
13 #include "SkDeflate.h" | 13 #include "SkDeflate.h" |
14 #include "SkImageEncoder.h" | 14 #include "SkImageEncoder.h" |
| 15 #include "SkMakeUnique.h" |
15 #include "SkMatrix.h" | 16 #include "SkMatrix.h" |
16 #include "SkPDFCanon.h" | 17 #include "SkPDFCanon.h" |
17 #include "SkPDFDevice.h" | 18 #include "SkPDFDevice.h" |
18 #include "SkPDFFont.h" | 19 #include "SkPDFFont.h" |
19 #include "SkPDFTypes.h" | 20 #include "SkPDFTypes.h" |
20 #include "SkPDFUtils.h" | 21 #include "SkPDFUtils.h" |
21 #include "SkReadBuffer.h" | 22 #include "SkReadBuffer.h" |
22 #include "SkScalar.h" | 23 #include "SkScalar.h" |
23 #include "SkSpecialImage.h" | 24 #include "SkSpecialImage.h" |
24 #include "SkStream.h" | 25 #include "SkStream.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 template <typename T> | 69 template <typename T> |
69 static void assert_emit_eq(skiatest::Reporter* reporter, | 70 static void assert_emit_eq(skiatest::Reporter* reporter, |
70 T& object, | 71 T& object, |
71 const char* string) { | 72 const char* string) { |
72 SkString result = emit_to_string(object); | 73 SkString result = emit_to_string(object); |
73 assert_eq(reporter, result, string); | 74 assert_eq(reporter, result, string); |
74 } | 75 } |
75 | 76 |
76 static void TestPDFStream(skiatest::Reporter* reporter) { | 77 static void TestPDFStream(skiatest::Reporter* reporter) { |
77 char streamBytes[] = "Test\nFoo\tBar"; | 78 char streamBytes[] = "Test\nFoo\tBar"; |
78 std::unique_ptr<SkStreamAsset> streamData(new SkMemoryStream( | 79 auto streamData = skstd::make_unique<SkMemoryStream>( |
79 streamBytes, strlen(streamBytes), true)); | 80 streamBytes, strlen(streamBytes), true); |
80 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData)); | 81 auto stream = sk_make_sp<SkPDFStream>(std::move(streamData)); |
81 assert_emit_eq(reporter, | 82 assert_emit_eq(reporter, |
82 *stream, | 83 *stream, |
83 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); | 84 "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); |
84 stream->dict()->insertInt("Attribute", 42); | 85 stream->dict()->insertInt("Attribute", 42); |
85 assert_emit_eq(reporter, | 86 assert_emit_eq(reporter, |
86 *stream, | 87 *stream, |
87 "<</Length 12\n/Attribute 42>> stream\n" | 88 "<</Length 12\n/Attribute 42>> stream\n" |
88 "Test\nFoo\tBar\nendstream"); | 89 "Test\nFoo\tBar\nendstream"); |
89 | 90 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 char buffer[5]; | 478 char buffer[5]; |
478 for (int i = 0; i < 256; ++i) { | 479 for (int i = 0; i < 256; ++i) { |
479 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); | 480 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); |
480 REPORTER_ASSERT(reporter, len == strlen(buffer)); | 481 REPORTER_ASSERT(reporter, len == strlen(buffer)); |
481 float f; | 482 float f; |
482 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); | 483 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); |
483 int roundTrip = (int)(0.5 + f * 255); | 484 int roundTrip = (int)(0.5 + f * 255); |
484 REPORTER_ASSERT(reporter, roundTrip == i); | 485 REPORTER_ASSERT(reporter, roundTrip == i); |
485 } | 486 } |
486 } | 487 } |
OLD | NEW |