blob: f4e8ea4963fe06c8556551b014ad81bb717878d0 [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
scroggo@google.coma7a946a2013-11-07 18:22:18 +00008#ifdef PDF_REPORT
edisonn@google.com67d7fb42013-10-07 15:40:21 +00009
10#include "SkPdfReporter.h"
11
12#include "SkTypes.h"
13
14const char* severityName[] = {
15"Info",
16"CodeWarning",
17"Warning",
18"IgnoreError",
19"Error",
20"FatalError",
21};
22
23const char* getSeverityName(SkPdfIssueSeverity sev) {
24 if (0 <= sev && sev < _kCount__SkPdfIssueSeverity) {
25 return severityName[sev];
26 }
27 SkASSERT(false);
28 return "UNKOWN SEVERITY";
29}
30
31// TODO(edisonn): add a flag to set the minimum warning level
edisonn@google.comd03c2c72013-10-11 18:26:45 +000032// TODO(edisonn): get the address in the file, and report it.
33// TODO(edisonn): build a html file based on warnings which would showe the original pdf
34// content, with tooltips where warnings/errors were reported.
35
edisonn@google.com67d7fb42013-10-07 15:40:21 +000036
edisonn@google.come50d9a12013-10-10 20:58:22 +000037void SkPdfReport(SkPdfIssueSeverity sev, SkPdfIssue issue,
38 const char* context,
39 const SkPdfNativeObject* obj,
40 SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000041 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
42 printf("%s: %s\n", getSeverityName(sev), context);
43 }
44}
45
edisonn@google.come50d9a12013-10-10 20:58:22 +000046void SkPdfReportIf(bool report,
47 SkPdfIssueSeverity sev, SkPdfIssue issue,
48 const char* context,
49 const SkPdfNativeObject* obj,
50SkPdfContext* pdfContext) {
edisonn@google.com67d7fb42013-10-07 15:40:21 +000051 if (!report) {
52 return;
53 }
54 SkPdfReport(sev, issue, context, obj, pdfContext);
55}
edisonn@google.come50d9a12013-10-10 20:58:22 +000056
57void SkPdfReportUnexpectedType(SkPdfIssueSeverity sev,
58 const char* context,
59 const SkPdfNativeObject* obj,
60 int anyOfTypes, SkPdfContext* pdfContext) {
61 if (sev >= kIgnoreError_SkPdfIssueSeverity) {
62 printf("%s: %s\n", getSeverityName(sev), context);
63 }
64}
65
edisonn@google.com67d7fb42013-10-07 15:40:21 +000066#endif // PDF_REPORT