edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkPdfConfig_DEFINED |
| 9 | #define SkPdfConfig_DEFINED |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 10 | |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 11 | #include "stddef.h" |
| 12 | class SkPdfNativeObject; |
| 13 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 14 | // shows what objects have not been used in rendering. can be used to track what features we might |
| 15 | // have not implemented, or where we implemented only the default behaivour |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 16 | //#define PDF_TRACK_OBJECT_USAGE |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 17 | |
| 18 | // tracks the position in the stream, it can be used to show where exactly the errors happened |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 19 | //#define PDF_TRACK_STREAM_OFFSETS |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 20 | |
| 21 | // reports issues, warning, NYI, errors, ... |
| 22 | // enable PDF_TRACK_STREAM_OFFSETS to also have the offset in the stream where the error happened |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 23 | //#define PDF_REPORT |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 24 | |
| 25 | // At various points in code we show the value of important variables with this flag |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 26 | //#define PDF_TRACE |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 27 | |
| 28 | // displays the result of each read token, individual result |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 29 | //#define PDF_TRACE_READ_TOKEN |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 30 | |
| 31 | // Every drawtext draws before a rectangle, in this way we see the one that might have failed |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 32 | //#define PDF_TRACE_DRAWTEXT |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 33 | |
| 34 | // For each render operations, it will dump the canvas in a png |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 35 | //#define PDF_TRACE_DIFF_IN_PNG |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 36 | |
| 37 | // Does not clip at all, can be used in debugging issues |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 38 | //#define PDF_DEBUG_NO_CLIPING |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 39 | |
| 40 | // Does not click the page, use is with 3x |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 41 | //#define PDF_DEBUG_NO_PAGE_CLIPING |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 42 | |
| 43 | // render the page 3X bigger (with content in center) - used to make sure we don't mess up |
| 44 | // positioning |
| 45 | // like a tick tac toe board, only the center one has content, all the rest of them have to be clean |
edisonn@google.com | 3aac1f9 | 2013-07-02 22:42:53 +0000 | [diff] [blame] | 46 | //#define PDF_DEBUG_3X |
| 47 | |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 48 | |
| 49 | // TODO(edisonn): pass a flag to say how it was used? e.g. asked the type? Obtained value? |
| 50 | // Implement it when it will be needed the first time to fix some bug. |
| 51 | #ifdef PDF_TRACK_OBJECT_USAGE |
| 52 | #define SkPdfMarkObjectUsed() fUsed = true |
| 53 | #else |
| 54 | #define SkPdfMarkObjectUsed() |
| 55 | #endif // PDF_TRACK_OBJECT_USAGE |
| 56 | |
| 57 | #ifdef PDF_TRACK_OBJECT_USAGE |
| 58 | #define SkPdfMarkObjectUnused() fUsed = false |
| 59 | #else |
| 60 | #define SkPdfMarkObjectUnused() |
| 61 | #endif // PDF_TRACK_OBJECT_USAGE |
| 62 | |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 63 | #ifdef PDF_TRACK_STREAM_OFFSETS |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 64 | #define TRACK_OBJECT_SRC(a) |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 65 | #define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId;\ |
| 66 | (obj)->fOffsetStart = offsetStart;\ |
| 67 | (obj)->fOffsetEnd = offsetEnd; |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 68 | #define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart; |
| 69 | #else |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 70 | #define TRACK_OBJECT_SRC(a) |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 71 | #define STORE_TRACK_PARAMETERS(obj) |
| 72 | #define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) |
| 73 | #endif //PDF_TRACK_STREAM_OFFSETS |
| 74 | |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 75 | // TODO(edisonn): move it somewhere else? |
| 76 | struct SkPdfInputStream { |
| 77 | #ifdef PDF_TRACK_STREAM_OFFSETS |
| 78 | // no parent object -> original file to be rendered |
| 79 | // no parent file -> stream object |
| 80 | // both -> external stream object |
| 81 | int fParentFileID; |
| 82 | const SkPdfNativeObject* fParentObject; |
| 83 | |
| 84 | size_t fDelta; // delta in parent stream |
| 85 | const unsigned char* fStart; |
| 86 | #endif // PDF_TRACK_STREAM_OFFSETS |
| 87 | |
| 88 | const unsigned char* fEnd; |
| 89 | }; |
| 90 | |
| 91 | struct SkPdfInputStreamLocation { |
| 92 | SkPdfInputStream fInputStream; |
| 93 | const unsigned char* fNow; |
| 94 | }; |
| 95 | |
| 96 | #ifdef PDF_TRACK_STREAM_OFFSETS |
| 97 | struct SkPdfInputStreamRange { |
| 98 | SkPdfInputStream fInputStream; |
| 99 | const unsigned char* fRangeStart; |
| 100 | const unsigned char* fRangeEnd; |
| 101 | }; |
| 102 | #endif // PDF_TRACK_STREAM_OFFSETS |
| 103 | |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 104 | |
edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 105 | #endif // SkPdfConfig_DEFINED |