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

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 1781773002: SkPDF: move all pdf sources into src/pdf (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-10 (Thursday) 15:59:02 EST Created 4 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 | « src/pdf/SkPDFDocument.h ('k') | src/xps/SkConstexprMath.h » ('j') | 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/doc/SkDocument_PDF.cpp b/src/pdf/SkPDFDocument.cpp
similarity index 94%
rename from src/doc/SkDocument_PDF.cpp
rename to src/pdf/SkPDFDocument.cpp
index c866648ae7fecae8cbc020cfd0b997aac4c289fa..bacd9eccc74be336a47c086a582f9020cf113f9e 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -5,17 +5,15 @@
* found in the LICENSE file.
*/
-#include "SkDocument.h"
#include "SkPDFCanon.h"
#include "SkPDFDevice.h"
+#include "SkPDFDocument.h"
#include "SkPDFFont.h"
+#include "SkPDFMetadata.h"
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
#include "SkPDFUtils.h"
#include "SkStream.h"
-#include "SkPDFMetadata.h"
-
-class SkPDFDict;
static void emit_pdf_header(SkWStream* stream) {
stream->writeText("%PDF-1.4\n%");
@@ -309,9 +307,9 @@ template <typename T> static T* clone(const T* o) { return o ? new T(*o) : nullp
////////////////////////////////////////////////////////////////////////////////
namespace {
-class SkDocument_PDF : public SkDocument {
+class SkPDFDocument : public SkDocument {
public:
- SkDocument_PDF(SkWStream* stream,
+ SkPDFDocument(SkWStream* stream,
void (*doneProc)(SkWStream*, bool),
SkScalar rasterDpi,
SkPixelSerializer* jpegEncoder)
@@ -320,7 +318,7 @@ public:
fCanon.setPixelSerializer(SkSafeRef(jpegEncoder));
}
- virtual ~SkDocument_PDF() {
+ virtual ~SkPDFDocument() {
// subclasses must call close() in their destructors
this->close();
}
@@ -380,24 +378,27 @@ private:
} // namespace
///////////////////////////////////////////////////////////////////////////////
+sk_sp<SkDocument> SkPDFMakeDocument(SkWStream* stream,
+ void (*proc)(SkWStream*, bool),
+ SkScalar dpi,
+ SkPixelSerializer* jpeg) {
+ return stream ? sk_make_sp<SkPDFDocument>(stream, proc, dpi, jpeg) : nullptr;
+}
+
SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
- return stream ? new SkDocument_PDF(stream, nullptr, dpi, nullptr) : nullptr;
+ return SkPDFMakeDocument(stream, nullptr, dpi, nullptr).release();
}
SkDocument* SkDocument::CreatePDF(SkWStream* stream,
SkScalar dpi,
SkPixelSerializer* jpegEncoder) {
- return stream
- ? new SkDocument_PDF(stream, nullptr, dpi, jpegEncoder)
- : nullptr;
+ return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release();
}
SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
- SkFILEWStream* stream = new SkFILEWStream(path);
- if (!stream->isValid()) {
- delete stream;
- return nullptr;
- }
auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
- return new SkDocument_PDF(stream, delete_wstream, dpi, nullptr);
+ SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
+ return stream->isValid()
+ ? SkPDFMakeDocument(stream.detach(), delete_wstream, dpi, nullptr).release()
+ : nullptr;
}
« no previous file with comments | « src/pdf/SkPDFDocument.h ('k') | src/xps/SkConstexprMath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698