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, |
scroggo@google.com | 7d8013f | 2013-11-20 21:40:57 +0000 | [diff] [blame] | 37 | kUnusedObject_SkPdfIssue, |
edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 38 | 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.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 60 | _kCount__SkPdfIssue |
| 61 | }; |
| 62 | |
| 63 | #ifdef PDF_REPORT |
| 64 | |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 65 | // Calls SkPdfReport(...) if report is true. |
edisonn@google.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 66 | void SkPdfReportIf(bool report, |
| 67 | SkPdfIssueSeverity sev, SkPdfIssue issue, |
| 68 | const char* context, |
| 69 | const SkPdfNativeObject* obj, |
| 70 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 71 | |
| 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.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 75 | void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue, |
| 76 | const char* context, |
| 77 | const SkPdfNativeObject* obj, |
| 78 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 79 | |
| 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.com | e50d9a1 | 2013-10-10 20:58:22 +0000 | [diff] [blame] | 83 | void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, |
| 84 | const char* context, |
| 85 | const SkPdfNativeObject* obj, int anyOfTypes, |
| 86 | SkPdfContext* pdfContext); |
edisonn@google.com | d03c2c7 | 2013-10-11 18:26:45 +0000 | [diff] [blame] | 87 | |
| 88 | // Code only in builds with reporting turn on. |
edisonn@google.com | 67d7fb4 | 2013-10-07 15:40:21 +0000 | [diff] [blame] | 89 | #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 |