Index: gm/gmmain.cpp |
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp |
index 2cd8f474f9302d9c65a4f9b7954cbe04a741d8d3..adcc5ba9638f3dc330dfced8ef79d5dec39bbb1c 100644 |
--- a/gm/gmmain.cpp |
+++ b/gm/gmmain.cpp |
@@ -23,6 +23,7 @@ |
#include "SkData.h" |
#include "SkDeferredCanvas.h" |
#include "SkDevice.h" |
+#include "SkDocument.h" |
#include "SkDrawFilter.h" |
#include "SkForceLinking.h" |
#include "SkGPipe.h" |
@@ -33,6 +34,7 @@ |
#include "SkPDFRasterizer.h" |
#include "SkPicture.h" |
#include "SkRefCnt.h" |
+#include "SkScalar.h" |
#include "SkStream.h" |
#include "SkTArray.h" |
#include "SkTDict.h" |
@@ -618,30 +620,16 @@ public: |
static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { |
#ifdef SK_SUPPORT_PDF |
SkMatrix initialTransform = gm->getInitialTransform(); |
- SkISize pageSize = gm->getISize(); |
- SkPDFDevice* dev = NULL; |
- if (initialTransform.isIdentity()) { |
- dev = new SkPDFDevice(pageSize, pageSize, initialTransform); |
- } else { |
- SkRect content = SkRect::MakeWH(SkIntToScalar(pageSize.width()), |
- SkIntToScalar(pageSize.height())); |
- initialTransform.mapRect(&content); |
- content.intersect(0, 0, SkIntToScalar(pageSize.width()), |
- SkIntToScalar(pageSize.height())); |
- SkISize contentSize = |
- SkISize::Make(SkScalarRoundToInt(content.width()), |
- SkScalarRoundToInt(content.height())); |
- dev = new SkPDFDevice(pageSize, contentSize, initialTransform); |
- } |
- dev->setDCTEncoder(encode_to_dct_stream); |
- SkAutoUnref aur(dev); |
+ SkISize pageISize = gm->getISize(); |
+ SkSize pageSize = SkSize::Make(SkIntToScalar(pageISize.width()), SkIntToScalar(pageISize.height())); |
+ SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(&pdf, NULL, encode_to_dct_stream)); |
+ SkCanvas* canvas = NULL; |
+ canvas = pdfDoc->beginPage(pageSize); |
+ canvas->setMatrix(initialTransform); |
vandebo (ex-Chrome)
2013/09/27 15:50:17
Until the old constructor is removed, I think it's
edisonn
2013/10/04 19:40:37
Now SkPDFDeviceFlatenable will call the old constr
vandebo (ex-Chrome)
2013/10/08 23:37:06
It doesn't.
edisonn
2013/10/09 13:25:55
Correct, I do not pass now the initialTransform.
vandebo (ex-Chrome)
2013/10/09 16:52:32
I added a gm (and the ability for the gm to specif
edisonn
2013/10/10 18:35:15
added a new flag to specify if SkDocument will be
|
- SkCanvas c(dev); |
- invokeGM(gm, &c, true, false); |
+ invokeGM(gm, canvas, true, false); |
- SkPDFDocument doc; |
- doc.appendPage(dev); |
- doc.emitPDF(&pdf); |
+ pdfDoc->close(); |
#endif |
} |