blob: d920718df91e51444f159f3c3d838cb613fac836 [file] [log] [blame]
edisonn@google.comcf2cfa12013-08-21 16:31:37 +00001/*
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.com3aac1f92013-07-02 22:42:53 +000010
edisonn@google.comaf54a512013-09-13 19:33:42 +000011#include "stddef.h"
12class SkPdfNativeObject;
13
edisonn@google.com598cf5d2013-10-09 15:13:19 +000014// 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.combca421b2013-09-05 20:00:21 +000016//#define PDF_TRACK_OBJECT_USAGE
edisonn@google.com598cf5d2013-10-09 15:13:19 +000017
18// tracks the position in the stream, it can be used to show where exactly the errors happened
edisonn@google.com0fd25d82013-09-05 16:40:34 +000019//#define PDF_TRACK_STREAM_OFFSETS
edisonn@google.com598cf5d2013-10-09 15:13:19 +000020
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.comaf54a512013-09-13 19:33:42 +000023//#define PDF_REPORT
edisonn@google.com598cf5d2013-10-09 15:13:19 +000024
25// At various points in code we show the value of important variables with this flag
edisonn@google.com3aac1f92013-07-02 22:42:53 +000026//#define PDF_TRACE
edisonn@google.com598cf5d2013-10-09 15:13:19 +000027
28// displays the result of each read token, individual result
edisonn@google.com2ccc3af2013-07-23 17:43:18 +000029//#define PDF_TRACE_READ_TOKEN
edisonn@google.com598cf5d2013-10-09 15:13:19 +000030
31// Every drawtext draws before a rectangle, in this way we see the one that might have failed
edisonn@google.com3aa35552013-08-14 18:26:20 +000032//#define PDF_TRACE_DRAWTEXT
edisonn@google.com598cf5d2013-10-09 15:13:19 +000033
34// For each render operations, it will dump the canvas in a png
edisonn@google.com3aac1f92013-07-02 22:42:53 +000035//#define PDF_TRACE_DIFF_IN_PNG
edisonn@google.com598cf5d2013-10-09 15:13:19 +000036
37// Does not clip at all, can be used in debugging issues
edisonn@google.com3aac1f92013-07-02 22:42:53 +000038//#define PDF_DEBUG_NO_CLIPING
edisonn@google.com598cf5d2013-10-09 15:13:19 +000039
40// Does not click the page, use is with 3x
edisonn@google.com3aac1f92013-07-02 22:42:53 +000041//#define PDF_DEBUG_NO_PAGE_CLIPING
edisonn@google.com598cf5d2013-10-09 15:13:19 +000042
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.com3aac1f92013-07-02 22:42:53 +000046//#define PDF_DEBUG_3X
47
edisonn@google.com0fd25d82013-09-05 16:40:34 +000048
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.combca421b2013-09-05 20:00:21 +000063#ifdef PDF_TRACK_STREAM_OFFSETS
edisonn@google.combca421b2013-09-05 20:00:21 +000064#define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId; (obj)->fOffsetStart = offsetStart; (obj)->fOffsetEnd = offsetEnd;
65#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart;
66#else
edisonn@google.combca421b2013-09-05 20:00:21 +000067#define STORE_TRACK_PARAMETERS(obj)
68#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd)
69#endif //PDF_TRACK_STREAM_OFFSETS
70
edisonn@google.comaf54a512013-09-13 19:33:42 +000071// TODO(edisonn): move it somewhere else?
72struct SkPdfInputStream {
73#ifdef PDF_TRACK_STREAM_OFFSETS
74 // no parent object -> original file to be rendered
75 // no parent file -> stream object
76 // both -> external stream object
77 int fParentFileID;
78 const SkPdfNativeObject* fParentObject;
79
80 size_t fDelta; // delta in parent stream
81 const unsigned char* fStart;
82#endif // PDF_TRACK_STREAM_OFFSETS
83
84 const unsigned char* fEnd;
85};
86
87struct SkPdfInputStreamLocation {
88 SkPdfInputStream fInputStream;
89 const unsigned char* fNow;
90};
91
92#ifdef PDF_TRACK_STREAM_OFFSETS
93struct SkPdfInputStreamRange {
94 SkPdfInputStream fInputStream;
95 const unsigned char* fRangeStart;
96 const unsigned char* fRangeEnd;
97};
98#endif // PDF_TRACK_STREAM_OFFSETS
99
edisonn@google.combca421b2013-09-05 20:00:21 +0000100
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000101#endif // SkPdfConfig_DEFINED