1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com/* 2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Copyright 2013 Google Inc. 3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * 4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * Use of this source code is governed by a BSD-style license that can be 5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com * found in the LICENSE file. 6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com */ 7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com 8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#ifndef SkPdfConfig_DEFINED 9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define SkPdfConfig_DEFINED 103aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com 11af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com#include "stddef.h" 12af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.comclass SkPdfNativeObject; 13af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 14598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// shows what objects have not been used in rendering. can be used to track what features we might 15598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// have not implemented, or where we implemented only the default behaivour 16bca421b468f53a591333918248f54bbd958389d2edisonn@google.com//#define PDF_TRACK_OBJECT_USAGE 17598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 18598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// tracks the position in the stream, it can be used to show where exactly the errors happened 190fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com//#define PDF_TRACK_STREAM_OFFSETS 20598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 21598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// reports issues, warning, NYI, errors, ... 22598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// enable PDF_TRACK_STREAM_OFFSETS to also have the offset in the stream where the error happened 23af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com//#define PDF_REPORT 24598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 25598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// At various points in code we show the value of important variables with this flag 263aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com//#define PDF_TRACE 27598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 28598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// displays the result of each read token, individual result 292ccc3afa474f9485c39c2e863252ddaa3f35724bedisonn@google.com//#define PDF_TRACE_READ_TOKEN 30598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 31598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// Every drawtext draws before a rectangle, in this way we see the one that might have failed 323aa355527a3b91d3e12b8bee49e5637d00a736caedisonn@google.com//#define PDF_TRACE_DRAWTEXT 33598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 34598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// For each render operations, it will dump the canvas in a png 353aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com//#define PDF_TRACE_DIFF_IN_PNG 36598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 37598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// Does not clip at all, can be used in debugging issues 383aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com//#define PDF_DEBUG_NO_CLIPING 39598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 40598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// Does not click the page, use is with 3x 413aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com//#define PDF_DEBUG_NO_PAGE_CLIPING 42598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com 43598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// render the page 3X bigger (with content in center) - used to make sure we don't mess up 44598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// positioning 45598cf5d3cfc428108cf21ab45d73a995d7e5c2a8edisonn@google.com// like a tick tac toe board, only the center one has content, all the rest of them have to be clean 463aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com//#define PDF_DEBUG_3X 473aac1f9f308192f3787265830fe86ce8874e7382edisonn@google.com 480fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com 490fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com// TODO(edisonn): pass a flag to say how it was used? e.g. asked the type? Obtained value? 500fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com// Implement it when it will be needed the first time to fix some bug. 510fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#ifdef PDF_TRACK_OBJECT_USAGE 520fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#define SkPdfMarkObjectUsed() fUsed = true 530fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#else 540fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#define SkPdfMarkObjectUsed() 550fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#endif // PDF_TRACK_OBJECT_USAGE 560fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com 570fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#ifdef PDF_TRACK_OBJECT_USAGE 580fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#define SkPdfMarkObjectUnused() fUsed = false 590fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#else 600fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#define SkPdfMarkObjectUnused() 610fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com#endif // PDF_TRACK_OBJECT_USAGE 620fd25d8b22ae092183f3dc67dec4c0c1bbde06bfedisonn@google.com 63bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#ifdef PDF_TRACK_STREAM_OFFSETS 64c8fda9d96be0bd944d37a6e23f7adad5f247c51dedisonn@google.com#define TRACK_OBJECT_SRC(a) 65e50d9a1fcd9c4298079ff54f9a40c9708d30f8c6edisonn@google.com#define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId;\ 66e50d9a1fcd9c4298079ff54f9a40c9708d30f8c6edisonn@google.com (obj)->fOffsetStart = offsetStart;\ 67e50d9a1fcd9c4298079ff54f9a40c9708d30f8c6edisonn@google.com (obj)->fOffsetEnd = offsetEnd; 68bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart; 69bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#else 70c8fda9d96be0bd944d37a6e23f7adad5f247c51dedisonn@google.com#define TRACK_OBJECT_SRC(a) 71bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#define STORE_TRACK_PARAMETERS(obj) 72bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) 73bca421b468f53a591333918248f54bbd958389d2edisonn@google.com#endif //PDF_TRACK_STREAM_OFFSETS 74bca421b468f53a591333918248f54bbd958389d2edisonn@google.com 75af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com// TODO(edisonn): move it somewhere else? 76af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.comstruct SkPdfInputStream { 77af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com#ifdef PDF_TRACK_STREAM_OFFSETS 78af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com // no parent object -> original file to be rendered 79af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com // no parent file -> stream object 80af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com // both -> external stream object 81af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com int fParentFileID; 82af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const SkPdfNativeObject* fParentObject; 83af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 84af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com size_t fDelta; // delta in parent stream 85af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const unsigned char* fStart; 86af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com#endif // PDF_TRACK_STREAM_OFFSETS 87af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 88af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const unsigned char* fEnd; 89af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com}; 90af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 91af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.comstruct SkPdfInputStreamLocation { 92af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com SkPdfInputStream fInputStream; 93af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const unsigned char* fNow; 94af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com}; 95af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 96af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com#ifdef PDF_TRACK_STREAM_OFFSETS 97af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.comstruct SkPdfInputStreamRange { 98af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com SkPdfInputStream fInputStream; 99af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const unsigned char* fRangeStart; 100af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com const unsigned char* fRangeEnd; 101af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com}; 102af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com#endif // PDF_TRACK_STREAM_OFFSETS 103af54a513a5b7723b53f61730afe0ad6256881749edisonn@google.com 104bca421b468f53a591333918248f54bbd958389d2edisonn@google.com 105cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#endif // SkPdfConfig_DEFINED 106