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

Unified Diff: gm/gmmain.cpp

Issue 24811002: Update the SkDocument interface to allow for 1) abort won't emit pdf, 2) close can report success/f… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | gyp/core.gyp » ('j') | include/core/SkDocument.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « no previous file | gyp/core.gyp » ('j') | include/core/SkDocument.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698