edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | class SkPdfNativeObject; |
| 15 | class SkPdfContext; |
| 16 | |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 17 | // TODO(edisonn): ability to turn on asserts for known good files |
| 18 | |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 19 | // 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.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 21 | enum SkPdfIssueSeverity { |
| 22 | kInfo_SkPdfIssueSeverity, |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 23 | kCodeWarning_SkPdfIssueSeverity, // e.g. like NYI, PDF file is Ok. |
edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 24 | kWarning_SkPdfIssueSeverity, |
| 25 | kIgnoreError_SkPdfIssueSeverity, |
| 26 | kError_SkPdfIssueSeverity, |
| 27 | kFatalError_SkPdfIssueSeverity, |
| 28 | |
| 29 | _kCount__SkPdfIssueSeverity |
| 30 | }; |
| 31 | |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 32 | // The type of the issue. |
edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 33 | enum 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.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 59 | _kCount__SkPdfIssue |
| 60 | }; |
| 61 | |
| 62 | #ifdef PDF_REPORT |
| 63 | |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 64 | // Calls SkPdfReport(...) if report is true. |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 65 | void SkPdfReportIf(bool report, |
| 66 | SkPdfIssueSeverity sev, SkPdfIssue issue, |
| 67 | const char* context, |
| 68 | const SkPdfNativeObject* obj, |
| 69 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 70 | |
| 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.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 74 | void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue, |
| 75 | const char* context, |
| 76 | const SkPdfNativeObject* obj, |
| 77 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 78 | |
| 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.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 82 | void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, |
| 83 | const char* context, |
| 84 | const SkPdfNativeObject* obj, int anyOfTypes, |
| 85 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 86 | |
| 87 | // Code only in builds with reporting turn on. |
edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 88 | #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 |