OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkAutoPixmapStorage.h" | 10 #include "SkAutoPixmapStorage.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 struct NullWStream : public SkWStream { | 23 struct NullWStream : public SkWStream { |
24 NullWStream() : fN(0) {} | 24 NullWStream() : fN(0) {} |
25 bool write(const void*, size_t n) override { fN += n; return true; } | 25 bool write(const void*, size_t n) override { fN += n; return true; } |
26 size_t bytesWritten() const override { return fN; } | 26 size_t bytesWritten() const override { return fN; } |
27 size_t fN; | 27 size_t fN; |
28 }; | 28 }; |
29 | 29 |
30 static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) { | 30 static void test_pdf_object_serialization(const sk_sp<SkPDFObject> object) { |
31 // SkDebugWStream wStream; | 31 // SkDebugWStream wStream; |
32 NullWStream wStream; | 32 NullWStream wStream; |
33 SkPDFSubstituteMap substitutes; | |
34 SkPDFObjNumMap objNumMap; | 33 SkPDFObjNumMap objNumMap; |
35 objNumMap.addObjectRecursively(object.get(), substitutes); | 34 objNumMap.addObjectRecursively(object.get()); |
36 for (int i = 0; i < objNumMap.objects().count(); ++i) { | 35 for (int i = 0; i < objNumMap.objects().count(); ++i) { |
37 SkPDFObject* object = objNumMap.objects()[i].get(); | 36 SkPDFObject* object = objNumMap.objects()[i].get(); |
38 wStream.writeDecAsText(i + 1); | 37 wStream.writeDecAsText(i + 1); |
39 wStream.writeText(" 0 obj\n"); | 38 wStream.writeText(" 0 obj\n"); |
40 object->emitObject(&wStream, objNumMap, substitutes); | 39 object->emitObject(&wStream, objNumMap); |
41 wStream.writeText("\nendobj\n"); | 40 wStream.writeText("\nendobj\n"); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 class PDFImageBench : public Benchmark { | 44 class PDFImageBench : public Benchmark { |
46 public: | 45 public: |
47 PDFImageBench() {} | 46 PDFImageBench() {} |
48 virtual ~PDFImageBench() {} | 47 virtual ~PDFImageBench() {} |
49 | 48 |
50 protected: | 49 protected: |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 244 |
246 } // namespace | 245 } // namespace |
247 DEF_BENCH(return new PDFImageBench;) | 246 DEF_BENCH(return new PDFImageBench;) |
248 DEF_BENCH(return new PDFJpegImageBench;) | 247 DEF_BENCH(return new PDFJpegImageBench;) |
249 DEF_BENCH(return new PDFCompressionBench;) | 248 DEF_BENCH(return new PDFCompressionBench;) |
250 DEF_BENCH(return new PDFScalarBench;) | 249 DEF_BENCH(return new PDFScalarBench;) |
251 DEF_BENCH(return new PDFColorComponentBench;) | 250 DEF_BENCH(return new PDFColorComponentBench;) |
252 DEF_BENCH(return new PDFShaderBench;) | 251 DEF_BENCH(return new PDFShaderBench;) |
253 DEF_BENCH(return new WStreamWriteTextBenchmark;) | 252 DEF_BENCH(return new WStreamWriteTextBenchmark;) |
254 DEF_BENCH(return new WritePDFTextBenchmark;) | 253 DEF_BENCH(return new WritePDFTextBenchmark;) |
OLD | NEW |