blob: 3718154d843abd9f8fd7533a6d55060ce42aaaff [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,
scroggo@google.com7d8013f2013-11-20 21:40:57 +000037 kUnusedObject_SkPdfIssue,
edisonn@google.com67d7fb42013-10-07 15:40:21 +000038 kUnexpectedArraySize_SkPdfIssue,
39 kMissingEncoding_SkPdfIssue,
40 kNYI_SkPdfIssue,
41 kIncostistentSizes_SkPdfIssue,
42 kMissingRequiredKey_SkPdfIssue,
43 kRecursiveReferencing_SkPdfIssue,
44 kStackNestingOverflow_SkPdfIssue,
45 kStackOverflow_SkPdfIssue,
46 kIncositentSyntax_SkPdfIssue,
47 kMissingFont_SkPdfIssue,
48 kInvalidFont_SkPdfIssue,
49 kMissingBT_SkPdfIssue,
50 kOutOfRange_SkPdfIssue,
51 kUnknownBlendMode_SkPdfIssue,
52 kMissingExtGState_SkPdfIssue,
53 kMissingXObject_SkPdfIssue,
54 kReadStreamError_SkPdfIssue,
55 kMissingToken_SkPdfIssue,
56 kBadReference_SkPdfIssue,
57 kNoFlateLibrary_SkPdfIssue,
58 kBadStream_SkPdfIssue,
59
edisonn@google.com67d7fb42013-10-07 15:40:21 +000060 _kCount__SkPdfIssue
61};
62
63#ifdef PDF_REPORT
64
edisonn@google.comd03c2c72013-10-11 18:26:45 +000065// Calls SkPdfReport(...) if report is true.
edisonn@google.come50d9a12013-10-10 20:58:22 +000066void SkPdfReportIf(bool report,
67 SkPdfIssueSeverity sev, SkPdfIssue issue,
68 const char* context,
69 const SkPdfNativeObject* obj,
70 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000071
72// Reports an issue, along with information where it happened, for example obj can be used to report
73// where exactly in th pdf there is a corruption
74// TODO(edisonn): add ability to report the callstack
edisonn@google.come50d9a12013-10-10 20:58:22 +000075void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue,
76 const char* context,
77 const SkPdfNativeObject* obj,
78 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000079
80// Reports that an object does not have the expected type
81// TODO(edisonn): replace with SkPdfReportIfUnexpectedType() to simplify the callers?
82// TODO(edisonn): pass the keyword/operator too which triggers the issue.
edisonn@google.come50d9a12013-10-10 20:58:22 +000083void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev,
84 const char* context,
85 const SkPdfNativeObject* obj, int anyOfTypes,
86 SkPdfContext* pdfContext);
edisonn@google.comd03c2c72013-10-11 18:26:45 +000087
88// Code only in builds with reporting turn on.
edisonn@google.com67d7fb42013-10-07 15:40:21 +000089#define SkPdfREPORTCODE(code) code
90
91#else // !PDF_REPORT
92
93#define SkPdfReportIf(a,b,c,d,e,f)
94#define SkPdfReport(a,b,c,d,e)
95#define SkPdfReportUnexpectedType(a,b,c,d,e)
96#define SkPdfREPORTCODE(code)
97
98#endif // PDF_REPORT
99
100#endif // SkPdfReporter_DEFINED