blob: 1894b788ea1b6556b8d03e99e69679efcf46070e [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.comc8fda9d2013-10-09 20:23:12 +000064#define TRACK_OBJECT_SRC(a)
edisonn@google.combca421b2013-09-05 20:00:21 +000065#define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId; (obj)->fOffsetStart = offsetStart; (obj)->fOffsetEnd = offsetEnd;
66#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart;
67#else
edisonn@google.comc8fda9d2013-10-09 20:23:12 +000068#define TRACK_OBJECT_SRC(a)
edisonn@google.combca421b2013-09-05 20:00:21 +000069#define STORE_TRACK_PARAMETERS(obj)
70#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd)
71#endif //PDF_TRACK_STREAM_OFFSETS
72
edisonn@google.comaf54a512013-09-13 19:33:42 +000073// TODO(edisonn): move it somewhere else?
74struct SkPdfInputStream {
75#ifdef PDF_TRACK_STREAM_OFFSETS
76 // no parent object -> original file to be rendered
77 // no parent file -> stream object
78 // both -> external stream object
79 int fParentFileID;
80 const SkPdfNativeObject* fParentObject;
81
82 size_t fDelta; // delta in parent stream
83 const unsigned char* fStart;
84#endif // PDF_TRACK_STREAM_OFFSETS
85
86 const unsigned char* fEnd;
87};
88
89struct SkPdfInputStreamLocation {
90 SkPdfInputStream fInputStream;
91 const unsigned char* fNow;
92};
93
94#ifdef PDF_TRACK_STREAM_OFFSETS
95struct SkPdfInputStreamRange {
96 SkPdfInputStream fInputStream;
97 const unsigned char* fRangeStart;
98 const unsigned char* fRangeEnd;
99};
100#endif // PDF_TRACK_STREAM_OFFSETS
101
edisonn@google.combca421b2013-09-05 20:00:21 +0000102
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000103#endif // SkPdfConfig_DEFINED