diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-22 20:45:15 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-22 20:45:15 +0000 |
commit | 7d6c8f997f8fe2c222f9d6d31f984c2e7cf16cc5 (patch) | |
tree | 95d8dc5cf623018c83ef2154f10b618c8990b4a0 | |
parent | 7c9594259bbf007bf6dab857544586f2327ea66e (diff) |
[PDF] Move most of the headers to be private.
Compute font stats in SkPDFDocument in order to make more of the headers private.
Previous review: https://codereview.appspot.com/5868049/
Review URL: https://codereview.appspot.com/5875049
git-svn-id: http://skia.googlecode.com/svn/trunk@3470 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gyp/pdf.gyp | 20 | ||||
-rw-r--r-- | gyp/tests.gyp | 1 | ||||
-rw-r--r-- | include/pdf/SkPDFDocument.h | 11 | ||||
-rw-r--r-- | src/pdf/SkPDFCatalog.h (renamed from include/pdf/SkPDFCatalog.h) | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFDocument.cpp | 22 | ||||
-rw-r--r-- | src/pdf/SkPDFFont.h (renamed from include/pdf/SkPDFFont.h) | 18 | ||||
-rw-r--r-- | src/pdf/SkPDFFormXObject.h (renamed from include/pdf/SkPDFFormXObject.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFGraphicState.h (renamed from include/pdf/SkPDFGraphicState.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFImage.h (renamed from include/pdf/SkPDFImage.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFPage.h (renamed from include/pdf/SkPDFPage.h) | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFShader.h (renamed from include/pdf/SkPDFShader.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFStream.h (renamed from include/pdf/SkPDFStream.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.h (renamed from include/pdf/SkPDFTypes.h) | 0 | ||||
-rw-r--r-- | src/pdf/SkPDFUtils.h (renamed from include/pdf/SkPDFUtils.h) | 0 |
14 files changed, 48 insertions, 28 deletions
diff --git a/gyp/pdf.gyp b/gyp/pdf.gyp index bb42f00d30..e7b0369a47 100644 --- a/gyp/pdf.gyp +++ b/gyp/pdf.gyp @@ -17,32 +17,32 @@ '../src/utils', # needed to get SkBitSet.h ], 'sources': [ - '../include/pdf/SkPDFCatalog.h', '../include/pdf/SkPDFDevice.h', '../include/pdf/SkPDFDocument.h', - '../include/pdf/SkPDFFont.h', - '../include/pdf/SkPDFFormXObject.h', - '../include/pdf/SkPDFGraphicState.h', - '../include/pdf/SkPDFImage.h', - '../include/pdf/SkPDFPage.h', - '../include/pdf/SkPDFShader.h', - '../include/pdf/SkPDFStream.h', - '../include/pdf/SkPDFTypes.h', - '../include/pdf/SkPDFUtils.h', '../src/pdf/SkPDFCatalog.cpp', + '../src/pdf/SkPDFCatalog.h', '../src/pdf/SkPDFDevice.cpp', '../src/pdf/SkPDFDocument.cpp', '../src/pdf/SkPDFFont.cpp', + '../src/pdf/SkPDFFont.h', '../src/pdf/SkPDFFontImpl.h', '../src/pdf/SkPDFFormXObject.cpp', + '../src/pdf/SkPDFFormXObject.h', '../src/pdf/SkPDFGraphicState.cpp', + '../src/pdf/SkPDFGraphicState.h', '../src/pdf/SkPDFImage.cpp', + '../src/pdf/SkPDFImage.h', '../src/pdf/SkPDFPage.cpp', + '../src/pdf/SkPDFPage.h', '../src/pdf/SkPDFShader.cpp', + '../src/pdf/SkPDFShader.h', '../src/pdf/SkPDFStream.cpp', + '../src/pdf/SkPDFStream.h', '../src/pdf/SkPDFTypes.cpp', + '../src/pdf/SkPDFTypes.h', '../src/pdf/SkPDFUtils.cpp', + '../src/pdf/SkPDFUtils.h', ], # This section makes all targets that depend on this target # #define SK_SUPPORT_PDF and have access to the pdf header files. diff --git a/gyp/tests.gyp b/gyp/tests.gyp index 541db7f556..a3a8002881 100644 --- a/gyp/tests.gyp +++ b/gyp/tests.gyp @@ -11,6 +11,7 @@ '../src/core', '../src/effects', '../src/gpu', + '../src/pdf', '../src/utils', ], 'sources': [ diff --git a/include/pdf/SkPDFDocument.h b/include/pdf/SkPDFDocument.h index c1c6fb4c64..1a4a51fa43 100644 --- a/include/pdf/SkPDFDocument.h +++ b/include/pdf/SkPDFDocument.h @@ -10,15 +10,17 @@ #ifndef SkPDFDocument_DEFINED #define SkPDFDocument_DEFINED -#include "SkPDFTypes.h" +#include "SkAdvancedTypefaceMetrics.h" #include "SkRefCnt.h" #include "SkTDArray.h" #include "SkTScopedPtr.h" class SkPDFCatalog; class SkPDFDevice; +class SkPDFDict; class SkPDFPage; -class SkWSteam; +class SkPDFObject; +class SkWStream; /** \class SkPDFDocument @@ -62,9 +64,10 @@ public: */ SK_API bool appendPage(SkPDFDevice* pdfDevice); - /** Get the list of pages in this document. + /** Get the count of unique font types used in the document. */ - SK_API const SkTDArray<SkPDFPage*>& getPages(); + SK_API void getCountOfFontTypes( + int counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1]) const; private: SkTScopedPtr<SkPDFCatalog> fCatalog; diff --git a/include/pdf/SkPDFCatalog.h b/src/pdf/SkPDFCatalog.h index 68a244fab0..44005c6784 100644 --- a/include/pdf/SkPDFCatalog.h +++ b/src/pdf/SkPDFCatalog.h @@ -22,7 +22,7 @@ The PDF catalog manages object numbers and file offsets. It is used to create the PDF cross reference table. */ -class SK_API SkPDFCatalog { +class SkPDFCatalog { public: /** Create a PDF catalog. */ diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index cb87d8fc74..3ec4877b98 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -10,8 +10,9 @@ #include "SkPDFCatalog.h" #include "SkPDFDevice.h" #include "SkPDFDocument.h" -#include "SkPDFPage.h" #include "SkPDFFont.h" +#include "SkPDFPage.h" +#include "SkPDFTypes.h" #include "SkStream.h" // Add the resources, starting at firstIndex to the catalog, removing any dupes. @@ -222,8 +223,23 @@ bool SkPDFDocument::appendPage(SkPDFDevice* pdfDevice) { return true; } -const SkTDArray<SkPDFPage*>& SkPDFDocument::getPages() { - return fPages; +void SkPDFDocument::getCountOfFontTypes( + int counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1]) const { + memset(counts, 0, + sizeof(int)* SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1); + SkTDArray<SkFontID> seenFonts; + + for (int pageNumber = 0; pageNumber < fPages.count(); pageNumber++) { + const SkTDArray<SkPDFFont*>& fontResources = + fPages[pageNumber]->getFontResources(); + for (int font = 0; font < fontResources.count(); font++) { + SkFontID fontID = fontResources[font]->typeface()->uniqueID(); + if (seenFonts.find(fontID) == -1) { + counts[fontResources[font]->getType()]++; + seenFonts.push(fontID); + } + } + } } void SkPDFDocument::emitHeader(SkWStream* stream) { diff --git a/include/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h index 2ebdec73da..f463ed740a 100644 --- a/include/pdf/SkPDFFont.h +++ b/src/pdf/SkPDFFont.h @@ -79,27 +79,27 @@ private: */ class SkPDFFont : public SkPDFDict { public: - SK_API virtual ~SkPDFFont(); + virtual ~SkPDFFont(); - SK_API virtual void getResources(SkTDArray<SkPDFObject*>* resourceList); + virtual void getResources(SkTDArray<SkPDFObject*>* resourceList); /** Returns the typeface represented by this class. Returns NULL for the * default typeface. */ - SK_API SkTypeface* typeface(); + SkTypeface* typeface(); /** Returns the font type represented in this font. For Type0 fonts, * returns the type of the decendant font. */ - SK_API virtual SkAdvancedTypefaceMetrics::FontType getType(); + virtual SkAdvancedTypefaceMetrics::FontType getType(); /** Returns true if this font encoding supports glyph IDs above 255. */ - SK_API virtual bool multiByteGlyphs() const = 0; + virtual bool multiByteGlyphs() const = 0; /** Return true if this font has an encoding for the passed glyph id. */ - SK_API bool hasGlyph(uint16_t glyphID); + bool hasGlyph(uint16_t glyphID); /** Convert (in place) the input glyph IDs into the font encoding. If the * font has more glyphs than can be encoded (like a type 1 font with more @@ -109,7 +109,7 @@ public: * @param numGlyphs The number of input glyphs. * @return Returns the number of glyphs consumed. */ - SK_API size_t glyphsToPDFFontEncoding(uint16_t* glyphIDs, size_t numGlyphs); + size_t glyphsToPDFFontEncoding(uint16_t* glyphIDs, size_t numGlyphs); /** Get the font resource for the passed typeface and glyphID. The * reference count of the object is incremented and it is the caller's @@ -119,7 +119,7 @@ public: * @param typeface The typeface to find. * @param glyphID Specify which section of a large font is of interest. */ - SK_API static SkPDFFont* GetFontResource(SkTypeface* typeface, + static SkPDFFont* GetFontResource(SkTypeface* typeface, uint16_t glyphID); /** Subset the font based on usage set. Returns a SkPDFFont instance with @@ -128,7 +128,7 @@ public: * @return NULL if font does not support subsetting, a new instance * of SkPDFFont otherwise. */ - SK_API virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); + virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); protected: // Common constructor to handle common members. diff --git a/include/pdf/SkPDFFormXObject.h b/src/pdf/SkPDFFormXObject.h index 0c49152a1b..0c49152a1b 100644 --- a/include/pdf/SkPDFFormXObject.h +++ b/src/pdf/SkPDFFormXObject.h diff --git a/include/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h index af01737276..af01737276 100644 --- a/include/pdf/SkPDFGraphicState.h +++ b/src/pdf/SkPDFGraphicState.h diff --git a/include/pdf/SkPDFImage.h b/src/pdf/SkPDFImage.h index 48b0157da9..48b0157da9 100644 --- a/include/pdf/SkPDFImage.h +++ b/src/pdf/SkPDFImage.h diff --git a/include/pdf/SkPDFPage.h b/src/pdf/SkPDFPage.h index e726638ebb..8ef909e573 100644 --- a/include/pdf/SkPDFPage.h +++ b/src/pdf/SkPDFPage.h @@ -82,7 +82,7 @@ public: /** Get the fonts used on this page. */ - SK_API const SkTDArray<SkPDFFont*>& getFontResources() const; + const SkTDArray<SkPDFFont*>& getFontResources() const; /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font * that shows on this page. diff --git a/include/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h index 439d83bbd5..439d83bbd5 100644 --- a/include/pdf/SkPDFShader.h +++ b/src/pdf/SkPDFShader.h diff --git a/include/pdf/SkPDFStream.h b/src/pdf/SkPDFStream.h index b3a7ad34e3..b3a7ad34e3 100644 --- a/include/pdf/SkPDFStream.h +++ b/src/pdf/SkPDFStream.h diff --git a/include/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h index 6334938d77..6334938d77 100644 --- a/include/pdf/SkPDFTypes.h +++ b/src/pdf/SkPDFTypes.h diff --git a/include/pdf/SkPDFUtils.h b/src/pdf/SkPDFUtils.h index 5b9d74e321..5b9d74e321 100644 --- a/include/pdf/SkPDFUtils.h +++ b/src/pdf/SkPDFUtils.h |