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

Unified Diff: src/pdf/SkPDFCatalog.h

Issue 1033543002: SKPDF: refactor pdfcatalog and pdfdocument (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-25 (Wednesday) 14:17:42 EDT Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFCatalog.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCatalog.h
diff --git a/src/pdf/SkPDFCatalog.h b/src/pdf/SkPDFCatalog.h
index 1bdac936d47c57cdf1112bfbcf22d447ba8c198c..54d08c5e24646c25f8d64067e733d6189f72f5de 100644
--- a/src/pdf/SkPDFCatalog.h
+++ b/src/pdf/SkPDFCatalog.h
@@ -10,99 +10,44 @@
#ifndef SkPDFCatalog_DEFINED
#define SkPDFCatalog_DEFINED
-#include <sys/types.h>
-
#include "SkPDFTypes.h"
#include "SkTDArray.h"
+#include "SkTHash.h"
/** \class SkPDFCatalog
- The PDF catalog manages object numbers and file offsets. It is used
+ The PDF catalog manages object numbers. It is used
to create the PDF cross reference table.
*/
class SkPDFCatalog {
public:
- /** Create a PDF catalog.
- */
SkPDFCatalog();
~SkPDFCatalog();
- /** Add the passed object to the catalog. Refs obj.
+ /** Add the passed object to the catalog.
* @param obj The object to add.
- * @param onFirstPage Is the object on the first page.
- * @return The obj argument is returned.
+ * @return True iff the object was not already added to the catalog.
*/
- SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage);
-
- /** Inform the catalog of the object's position in the final stream.
- * The object should already have been added to the catalog.
- * @param obj The object to add.
- * @param offset The byte offset in the output stream of this object.
- */
- void setFileOffset(SkPDFObject* obj, off_t offset);
+ bool addObject(SkPDFObject* obj);
/** Get the object number for the passed object.
* @param obj The object of interest.
*/
- int32_t getObjectNumber(SkPDFObject* obj);
-
- /** Output the cross reference table for objects in the catalog.
- * Returns the total number of objects.
- * @param stream The writable output stream to send the output to.
- * @param firstPage If true, include first page objects only, otherwise
- * include all objects not on the first page.
- */
- int32_t emitXrefTable(SkWStream* stream, bool firstPage);
+ int32_t getObjectNumber(SkPDFObject* obj) const;
/** Set substitute object for the passed object.
+ Refs substitute.
*/
void setSubstitute(SkPDFObject* original, SkPDFObject* substitute);
/** Find and return any substitute object set for the passed object. If
* there is none, return the passed object.
*/
- SkPDFObject* getSubstituteObject(SkPDFObject* object);
+ SkPDFObject* getSubstituteObject(SkPDFObject* object) const;
private:
- struct Rec {
- Rec(SkPDFObject* object, bool onFirstPage)
- : fObject(object),
- fFileOffset(0),
- fObjNumAssigned(false),
- fOnFirstPage(onFirstPage) {
- }
- SkPDFObject* fObject;
- off_t fFileOffset;
- bool fObjNumAssigned;
- bool fOnFirstPage;
- };
-
- struct SubstituteMapping {
- SubstituteMapping(SkPDFObject* original, SkPDFObject* substitute)
- : fOriginal(original), fSubstitute(substitute) {
- }
- SkPDFObject* fOriginal;
- SkPDFObject* fSubstitute;
- };
-
- // TODO(vandebo): Make this a hash if it's a performance problem.
- SkTDArray<Rec> fCatalog;
-
- // TODO(arthurhsu): Make this a hash if it's a performance problem.
- SkTDArray<SubstituteMapping> fSubstituteMap;
- SkTSet<SkPDFObject*> fSubstituteResourcesFirstPage;
- SkTSet<SkPDFObject*> fSubstituteResourcesRemaining;
-
- // Number of objects on the first page.
- uint32_t fFirstPageCount;
- // Next object number to assign (on page > 1).
- uint32_t fNextObjNum;
- // Next object number to assign on the first page.
- uint32_t fNextFirstPageObjNum;
-
- int findObjectIndex(SkPDFObject* obj);
-
- int assignObjNum(SkPDFObject* obj);
+ SkTHashMap<SkPDFObject*, int32_t> fObjectNumbers;
+ SkTHashMap<SkPDFObject*, SkPDFObject*> fSubstituteMap;
};
#endif
« no previous file with comments | « no previous file | src/pdf/SkPDFCatalog.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698