From ac8d8b8f13aaf8e63884029c9016eae7cf463534 Mon Sep 17 00:00:00 2001 From: caryclark Date: Wed, 7 Jan 2015 07:36:52 -0800 Subject: [PATCH] revert buildbot breaker Hals's change broke a buildbot has shown here http://build.chromium.org/p/client.skia/builders/Test-Win7-ShuttleA-HD2000-x86-Release/builds/510/steps/gm/logs/stdio Got unknown flag "--useDocumentInsteadOfDevice". Exiting. TBR=halcanary Review URL: https://codereview.chromium.org/832183006 --- gm/gmmain.cpp | 65 ++++++++++++++++++++++------ gyp/pdf.gyp | 6 +++ gyp/pdf.gypi | 6 ++- gyp/tools.gyp | 1 + {src => include}/pdf/SkPDFDevice.h | 0 {src => include}/pdf/SkPDFDocument.h | 0 6 files changed, 62 insertions(+), 16 deletions(-) rename {src => include}/pdf/SkPDFDevice.h (100%) rename {src => include}/pdf/SkPDFDocument.h (100%) diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index b8c8891471..ece8ff32d4 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -74,6 +74,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 @@ -668,24 +675,53 @@ public: static bool generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { #ifdef SK_SUPPORT_PDF - SkAutoTUnref pdfDoc( - SkDocument::CreatePDF(&pdf, NULL, encode_to_dct_data, - SkIntToScalar(FLAGS_pdfRasterDpi))); - if (!pdfDoc) { - return false; - } - - SkCanvas* canvas = NULL; - canvas = pdfDoc->beginPage(gm->width(), gm->height()); - canvas->concat(gm->getInitialTransform()); + SkMatrix initialTransform = gm->getInitialTransform(); + if (FLAGS_useDocumentInsteadOfDevice) { + SkISize pageISize = gm->getISize(); + SkAutoTUnref pdfDoc( + SkDocument::CreatePDF(&pdf, NULL, + encode_to_dct_data, + SkIntToScalar(FLAGS_pdfRasterDpi))); + + if (!pdfDoc.get()) { + return false; + } - invokeGM(gm, canvas, true, false); + SkCanvas* canvas = NULL; + canvas = pdfDoc->beginPage(SkIntToScalar(pageISize.width()), + SkIntToScalar(pageISize.height())); + canvas->concat(initialTransform); - return pdfDoc->close(); + invokeGM(gm, canvas, true, false); -#else // SK_SUPPORT_PDF - return true; // Do not report failure if pdf is not supported. + 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. } static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) { @@ -1542,6 +1578,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 " diff --git a/gyp/pdf.gyp b/gyp/pdf.gyp index e14990946c..76b23bb3a7 100644 --- a/gyp/pdf.gyp +++ b/gyp/pdf.gyp @@ -14,6 +14,7 @@ 'pdf.gypi', ], 'include_dirs': [ + '../include/pdf', '../src/core', # needed to get SkGlyphCache.h and SkTextFormatParams.h '../src/pdf', '../src/utils', # needed to get SkBitSet.h @@ -35,10 +36,15 @@ } ], ], + # This section makes all targets that depend on this target + # #define SK_SUPPORT_PDF and have access to the pdf header files. 'direct_dependent_settings': { 'defines': [ 'SK_SUPPORT_PDF', ], + 'include_dirs': [ + '../include/pdf', + ], }, }, ], diff --git a/gyp/pdf.gypi b/gyp/pdf.gypi index fd4bdc5fbb..e4cb958e1c 100644 --- a/gyp/pdf.gypi +++ b/gyp/pdf.gypi @@ -7,15 +7,17 @@ # { 'sources': [ + '<(skia_include_path)/pdf/SkPDFDevice.h', + '<(skia_include_path)/pdf/SkPDFDocument.h', + '<(skia_src_path)/doc/SkDocument_PDF.cpp', + '<(skia_src_path)/pdf/SkPDFCatalog.cpp', '<(skia_src_path)/pdf/SkPDFCatalog.h', '<(skia_src_path)/pdf/SkPDFDevice.cpp', - '<(skia_src_path)/pdf/SkPDFDevice.h', '<(skia_src_path)/pdf/SkPDFDeviceFlattener.cpp', '<(skia_src_path)/pdf/SkPDFDeviceFlattener.h', '<(skia_src_path)/pdf/SkPDFDocument.cpp', - '<(skia_src_path)/pdf/SkPDFDocument.h', '<(skia_src_path)/pdf/SkPDFFont.cpp', '<(skia_src_path)/pdf/SkPDFFont.h', '<(skia_src_path)/pdf/SkPDFFontImpl.h', diff --git a/gyp/tools.gyp b/gyp/tools.gyp index 5cb6cdffd9..13416664fc 100644 --- a/gyp/tools.gyp +++ b/gyp/tools.gyp @@ -634,6 +634,7 @@ '<(skia_include_path)/gpu', '<(skia_include_path)/images', '<(skia_include_path)/pathops', + '<(skia_include_path)/pdf', '<(skia_include_path)/pipe', '<(skia_include_path)/ports', '<(skia_include_path)/svg', diff --git a/src/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h similarity index 100% rename from src/pdf/SkPDFDevice.h rename to include/pdf/SkPDFDevice.h diff --git a/src/pdf/SkPDFDocument.h b/include/pdf/SkPDFDocument.h similarity index 100% rename from src/pdf/SkPDFDocument.h rename to include/pdf/SkPDFDocument.h -- 2.34.1