| Index: gm/gmmain.cpp
|
| diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
|
| index 2cd8f474f9302d9c65a4f9b7954cbe04a741d8d3..759175c89026987626548a2adac85bc3be6a3148 100644
|
| --- a/gm/gmmain.cpp
|
| +++ b/gm/gmmain.cpp
|
| @@ -18,11 +18,13 @@
|
| #include "gm_expectations.h"
|
| #include "system_preferences.h"
|
| #include "SkBitmap.h"
|
| +#include "SkCanvasSimplifier.h"
|
| #include "SkColorPriv.h"
|
| #include "SkCommandLineFlags.h"
|
| #include "SkData.h"
|
| #include "SkDeferredCanvas.h"
|
| #include "SkDevice.h"
|
| +#include "SkDocument.h"
|
| #include "SkDrawFilter.h"
|
| #include "SkForceLinking.h"
|
| #include "SkGPipe.h"
|
| @@ -33,6 +35,7 @@
|
| #include "SkPDFRasterizer.h"
|
| #include "SkPicture.h"
|
| #include "SkRefCnt.h"
|
| +#include "SkScalar.h"
|
| #include "SkStream.h"
|
| #include "SkTArray.h"
|
| #include "SkTDict.h"
|
| @@ -619,29 +622,17 @@ public:
|
| #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);
|
| + SkSize pageSize2 = SkSize::Make(SkIntToScalar(pageSize.width()), SkIntToScalar(pageSize.height()));
|
| + SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(&pdf, NULL));
|
| + SkCanvas* canvas = NULL;
|
| + canvas = pdfDoc->beginPage(pageSize2);
|
| + canvas->setMatrix(initialTransform);
|
|
|
| - SkCanvas c(dev);
|
| - invokeGM(gm, &c, true, false);
|
| + pdfDoc->setDCTEncoder(encode_to_dct_stream);
|
| +
|
| + invokeGM(gm, canvas, true, false);
|
|
|
| - SkPDFDocument doc;
|
| - doc.appendPage(dev);
|
| - doc.emitPDF(&pdf);
|
| + pdfDoc->close();
|
| #endif
|
| }
|
|
|
|
|