2013-08-21 16:31:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPdfConfig_DEFINED
|
|
|
|
#define SkPdfConfig_DEFINED
|
2013-07-02 22:42:53 +00:00
|
|
|
|
2013-09-13 19:33:42 +00:00
|
|
|
#include "stddef.h"
|
|
|
|
class SkPdfNativeObject;
|
|
|
|
|
2013-09-05 20:00:21 +00:00
|
|
|
//#define PDF_TRACK_OBJECT_USAGE
|
2013-09-05 16:40:34 +00:00
|
|
|
//#define PDF_TRACK_STREAM_OFFSETS
|
2013-09-13 19:33:42 +00:00
|
|
|
//#define PDF_REPORT
|
2013-07-02 22:42:53 +00:00
|
|
|
//#define PDF_TRACE
|
2013-07-23 17:43:18 +00:00
|
|
|
//#define PDF_TRACE_READ_TOKEN
|
2013-08-14 18:26:20 +00:00
|
|
|
//#define PDF_TRACE_DRAWTEXT
|
2013-07-02 22:42:53 +00:00
|
|
|
//#define PDF_TRACE_DIFF_IN_PNG
|
|
|
|
//#define PDF_DEBUG_NO_CLIPING
|
|
|
|
//#define PDF_DEBUG_NO_PAGE_CLIPING
|
|
|
|
//#define PDF_DEBUG_3X
|
|
|
|
|
2013-09-05 16:40:34 +00:00
|
|
|
|
|
|
|
// TODO(edisonn): pass a flag to say how it was used? e.g. asked the type? Obtained value?
|
|
|
|
// Implement it when it will be needed the first time to fix some bug.
|
|
|
|
#ifdef PDF_TRACK_OBJECT_USAGE
|
|
|
|
#define SkPdfMarkObjectUsed() fUsed = true
|
|
|
|
#else
|
|
|
|
#define SkPdfMarkObjectUsed()
|
|
|
|
#endif // PDF_TRACK_OBJECT_USAGE
|
|
|
|
|
|
|
|
#ifdef PDF_TRACK_OBJECT_USAGE
|
|
|
|
#define SkPdfMarkObjectUnused() fUsed = false
|
|
|
|
#else
|
|
|
|
#define SkPdfMarkObjectUnused()
|
|
|
|
#endif // PDF_TRACK_OBJECT_USAGE
|
|
|
|
|
2013-09-05 20:00:21 +00:00
|
|
|
#ifdef PDF_TRACK_STREAM_OFFSETS
|
|
|
|
|
|
|
|
// TODO(edisonn): track source files
|
|
|
|
#define SkPdfTrackSrourceFile(foo) -2
|
|
|
|
|
|
|
|
#define GET_TRACK_STREAM , int streamId, const unsigned char* streamStart
|
|
|
|
#define PUT_TRACK_STREAM_ARGS , streamId, streamStart
|
|
|
|
#define PUT_TRACK_STREAM(start,end) , streamId, start-streamStart, end-streamStart
|
|
|
|
#define PUT_TRACK_STREAM_ARGS_EXPL(a,b,c) , a, b, c
|
|
|
|
#define PUT_TRACK_STREAM_ARGS_EXPL2(a,b) , a, b
|
|
|
|
|
|
|
|
|
|
|
|
#define PUT_TRACK_PARAMETERS , streamId, offsetStart, offsetEnd
|
|
|
|
#define PUT_TRACK_PARAMETERS_OBJ(obj) , (obj)->streamId(), (obj)->offsetStart(), (obj)->offsetEnd()
|
|
|
|
#define PUT_TRACK_PARAMETERS_OBJ2(obj,objEnd) , (obj)->streamId(), (obj)->offsetStart(), (objEnd)->offsetEnd()
|
|
|
|
#define PUT_TRACK_PARAMETERS_SRC , SkPdfTrackSrourceFile(__FILE__), __LINE__, __LINE__
|
|
|
|
#define PUT_TRACK_PARAMETERS_SRC0 SkPdfTrackSrourceFile(__FILE__), __LINE__, __LINE__
|
|
|
|
#define GET_TRACK_PARAMETERS , int streamId, int offsetStart, int offsetEnd
|
|
|
|
#define GET_TRACK_PARAMETERS0 int streamId, int offsetStart, int offsetEnd
|
|
|
|
#define STORE_TRACK_PARAMETERS(obj) (obj)->fStreamId = streamId; (obj)->fOffsetStart = offsetStart; (obj)->fOffsetEnd = offsetEnd;
|
|
|
|
#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd) (obj)->fOffsetEnd = (offsetEnd)-streamStart;
|
|
|
|
#else
|
|
|
|
#define GET_TRACK_STREAM
|
|
|
|
#define PUT_TRACK_STREAM_ARGS
|
|
|
|
#define PUT_TRACK_STREAM(start,end)
|
|
|
|
#define PUT_TRACK_STREAM_ARGS_EXPL(a,b,c)
|
|
|
|
#define PUT_TRACK_STREAM_ARGS_EXPL2(a,b)
|
|
|
|
|
|
|
|
|
|
|
|
#define PUT_TRACK_PARAMETERS
|
|
|
|
#define PUT_TRACK_PARAMETERS_OBJ(obj)
|
|
|
|
#define PUT_TRACK_PARAMETERS_OBJ2(obj,objEnd)
|
|
|
|
#define PUT_TRACK_PARAMETERS_SRC
|
|
|
|
#define PUT_TRACK_PARAMETERS_SRC0
|
|
|
|
#define GET_TRACK_PARAMETERS
|
|
|
|
#define GET_TRACK_PARAMETERS0
|
|
|
|
#define STORE_TRACK_PARAMETERS(obj)
|
|
|
|
#define STORE_TRACK_PARAMETER_OFFSET_END(obj,offsetEnd)
|
|
|
|
#endif //PDF_TRACK_STREAM_OFFSETS
|
|
|
|
|
2013-09-13 19:33:42 +00:00
|
|
|
// TODO(edisonn): move it somewhere else?
|
|
|
|
struct SkPdfInputStream {
|
|
|
|
#ifdef PDF_TRACK_STREAM_OFFSETS
|
|
|
|
// no parent object -> original file to be rendered
|
|
|
|
// no parent file -> stream object
|
|
|
|
// both -> external stream object
|
|
|
|
int fParentFileID;
|
|
|
|
const SkPdfNativeObject* fParentObject;
|
|
|
|
|
|
|
|
size_t fDelta; // delta in parent stream
|
|
|
|
const unsigned char* fStart;
|
|
|
|
#endif // PDF_TRACK_STREAM_OFFSETS
|
|
|
|
|
|
|
|
const unsigned char* fEnd;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SkPdfInputStreamLocation {
|
|
|
|
SkPdfInputStream fInputStream;
|
|
|
|
const unsigned char* fNow;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef PDF_TRACK_STREAM_OFFSETS
|
|
|
|
struct SkPdfInputStreamRange {
|
|
|
|
SkPdfInputStream fInputStream;
|
|
|
|
const unsigned char* fRangeStart;
|
|
|
|
const unsigned char* fRangeEnd;
|
|
|
|
};
|
|
|
|
#endif // PDF_TRACK_STREAM_OFFSETS
|
|
|
|
|
2013-09-05 20:00:21 +00:00
|
|
|
|
2013-08-21 16:31:37 +00:00
|
|
|
#endif // SkPdfConfig_DEFINED
|