diff options
author | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-07 15:40:21 +0000 |
---|---|---|
committer | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-07 15:40:21 +0000 |
commit | 67d7fb4e89d91a63d54426ac63d8e5c253521a59 (patch) | |
tree | 8db8db42988cb153f40d9947595077983f0b920a /experimental/PdfViewer | |
parent | 64f031c278a32ac4dbc4478e64f816b2173ecca7 (diff) |
pdf report files
Review URL: https://codereview.chromium.org/26271002
git-svn-id: http://skia.googlecode.com/svn/trunk@11629 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer')
-rw-r--r-- | experimental/PdfViewer/SkPdfReporter.cpp | 51 | ||||
-rw-r--r-- | experimental/PdfViewer/SkPdfReporter.h | 74 |
2 files changed, 125 insertions, 0 deletions
diff --git a/experimental/PdfViewer/SkPdfReporter.cpp b/experimental/PdfViewer/SkPdfReporter.cpp new file mode 100644 index 0000000000..cc0cc2d8f1 --- /dev/null +++ b/experimental/PdfViewer/SkPdfReporter.cpp @@ -0,0 +1,51 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "SkPdfReporter.h" + +#include "SkTypes.h" + +const char* severityName[] = { +"Info", +"CodeWarning", +"Warning", +"IgnoreError", +"Error", +"FatalError", +}; + +const char* getSeverityName(SkPdfIssueSeverity sev) { + if (0 <= sev && sev < _kCount__SkPdfIssueSeverity) { + return severityName[sev]; + } + SkASSERT(false); + return "UNKOWN SEVERITY"; +} + +// TODO(edisonn): add a flag to set the minimum warning level + +#ifdef PDF_REPORT +void SkPdfReport( SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext) { + if (sev >= kIgnoreError_SkPdfIssueSeverity) { + printf("%s: %s\n", getSeverityName(sev), context); + } +} + +void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev, const char* context, const SkPdfNativeObject* obj, int anyOfTypes, SkPdfContext* pdfContext) { + if (sev >= kIgnoreError_SkPdfIssueSeverity) { + printf("%s: %s\n", getSeverityName(sev), context); + } +} + +void SkPdfReportIf(bool report, SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext) { + if (!report) { + return; + } + SkPdfReport(sev, issue, context, obj, pdfContext); +} +#endif // PDF_REPORT diff --git a/experimental/PdfViewer/SkPdfReporter.h b/experimental/PdfViewer/SkPdfReporter.h new file mode 100644 index 0000000000..7f1c1cf247 --- /dev/null +++ b/experimental/PdfViewer/SkPdfReporter.h @@ -0,0 +1,74 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#ifndef SkPdfReporter_DEFINED +#define SkPdfReporter_DEFINED + +#include "SkPdfConfig.h" + +class SkPdfNativeObject; +class SkPdfContext; + +enum SkPdfIssueSeverity { + kInfo_SkPdfIssueSeverity, + kCodeWarning_SkPdfIssueSeverity, // e.g. like NYI, which has nothing to do with an error in the file + kWarning_SkPdfIssueSeverity, + kIgnoreError_SkPdfIssueSeverity, + kError_SkPdfIssueSeverity, + kFatalError_SkPdfIssueSeverity, + + _kCount__SkPdfIssueSeverity +}; + +enum SkPdfIssue { + kNoIssue_SkPdfIssue, + + kNullObject_SkPdfIssue, + kUnexpectedArraySize_SkPdfIssue, + kMissingEncoding_SkPdfIssue, + kNYI_SkPdfIssue, + kIncostistentSizes_SkPdfIssue, + kMissingRequiredKey_SkPdfIssue, + kRecursiveReferencing_SkPdfIssue, + kStackNestingOverflow_SkPdfIssue, + kStackOverflow_SkPdfIssue, + kIncositentSyntax_SkPdfIssue, + kMissingFont_SkPdfIssue, + kInvalidFont_SkPdfIssue, + kMissingBT_SkPdfIssue, + kOutOfRange_SkPdfIssue, + kUnknownBlendMode_SkPdfIssue, + kMissingExtGState_SkPdfIssue, + kMissingXObject_SkPdfIssue, + kReadStreamError_SkPdfIssue, + kMissingToken_SkPdfIssue, + kBadReference_SkPdfIssue, + kNoFlateLibrary_SkPdfIssue, + kBadStream_SkPdfIssue, + + + _kCount__SkPdfIssue +}; + +#ifdef PDF_REPORT + +void SkPdfReportIf(bool report, SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext); +void SkPdfReport( SkPdfIssueSeverity sev, SkPdfIssue issue, const char* context, const SkPdfNativeObject* obj, SkPdfContext* pdfContext); +void SkPdfReportUnexpectedType( SkPdfIssueSeverity sev, const char* context, const SkPdfNativeObject* obj, int anyOfTypes, SkPdfContext* pdfContext); +#define SkPdfREPORTCODE(code) code + +#else // !PDF_REPORT + +#define SkPdfReportIf(a,b,c,d,e,f) +#define SkPdfReport(a,b,c,d,e) +#define SkPdfReportUnexpectedType(a,b,c,d,e) +#define SkPdfREPORTCODE(code) + +#endif // PDF_REPORT + +#endif // SkPdfReporter_DEFINED |