blob: be939598641a9270a1f7e9388e65fbac1474b719 [file] [log] [blame]
edisonn@google.com67d7fb42013-10-07 15:40:21 +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
9#ifndef SkPdfReporter_DEFINED
10#define SkPdfReporter_DEFINED
11
12#include "SkPdfConfig.h"
13
14class SkPdfNativeObject;
15class SkPdfContext;
16
edisonn@google.come50d9a12013-10-10 20:58:22 +000017// TODO(edisonn): ability to turn on asserts for known good files
18
edisonn@google.comd03c2c72013-10-11 18:26:45 +000019// Severity of the issue, if it something interesting info, the result of an NYI feature,
20// sme ignorable defect in pdf or a major issue.
edisonn@google.com67d7fb42013-10-07 15:40:21 +000021enum SkPdfIssueSeverity {
22 kInfo_SkPdfIssueSeverity,
edisonn@google.come50d9a12013-10-10 20:58:22 +000023 kCodeWarning_SkPdfIssueSeverity, // e.g. like NYI, PDF file is Ok.
edisonn@google.com67d7fb42013-10-07 15:40:21 +000024 kWarning_SkPdfIssueSeverity,
25 kIgnoreError_SkPdfIssueSeverity,
26 kError_SkPdfIssueSeverity,
27 kFatalError_SkPdfIssueSeverity,
28
29 _kCount__SkPdfIssueSeverity
30};
31
edisonn@google.comd03c2c72013-10-11 18:26:45 +000032// The type of the issue.
edisonn@google.com67d7fb42013-10-07 15:40:21 +000033enum SkPdfIssue {
34 kNoIssue_SkPdfIssue,
35
36 kNullObject_SkPdfIssue,
37 kUnexpectedArraySize_SkPdfIssue,
38 kMissingEncoding_SkPdfIssue,
39 kNYI_SkPdfIssue,
40 kIncostistentSizes_SkPdfIssue,
41 kMissingRequiredKey_SkPdfIssue,
42 kRecursiveReferencing_SkPdfIssue,
43 kStackNestingOverflow_SkPdfIssue,
44 kStackOverflow_SkPdfIssue,
45 kIncositentSyntax_SkPdfIssue,
46 kMissingFont_SkPdfIssue,
47 kInvalidFont_SkPdfIssue,
48 kMissingBT_SkPdfIssue,
49 kOutOfRange_SkPdfIssue,
50 kUnknownBlendMode_SkPdfIssue,
51 kMissingExtGState_SkPdfIssue,
52 kMissingXObject_SkPdfIssue,
53 kReadStreamError_SkPdfIssue,
54 kMissingToken_SkPdfIssue,
55 kBadReference_SkPdfIssue,
56 kNoFlateLibrary_SkPdfIssue,
57 kBadStream_SkPdfIssue,
58
edisonn@google.com67d7fb42013-10-07 15:40:21 +000059 _kCount__SkPdfIssue
60};
61
62#ifdef PDF_REPORT
63
edisonn@google.comd03c2c72013-10-11 18:26:45 +000064// Calls SkPdfReport(...) if report is true.
edisonn@google.come50d9a12013-10-10 20:58:22 +000065void SkPdfReportIf(bool report,
66 SkPdfIssueSeverity sev, SkPdfIssue issue,
67 const char* context,
68 const SkPdfNativeObject* obj,
69 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000070
71// Reports an issue, along with information where it happened, for example obj can be used to report
72// where exactly in th pdf there is a corruption
73// TODO(edisonn): add ability to report the callstack
edisonn@google.come50d9a12013-10-10 20:58:22 +000074void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue,
75 const char* context,
76 const SkPdfNativeObject* obj,
77 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000078
79// Reports that an object does not have the expected type
80// TODO(edisonn): replace with SkPdfReportIfUnexpectedType() to simplify the callers?
81// TODO(edisonn): pass the keyword/operator too which triggers the issue.
edisonn@google.come50d9a12013-10-10 20:58:22 +000082void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev,
83 const char* context,
84 const SkPdfNativeObject* obj, int anyOfTypes,
85 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000086
87// Code only in builds with reporting turn on.
edisonn@google.com67d7fb42013-10-07 15:40:21 +000088#define SkPdfREPORTCODE(code) code
89
90#else // !PDF_REPORT
91
92#define SkPdfReportIf(a,b,c,d,e,f)
93#define SkPdfReport(a,b,c,d,e)
94#define SkPdfReportUnexpectedType(a,b,c,d,e)
95#define SkPdfREPORTCODE(code)
96
97#endif // PDF_REPORT
98
99#endif // SkPdfReporter_DEFINED