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

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 1036853002: SkPDF: clean up skpdfdocument, add static functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« src/pdf/SkPDFDocument.h ('K') | « src/pdf/SkPDFDocument.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDocument.cpp
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 4009cef9b6210251de6738bec0f327ecf9223487..57eab950edb987bbe0c2649183b08c17920d8dbf 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -39,10 +39,6 @@ static void perform_font_subsetting(SkPDFCatalog* catalog,
}
}
-SkPDFDocument::SkPDFDocument() {}
-
-SkPDFDocument::~SkPDFDocument() { fPageDevices.unrefAll(); }
-
static void emit_pdf_header(SkWStream* stream) {
stream->writeText("%PDF-1.4\n%");
// The PDF spec recommends including a comment with four bytes, all
@@ -69,15 +65,16 @@ static void emit_pdf_footer(SkWStream* stream,
stream->writeText("\n%%EOF");
}
-bool SkPDFDocument::emitPDF(SkWStream* stream) {
- // SkTDArray<SkPDFDevice*> fPageDevices;
- if (fPageDevices.isEmpty()) {
+bool SkPDFDocument::EmitPDF(const SkTDArray<SkPDFDevice*>& pageDevices,
+ SkWStream* stream) {
+ if (pageDevices.isEmpty()) {
return false;
}
SkTDArray<SkPDFPage*> pages;
- for (int i = 0; i < fPageDevices.count(); i++) {
+ for (int i = 0; i < pageDevices.count(); i++) {
+ SkASSERT(pageDevices[i]);
// Reference from new passed to pages.
- pages.push(SkNEW_ARGS(SkPDFPage, (fPageDevices[i])));
+ pages.push(SkNEW_ARGS(SkPDFPage, (pageDevices[i])));
}
SkPDFCatalog catalog;
@@ -194,19 +191,20 @@ bool SkPDFDocument::emitPDF(SkWStream* stream) {
}
// TODO(halcanary): expose notEmbeddableCount in SkDocument
-void SkPDFDocument::getCountOfFontTypes(
+void SkPDFDocument::GetCountOfFontTypes(
+ const SkTDArray<SkPDFDevice*>& pageDevices,
int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
int* notSubsettableCount,
- int* notEmbeddableCount) const {
+ int* notEmbeddableCount) {
sk_bzero(counts, sizeof(int) *
(SkAdvancedTypefaceMetrics::kOther_Font + 1));
SkTDArray<SkFontID> seenFonts;
int notSubsettable = 0;
int notEmbeddable = 0;
- for (int pageNumber = 0; pageNumber < fPageDevices.count(); pageNumber++) {
+ for (int pageNumber = 0; pageNumber < pageDevices.count(); pageNumber++) {
const SkTDArray<SkPDFFont*>& fontResources =
- fPageDevices[pageNumber]->getFontResources();
+ pageDevices[pageNumber]->getFontResources();
for (int font = 0; font < fontResources.count(); font++) {
SkFontID fontID = fontResources[font]->typeface()->uniqueID();
if (seenFonts.find(fontID) == -1) {
« src/pdf/SkPDFDocument.h ('K') | « src/pdf/SkPDFDocument.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698