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

Unified Diff: src/doc/SkDocument_PDF.cpp

Issue 1030193002: SkPDF: unclass skpdfdocument (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
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/doc/SkDocument_PDF.cpp
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp
index e486737d7e5e85ef6c0781d27bafaea76feec713..8387cccbd5fe361fff4685a9fa7320c0e81590bb 100644
--- a/src/doc/SkDocument_PDF.cpp
+++ b/src/doc/SkDocument_PDF.cpp
@@ -10,13 +10,13 @@
#include "SkPDFDocument.h"
#include "SkPDFDevice.h"
+namespace {
class SkDocument_PDF : public SkDocument {
public:
SkDocument_PDF(SkWStream* stream,
void (*doneProc)(SkWStream*, bool),
SkScalar rasterDpi)
: SkDocument(stream, doneProc)
- , fDoc(SkNEW(SkPDFDocument))
, fRasterDpi(rasterDpi) {}
virtual ~SkDocument_PDF() {
@@ -28,12 +28,13 @@ protected:
virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height,
const SkRect& trimBox) SK_OVERRIDE {
SkASSERT(!fCanvas.get());
- SkASSERT(!fDevice.get());
SkISize pageSize = SkISize::Make(
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
- fDevice.reset(SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
- fCanvas.reset(SkNEW_ARGS(SkCanvas, (fDevice)));
+ SkAutoTUnref<SkPDFDevice> device(
+ SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
+ fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get())));
+ fPageDevices.push(device.detach());
fCanvas->clipRect(trimBox);
fCanvas->translate(trimBox.x(), trimBox.y());
return fCanvas.get();
@@ -41,38 +42,31 @@ protected:
void onEndPage() SK_OVERRIDE {
SkASSERT(fCanvas.get());
- SkASSERT(fDevice.get());
-
fCanvas->flush();
- fDoc->appendPage(fDevice.get());
-
fCanvas.reset(NULL);
- fDevice.reset(NULL);
}
bool onClose(SkWStream* stream) SK_OVERRIDE {
SkASSERT(!fCanvas.get());
- SkASSERT(!fDevice.get());
- bool success = fDoc->emitPDF(stream);
- fDoc.free();
+ bool success = SkPDFDocument::EmitPDF(fPageDevices, stream);
+ fPageDevices.unrefAll();
fCanon.reset();
return success;
}
void onAbort() SK_OVERRIDE {
- fDoc.free();
+ fPageDevices.unrefAll();
fCanon.reset();
}
private:
SkPDFCanon fCanon;
- SkAutoTDelete<SkPDFDocument> fDoc;
- SkAutoTUnref<SkPDFDevice> fDevice;
+ SkTDArray<SkPDFDevice*> fPageDevices;
SkAutoTUnref<SkCanvas> fCanvas;
SkScalar fRasterDpi;
};
-
+} // namespace
///////////////////////////////////////////////////////////////////////////////
SkDocument* SkDocument::CreatePDF(SkWStream* stream, SkScalar dpi) {
« no previous file with comments | « no previous file | src/pdf/SkPDFDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698