OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkPdfReporter_DEFINED | 9 #ifndef SkPdfReporter_DEFINED |
10 #define SkPdfReporter_DEFINED | 10 #define SkPdfReporter_DEFINED |
11 | 11 |
12 #include "SkPdfConfig.h" | 12 #include "SkPdfConfig.h" |
13 | 13 |
14 class SkPdfNativeObject; | 14 class SkPdfNativeObject; |
15 class SkPdfContext; | 15 class SkPdfContext; |
16 | 16 |
17 // TODO(edisonn): ability to turn on asserts for known good files | 17 // TODO(edisonn): ability to turn on asserts for known good files |
18 | 18 |
| 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. |
19 enum SkPdfIssueSeverity { | 21 enum SkPdfIssueSeverity { |
20 kInfo_SkPdfIssueSeverity, | 22 kInfo_SkPdfIssueSeverity, |
21 kCodeWarning_SkPdfIssueSeverity, // e.g. like NYI, PDF file is Ok. | 23 kCodeWarning_SkPdfIssueSeverity, // e.g. like NYI, PDF file is Ok. |
22 kWarning_SkPdfIssueSeverity, | 24 kWarning_SkPdfIssueSeverity, |
23 kIgnoreError_SkPdfIssueSeverity, | 25 kIgnoreError_SkPdfIssueSeverity, |
24 kError_SkPdfIssueSeverity, | 26 kError_SkPdfIssueSeverity, |
25 kFatalError_SkPdfIssueSeverity, | 27 kFatalError_SkPdfIssueSeverity, |
26 | 28 |
27 _kCount__SkPdfIssueSeverity | 29 _kCount__SkPdfIssueSeverity |
28 }; | 30 }; |
29 | 31 |
| 32 // The type of the issue. |
30 enum SkPdfIssue { | 33 enum SkPdfIssue { |
31 kNoIssue_SkPdfIssue, | 34 kNoIssue_SkPdfIssue, |
32 | 35 |
33 kNullObject_SkPdfIssue, | 36 kNullObject_SkPdfIssue, |
34 kUnexpectedArraySize_SkPdfIssue, | 37 kUnexpectedArraySize_SkPdfIssue, |
35 kMissingEncoding_SkPdfIssue, | 38 kMissingEncoding_SkPdfIssue, |
36 kNYI_SkPdfIssue, | 39 kNYI_SkPdfIssue, |
37 kIncostistentSizes_SkPdfIssue, | 40 kIncostistentSizes_SkPdfIssue, |
38 kMissingRequiredKey_SkPdfIssue, | 41 kMissingRequiredKey_SkPdfIssue, |
39 kRecursiveReferencing_SkPdfIssue, | 42 kRecursiveReferencing_SkPdfIssue, |
(...skipping 11 matching lines...) Expand all Loading... |
51 kMissingToken_SkPdfIssue, | 54 kMissingToken_SkPdfIssue, |
52 kBadReference_SkPdfIssue, | 55 kBadReference_SkPdfIssue, |
53 kNoFlateLibrary_SkPdfIssue, | 56 kNoFlateLibrary_SkPdfIssue, |
54 kBadStream_SkPdfIssue, | 57 kBadStream_SkPdfIssue, |
55 | 58 |
56 _kCount__SkPdfIssue | 59 _kCount__SkPdfIssue |
57 }; | 60 }; |
58 | 61 |
59 #ifdef PDF_REPORT | 62 #ifdef PDF_REPORT |
60 | 63 |
| 64 // Calls SkPdfReport(...) if report is true. |
61 void SkPdfReportIf(bool report, | 65 void SkPdfReportIf(bool report, |
62 SkPdfIssueSeverity sev, SkPdfIssue issue, | 66 SkPdfIssueSeverity sev, SkPdfIssue issue, |
63 const char* context, | 67 const char* context, |
64 const SkPdfNativeObject* obj, | 68 const SkPdfNativeObject* obj, |
65 SkPdfContext* pdfContext); | 69 SkPdfContext* pdfContext); |
| 70 |
| 71 // Reports an issue, along with information where it happened, for example obj c
an be used to report |
| 72 // where exactly in th pdf there is a corruption |
| 73 // TODO(edisonn): add ability to report the callstack |
66 void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue, | 74 void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue, |
67 const char* context, | 75 const char* context, |
68 const SkPdfNativeObject* obj, | 76 const SkPdfNativeObject* obj, |
69 SkPdfContext* pdfContext); | 77 SkPdfContext* pdfContext); |
| 78 |
| 79 // Reports that an object does not have the expected type |
| 80 // TODO(edisonn): replace with SkPdfReportIfUnexpectedType() to simplify the cal
lers? |
| 81 // TODO(edisonn): pass the keyword/operator too which triggers the issue. |
70 void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, | 82 void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, |
71 const char* context, | 83 const char* context, |
72 const SkPdfNativeObject* obj, int anyOfTypes, | 84 const SkPdfNativeObject* obj, int anyOfTypes, |
73 SkPdfContext* pdfContext); | 85 SkPdfContext* pdfContext); |
| 86 |
| 87 // Code only in builds with reporting turn on. |
74 #define SkPdfREPORTCODE(code) code | 88 #define SkPdfREPORTCODE(code) code |
75 | 89 |
76 #else // !PDF_REPORT | 90 #else // !PDF_REPORT |
77 | 91 |
78 #define SkPdfReportIf(a,b,c,d,e,f) | 92 #define SkPdfReportIf(a,b,c,d,e,f) |
79 #define SkPdfReport(a,b,c,d,e) | 93 #define SkPdfReport(a,b,c,d,e) |
80 #define SkPdfReportUnexpectedType(a,b,c,d,e) | 94 #define SkPdfReportUnexpectedType(a,b,c,d,e) |
81 #define SkPdfREPORTCODE(code) | 95 #define SkPdfREPORTCODE(code) |
82 | 96 |
83 #endif // PDF_REPORT | 97 #endif // PDF_REPORT |
84 | 98 |
85 #endif // SkPdfReporter_DEFINED | 99 #endif // SkPdfReporter_DEFINED |
OLD | NEW |