skia2/experimental/PdfViewer/SkPdfReporter.cpp
scroggo@google.com 7d8013f306 Changes to SkTDStackNester.
SkTDStackNester is a class used by PdfViewer to assist in saving
and restoring the PDF state. Clean up and test this class.

Add some documentation.

Add FIXME's where I have questions to resolve.

Fix a bug where fNestingLevel was not initialized.

Remove a commented out line of code copied over from
SkTDStack.

Rename SkTDStackNester::nests() to nestingLevel() and make it const.

Remove unnecessary predeclaration and friend declaration.

Remove index() (both const and non-const versions). They were
unused, return something that may not be expected (index from
the top, rather than from the bottom), and don't work to get any
elements in earlier Recs once the first one is full.

Report a warning if the nesting level goes above the maximum level,
or if we attempt to bring it below zero.

Prevent fNestingLevel from dropping below zero.

Add kUnusedObject_SkPdfIssue, and use it where appropriate.

Depends on https://codereview.chromium.org/64093009/

R=mtklein@google.com

Review URL: https://codereview.chromium.org/68843006

git-svn-id: http://skia.googlecode.com/svn/trunk@12328 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-11-20 21:40:57 +00:00

67 lines
1.8 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifdef PDF_REPORT
#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
// TODO(edisonn): get the address in the file, and report it.
// TODO(edisonn): build a html file based on warnings which would showe the original pdf
// content, with tooltips where warnings/errors were reported.
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 SkPdfReportIf(bool report,
SkPdfIssueSeverity sev, SkPdfIssue issue,
const char* context,
const SkPdfNativeObject* obj,
SkPdfContext* pdfContext) {
if (!report) {
return;
}
SkPdfReport(sev, issue, context, obj, pdfContext);
}
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);
}
}
#endif // PDF_REPORT