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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 streamBytes, strlen(streamBytes), true)); | 107 streamBytes, strlen(streamBytes), true)); |
108 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData.get())); | 108 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData.get())); |
109 SimpleCheckObjectOutput( | 109 SimpleCheckObjectOutput( |
110 reporter, stream.get(), | 110 reporter, stream.get(), |
111 "<</Length 12\n>> stream\nTest\nFoo\tBar\nendstream"); | 111 "<</Length 12\n>> stream\nTest\nFoo\tBar\nendstream"); |
112 stream->insert("Attribute", new SkPDFInt(42))->unref(); | 112 stream->insert("Attribute", new SkPDFInt(42))->unref(); |
113 SimpleCheckObjectOutput(reporter, stream.get(), | 113 SimpleCheckObjectOutput(reporter, stream.get(), |
114 "<</Length 12\n/Attribute 42\n>> stream\n" | 114 "<</Length 12\n/Attribute 42\n>> stream\n" |
115 "Test\nFoo\tBar\nendstream"); | 115 "Test\nFoo\tBar\nendstream"); |
116 | 116 |
117 #ifndef SK_NO_FLATE | |
118 { | 117 { |
119 char streamBytes2[] = "This is a longer string, so that compression " | 118 char streamBytes2[] = "This is a longer string, so that compression " |
120 "can do something with it. With shorter strings, " | 119 "can do something with it. With shorter strings, " |
121 "the short circuit logic cuts in and we end up " | 120 "the short circuit logic cuts in and we end up " |
122 "with an uncompressed string."; | 121 "with an uncompressed string."; |
123 SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2, | 122 SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2, |
124 strlen(streamBytes2))); | 123 strlen(streamBytes2))); |
125 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get())); | 124 SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get())); |
126 | 125 |
127 SkDynamicMemoryWStream compressedByteStream; | 126 SkDynamicMemoryWStream compressedByteStream; |
128 SkFlate::Deflate(streamData2.get(), &compressedByteStream); | 127 SkFlate::Deflate(streamData2.get(), &compressedByteStream); |
129 SkAutoDataUnref compressedData(compressedByteStream.copyToData()); | 128 SkAutoDataUnref compressedData(compressedByteStream.copyToData()); |
130 | 129 |
131 SkDynamicMemoryWStream expected; | 130 SkDynamicMemoryWStream expected; |
132 expected.writeText("<</Filter /FlateDecode\n/Length 116\n" | 131 expected.writeText("<</Filter /FlateDecode\n/Length 116\n" |
133 ">> stream\n"); | 132 ">> stream\n"); |
134 expected.write(compressedData->data(), compressedData->size()); | 133 expected.write(compressedData->data(), compressedData->size()); |
135 expected.writeText("\nendstream"); | 134 expected.writeText("\nendstream"); |
136 SkAutoDataUnref expectedResultData2(expected.copyToData()); | 135 SkAutoDataUnref expectedResultData2(expected.copyToData()); |
137 CheckObjectOutput(reporter, stream.get(), | 136 CheckObjectOutput(reporter, stream.get(), |
138 (const char*) expectedResultData2->data(), | 137 (const char*) expectedResultData2->data(), |
139 expectedResultData2->size(), true); | 138 expectedResultData2->size(), true); |
140 } | 139 } |
141 #endif // SK_NO_FLATE | |
142 } | 140 } |
143 | 141 |
144 static void TestCatalog(skiatest::Reporter* reporter) { | 142 static void TestCatalog(skiatest::Reporter* reporter) { |
145 SkPDFCatalog catalog; | 143 SkPDFCatalog catalog; |
146 SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); | 144 SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); |
147 SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); | 145 SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); |
148 SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3)); | 146 SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3)); |
149 int1.get()->ref(); | 147 int1.get()->ref(); |
150 SkAutoTUnref<SkPDFInt> int1Again(int1.get()); | 148 SkAutoTUnref<SkPDFInt> int1Again(int1.get()); |
151 | 149 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // Filter just created; should be unvisited. | 339 // Filter just created; should be unvisited. |
342 REPORTER_ASSERT(reporter, !filter->visited()); | 340 REPORTER_ASSERT(reporter, !filter->visited()); |
343 SkPaint paint; | 341 SkPaint paint; |
344 paint.setImageFilter(filter.get()); | 342 paint.setImageFilter(filter.get()); |
345 canvas->drawRect(SkRect::MakeWH(100, 100), paint); | 343 canvas->drawRect(SkRect::MakeWH(100, 100), paint); |
346 doc->close(); | 344 doc->close(); |
347 | 345 |
348 // Filter was used in rendering; should be visited. | 346 // Filter was used in rendering; should be visited. |
349 REPORTER_ASSERT(reporter, filter->visited()); | 347 REPORTER_ASSERT(reporter, filter->visited()); |
350 } | 348 } |
OLD | NEW |