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" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 assert_emit_eq(reporter, | 93 assert_emit_eq(reporter, |
94 *stream, | 94 *stream, |
95 "<</Length 12\n/Attribute 42>> stream\n" | 95 "<</Length 12\n/Attribute 42>> stream\n" |
96 "Test\nFoo\tBar\nendstream"); | 96 "Test\nFoo\tBar\nendstream"); |
97 | 97 |
98 { | 98 { |
99 char streamBytes2[] = "This is a longer string, so that compression " | 99 char streamBytes2[] = "This is a longer string, so that compression " |
100 "can do something with it. With shorter strings, " | 100 "can do something with it. With shorter strings, " |
101 "the short circuit logic cuts in and we end up " | 101 "the short circuit logic cuts in and we end up " |
102 "with an uncompressed string."; | 102 "with an uncompressed string."; |
103 SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2, | 103 auto stream = sk_make_sp<SkPDFStream>( |
104 strlen(streamBytes2))); | 104 SkData::MakeWithCopy(streamBytes2, strlen(streamBytes2))); |
105 sk_sp<SkPDFStream> stream(new SkPDFStream(streamData2.get())); | |
106 | 105 |
107 SkDynamicMemoryWStream compressedByteStream; | 106 SkDynamicMemoryWStream compressedByteStream; |
108 SkDeflateWStream deflateWStream(&compressedByteStream); | 107 SkDeflateWStream deflateWStream(&compressedByteStream); |
109 deflateWStream.write(streamBytes2, strlen(streamBytes2)); | 108 deflateWStream.write(streamBytes2, strlen(streamBytes2)); |
110 deflateWStream.finalize(); | 109 deflateWStream.finalize(); |
111 | 110 |
112 SkDynamicMemoryWStream expected; | 111 SkDynamicMemoryWStream expected; |
113 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n"); | 112 expected.writeText("<</Filter /FlateDecode\n/Length 116>> stream\n"); |
114 compressedByteStream.writeToStream(&expected); | 113 compressedByteStream.writeToStream(&expected); |
115 compressedByteStream.reset(); | 114 compressedByteStream.reset(); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 char buffer[5]; | 500 char buffer[5]; |
502 for (int i = 0; i < 256; ++i) { | 501 for (int i = 0; i < 256; ++i) { |
503 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); | 502 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); |
504 REPORTER_ASSERT(reporter, len == strlen(buffer)); | 503 REPORTER_ASSERT(reporter, len == strlen(buffer)); |
505 float f; | 504 float f; |
506 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); | 505 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); |
507 int roundTrip = (int)(0.5 + f * 255); | 506 int roundTrip = (int)(0.5 + f * 255); |
508 REPORTER_ASSERT(reporter, roundTrip == i); | 507 REPORTER_ASSERT(reporter, roundTrip == i); |
509 } | 508 } |
510 } | 509 } |
OLD | NEW |