blob: 914f156d18ed1090fc929cd5e28407e294e40661 [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.come50d9a12013-10-10 20:58:22 +000065#define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId;\
66 (obj)->fOffsetStart = offsetStart;\
67 (obj)->fOffsetEnd = offsetEnd;
edisonn@google.combca421b2013-09-05 20:00:21 +000068#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart;
69#else
edisonn@google.comc8fda9d2013-10-09 20:23:12 +000070#define TRACK_OBJECT_SRC(a)
edisonn@google.combca421b2013-09-05 20:00:21 +000071#define STORE_TRACK_PARAMETERS(obj)
72#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd)
73#endif //PDF_TRACK_STREAM_OFFSETS
74
edisonn@google.comaf54a512013-09-13 19:33:42 +000075// TODO(edisonn): move it somewhere else?
76struct 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
91struct SkPdfInputStreamLocation {
92 SkPdfInputStream fInputStream;
93 const unsigned char* fNow;
94};
95
96#ifdef PDF_TRACK_STREAM_OFFSETS
97struct SkPdfInputStreamRange {
98 SkPdfInputStream fInputStream;
99 const unsigned char* fRangeStart;
100 const unsigned char* fRangeEnd;
101};
102#endif // PDF_TRACK_STREAM_OFFSETS
103
edisonn@google.combca421b2013-09-05 20:00:21 +0000104
edisonn@google.comcf2cfa12013-08-21 16:31:37 +0000105#endif // SkPdfConfig_DEFINED