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

Unified Diff: gm/gmmain.cpp

Issue 731173002: Revert "move SkPDFD*.h from include to src" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/pdf.gyp » ('j') | no next file with comments »
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 196f152ef2d6298d573d8fb4d9ebba5c14abc692..62d4e74462d0c54499b8828cd3e50e343cfa5fe5 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -73,6 +73,13 @@ typedef int GrGLStandard;
#define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message")
+DECLARE_bool(useDocumentInsteadOfDevice);
+
+#ifdef SK_SUPPORT_PDF
+ #include "SkPDFDevice.h"
+ #include "SkPDFDocument.h"
+#endif
+
// Until we resolve http://code.google.com/p/skia/issues/detail?id=455 ,
// stop writing out XPS-format image baselines in gm.
#undef SK_SUPPORT_XPS
@@ -652,21 +659,51 @@ public:
static bool generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
#ifdef SK_SUPPORT_PDF
- SkAutoTUnref<SkDocument> pdfDoc(
- SkDocument::CreatePDF(&pdf, NULL, encode_to_dct_data,
- SkIntToScalar(FLAGS_pdfRasterDpi)));
- if (!pdfDoc) {
- return false;
- }
+ SkMatrix initialTransform = gm->getInitialTransform();
+ if (FLAGS_useDocumentInsteadOfDevice) {
+ SkISize pageISize = gm->getISize();
+ SkAutoTUnref<SkDocument> pdfDoc(
+ SkDocument::CreatePDF(&pdf, NULL,
+ encode_to_dct_data,
+ SkIntToScalar(FLAGS_pdfRasterDpi)));
+
+ if (!pdfDoc.get()) {
+ return false;
+ }
- SkISize pageISize = gm->getISize();
- SkCanvas* canvas = pdfDoc->beginPage(SkIntToScalar(pageISize.width()),
- SkIntToScalar(pageISize.height()));
- canvas->concat(gm->getInitialTransform());
+ SkCanvas* canvas = NULL;
+ canvas = pdfDoc->beginPage(SkIntToScalar(pageISize.width()),
+ SkIntToScalar(pageISize.height()));
+ canvas->concat(initialTransform);
- invokeGM(gm, canvas, true, false);
+ invokeGM(gm, canvas, true, false);
- return pdfDoc->close();
+ return pdfDoc->close();
+ } else {
+ 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_data);
+ dev->setRasterDpi(SkIntToScalar(FLAGS_pdfRasterDpi));
+ SkAutoUnref aur(dev);
+ SkCanvas c(dev);
+ invokeGM(gm, &c, true, false);
+ SkPDFDocument doc;
+ doc.appendPage(dev);
+ doc.emitPDF(&pdf);
+ }
#endif // SK_SUPPORT_PDF
return true; // Do not report failure if pdf is not supported.
}
@@ -1468,6 +1505,7 @@ DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, "
// Probably define spacial names like centerx, centery, top, bottom, left, right
// then we can write something reabable like --rotate centerx centery 90
DEFINE_bool(forcePerspectiveMatrix, false, "Force a perspective matrix.");
+DEFINE_bool(useDocumentInsteadOfDevice, false, "Use SkDocument::CreateFoo instead of SkFooDevice.");
DEFINE_int32(pdfRasterDpi, 72, "Scale at which at which the non suported "
"features in PDF are rasterized. Must be be in range 0-10000. "
"Default is 72. N = 0 will disable rasterizing features like "
« no previous file with comments | « no previous file | gyp/pdf.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698