| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 stub->insert("Value", int33.get()); | 221 stub->insert("Value", int33.get()); |
| 222 stubResource->insert("InnerValue", int44.get()); | 222 stubResource->insert("InnerValue", int44.get()); |
| 223 stub->addResource(stubResource.get()); | 223 stub->addResource(stubResource.get()); |
| 224 | 224 |
| 225 SkPDFCatalog catalog((SkPDFDocument::Flags)0); | 225 SkPDFCatalog catalog((SkPDFDocument::Flags)0); |
| 226 catalog.addObject(proxy.get(), false); | 226 catalog.addObject(proxy.get(), false); |
| 227 catalog.setSubstitute(proxy.get(), stub.get()); | 227 catalog.setSubstitute(proxy.get(), stub.get()); |
| 228 | 228 |
| 229 SkDynamicMemoryWStream buffer; | 229 SkDynamicMemoryWStream buffer; |
| 230 proxy->emit(&buffer, &catalog, false); | 230 proxy->emit(&buffer, &catalog, false); |
| 231 catalog.emitSubstituteResources(&buffer, false); | 231 SkTSet<SkPDFObject*>* substituteResources = |
| 232 catalog.getSubstituteList(false); |
| 233 for (int i = 0; i < substituteResources->count(); ++i) { |
| 234 (*substituteResources)[i]->emit(&buffer, &catalog, true); |
| 235 } |
| 232 | 236 |
| 233 char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n"; | 237 char objectResult[] = "2 0 obj\n<</Value 33\n>>\nendobj\n"; |
| 234 REPORTER_ASSERT( | 238 catalog.setFileOffset(proxy.get(), 0); |
| 235 reporter, | 239 |
| 236 catalog.setFileOffset(proxy.get(), 0) == strlen(objectResult)); | 240 size_t outputSize = catalog.getSubstituteObject(proxy.get()) |
| 241 ->getOutputSize(&catalog, true); |
| 242 REPORTER_ASSERT(reporter, outputSize == strlen(objectResult)); |
| 237 | 243 |
| 238 char expectedResult[] = | 244 char expectedResult[] = |
| 239 "<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n"; | 245 "<</Value 33\n>>1 0 obj\n<</InnerValue 44\n>>\nendobj\n"; |
| 240 REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); | 246 REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); |
| 241 REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, | 247 REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, |
| 242 buffer.getOffset())); | 248 buffer.getOffset())); |
| 243 } | 249 } |
| 244 | 250 |
| 245 // Create a bitmap that would be very eficiently compressed in a ZIP. | 251 // Create a bitmap that would be very eficiently compressed in a ZIP. |
| 246 static void setup_bitmap(SkBitmap* bitmap, int width, int height) { | 252 static void setup_bitmap(SkBitmap* bitmap, int width, int height) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 482 |
| 477 // Filter just created; should be unvisited. | 483 // Filter just created; should be unvisited. |
| 478 REPORTER_ASSERT(reporter, !filter->visited()); | 484 REPORTER_ASSERT(reporter, !filter->visited()); |
| 479 SkPaint paint; | 485 SkPaint paint; |
| 480 paint.setImageFilter(filter.get()); | 486 paint.setImageFilter(filter.get()); |
| 481 canvas.drawRect(SkRect::MakeWH(100, 100), paint); | 487 canvas.drawRect(SkRect::MakeWH(100, 100), paint); |
| 482 | 488 |
| 483 // Filter was used in rendering; should be visited. | 489 // Filter was used in rendering; should be visited. |
| 484 REPORTER_ASSERT(reporter, filter->visited()); | 490 REPORTER_ASSERT(reporter, filter->visited()); |
| 485 } | 491 } |
| OLD | NEW |