aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFDocument.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf/SkPDFDocument.h')
-rw-r--r--src/pdf/SkPDFDocument.h50
1 files changed, 36 insertions, 14 deletions
diff --git a/src/pdf/SkPDFDocument.h b/src/pdf/SkPDFDocument.h
index e4c0521cbe..fce9f9df83 100644
--- a/src/pdf/SkPDFDocument.h
+++ b/src/pdf/SkPDFDocument.h
@@ -29,34 +29,56 @@ template <typename T> class SkTSet;
*/
class SkPDFDocument {
public:
- SkPDFDocument();
- ~SkPDFDocument();
+ SkPDFDocument() {}
+ ~SkPDFDocument() { fPageDevices.unrefAll(); }
/** Output the PDF to the passed stream. It is an error to call this (it
- * will return false and not modify stream) if no pages have been added
- * or there are pages missing (i.e. page 1 and 3 have been added, but not
- * page 2).
+ * will return false and not modify stream) if pageDevices is empty.
+ * No device pointer can be NULL.
+ *
+ * @param pageDevices An array of pages, in order. All pages
+ * should be created using the same SkPDFCanon.
+ * TODO(halcanary): ASSERT this condition.
+ * @param SkWStream The writable output stream to send the PDF to.
+ */
+ static bool EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices, SkWStream*);
+
+ /** Output the PDF to the passed stream. It is an error to call this (it
+ * will return false and not modify stream) if no pages have been added.
*
* @param stream The writable output stream to send the PDF to.
*/
- bool emitPDF(SkWStream* stream);
+ bool emitPDF(SkWStream* stream) const {
+ return SkPDFDocument::EmitPDF(fPageDevices, stream);
+ }
- /** Append the passed pdf device to the document as a new page. Returns
- * true if successful. Will fail if the document has already been emitted.
+ /** Append the passed pdf device to the document as a new page.
*
- * @param pdfDevice The page to add to this document.
+ * @param pdfDevice The page to add to this document. All pages
+ * added to this document should be created
+ * using the same SkPDFCanon.
*/
- bool appendPage(SkPDFDevice* pdfDevice) {
+ void appendPage(SkPDFDevice* pdfDevice) {
fPageDevices.push(SkRef(pdfDevice));
- return true;
}
+ /** Get the count of unique font types used in the given pages.
+ */
+ static void GetCountOfFontTypes(
+ const SkTDArray<SkPDFDevice*>& pageDevices,
+ int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
+ int* notSubsettableCount,
+ int* notEmbedddableCount);
+
/** Get the count of unique font types used in the document.
*/
void getCountOfFontTypes(
- int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
- int* notSubsettableCount,
- int* notEmbedddableCount) const;
+ int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
+ int* notSubsettableCount,
+ int* notEmbedddableCount) const {
+ return SkPDFDocument::GetCountOfFontTypes(
+ fPageDevices, counts, notSubsettableCount, notEmbedddableCount);
+ }
private:
SkTDArray<SkPDFDevice*> fPageDevices;