| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkPDFCatalog_DEFINED | 10 #ifndef SkPDFCatalog_DEFINED |
| 11 #define SkPDFCatalog_DEFINED | 11 #define SkPDFCatalog_DEFINED |
| 12 | 12 |
| 13 #include <sys/types.h> | 13 #include <sys/types.h> |
| 14 | 14 |
| 15 #include "SkPDFDocument.h" | 15 #include "SkPDFDocument.h" |
| 16 #include "SkPDFTypes.h" | 16 #include "SkPDFTypes.h" |
| 17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
| 18 #include "SkTDArray.h" | 18 #include "SkTDArray.h" |
| 19 | 19 |
| 20 /** \class SkPDFCatalog | 20 /** \class SkPDFCatalog |
| 21 | 21 |
| 22 The PDF catalog manages object numbers and file offsets. It is used | 22 The PDF catalog manages object numbers and file offsets. It is used |
| 23 to create the PDF cross reference table. | 23 to create the PDF cross reference table. |
| 24 */ | 24 */ |
| 25 class SkPDFCatalog { | 25 class SkPDFCatalog { |
| 26 public: | 26 public: |
| 27 /** Create a PDF catalog. | 27 /** Create a PDF catalog. |
| 28 */ | 28 */ |
| 29 explicit SkPDFCatalog(SkPDFDocument::Flags flags); | 29 SkPDFCatalog(); |
| 30 ~SkPDFCatalog(); | 30 ~SkPDFCatalog(); |
| 31 | 31 |
| 32 /** Add the passed object to the catalog. Refs obj. | 32 /** Add the passed object to the catalog. Refs obj. |
| 33 * @param obj The object to add. | 33 * @param obj The object to add. |
| 34 * @param onFirstPage Is the object on the first page. | 34 * @param onFirstPage Is the object on the first page. |
| 35 * @return The obj argument is returned. | 35 * @return The obj argument is returned. |
| 36 */ | 36 */ |
| 37 SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage); | 37 SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage); |
| 38 | 38 |
| 39 /** Inform the catalog of the object's position in the final stream. | 39 /** Inform the catalog of the object's position in the final stream. |
| 40 * The object should already have been added to the catalog. | 40 * The object should already have been added to the catalog. |
| 41 * @param obj The object to add. | 41 * @param obj The object to add. |
| 42 * @param offset The byte offset in the output stream of this object. | 42 * @param offset The byte offset in the output stream of this object. |
| 43 */ | 43 */ |
| 44 void setFileOffset(SkPDFObject* obj, off_t offset); | 44 void setFileOffset(SkPDFObject* obj, off_t offset); |
| 45 | 45 |
| 46 /** Get the object number for the passed object. | 46 /** Get the object number for the passed object. |
| 47 * @param obj The object of interest. | 47 * @param obj The object of interest. |
| 48 */ | 48 */ |
| 49 int32_t getObjectNumber(SkPDFObject* obj); | 49 int32_t getObjectNumber(SkPDFObject* obj); |
| 50 | 50 |
| 51 /** Return the document flags in effect for this catalog/document. | |
| 52 */ | |
| 53 SkPDFDocument::Flags getDocumentFlags() const { return fDocumentFlags; } | |
| 54 | |
| 55 /** Output the cross reference table for objects in the catalog. | 51 /** Output the cross reference table for objects in the catalog. |
| 56 * Returns the total number of objects. | 52 * Returns the total number of objects. |
| 57 * @param stream The writable output stream to send the output to. | 53 * @param stream The writable output stream to send the output to. |
| 58 * @param firstPage If true, include first page objects only, otherwise | 54 * @param firstPage If true, include first page objects only, otherwise |
| 59 * include all objects not on the first page. | 55 * include all objects not on the first page. |
| 60 */ | 56 */ |
| 61 int32_t emitXrefTable(SkWStream* stream, bool firstPage); | 57 int32_t emitXrefTable(SkWStream* stream, bool firstPage); |
| 62 | 58 |
| 63 /** Set substitute object for the passed object. | 59 /** Set substitute object for the passed object. |
| 64 */ | 60 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 SkTSet<SkPDFObject*> fSubstituteResourcesFirstPage; | 95 SkTSet<SkPDFObject*> fSubstituteResourcesFirstPage; |
| 100 SkTSet<SkPDFObject*> fSubstituteResourcesRemaining; | 96 SkTSet<SkPDFObject*> fSubstituteResourcesRemaining; |
| 101 | 97 |
| 102 // Number of objects on the first page. | 98 // Number of objects on the first page. |
| 103 uint32_t fFirstPageCount; | 99 uint32_t fFirstPageCount; |
| 104 // Next object number to assign (on page > 1). | 100 // Next object number to assign (on page > 1). |
| 105 uint32_t fNextObjNum; | 101 uint32_t fNextObjNum; |
| 106 // Next object number to assign on the first page. | 102 // Next object number to assign on the first page. |
| 107 uint32_t fNextFirstPageObjNum; | 103 uint32_t fNextFirstPageObjNum; |
| 108 | 104 |
| 109 SkPDFDocument::Flags fDocumentFlags; | |
| 110 | |
| 111 int findObjectIndex(SkPDFObject* obj); | 105 int findObjectIndex(SkPDFObject* obj); |
| 112 | 106 |
| 113 int assignObjNum(SkPDFObject* obj); | 107 int assignObjNum(SkPDFObject* obj); |
| 114 }; | 108 }; |
| 115 | 109 |
| 116 #endif | 110 #endif |
| OLD | NEW |