Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 846023003: In SkPDFDocument::emitPDF(), stop pre-calculating file offsets. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit: space between functions Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFTypes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698