add JSONP option to output of skpdiff
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/18648002
git-svn-id: http://skia.googlecode.com/svn/trunk@9907 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/skpdiff/SkDiffContext.cpp b/experimental/skpdiff/SkDiffContext.cpp
index 951bba0..78a2384 100644
--- a/experimental/skpdiff/SkDiffContext.cpp
+++ b/experimental/skpdiff/SkDiffContext.cpp
@@ -147,9 +147,15 @@
}
}
-void SkDiffContext::outputRecords(SkWStream& stream) {
+void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) {
DiffRecord* currentRecord = fRecords;
- stream.writeText("{\n");
+ if (useJSONP) {
+ stream.writeText("var SkPDiffRecords = {\n");
+ }
+ else
+ {
+ stream.writeText("{\n");
+ }
stream.writeText(" \"records\": [\n");
while (NULL != currentRecord) {
stream.writeText(" {\n");
@@ -214,5 +220,11 @@
currentRecord = currentRecord->fNext;
}
stream.writeText(" ]\n");
- stream.writeText("}\n");
+ if (useJSONP) {
+ stream.writeText("};\n");
+ }
+ else
+ {
+ stream.writeText("}\n");
+ }
}