aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/utils.gni
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-08-09 09:25:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-09 13:46:24 +0000
commit69fd008199989c5a5a96f992dcaa4089b63f490f (patch)
tree3bf276d326699010cb5e172d986e90e409ca7efd /gn/utils.gni
parentbca3b8d8e0eaca73e25ed44fd20d4a6a0376e4ce (diff)
Added SkJSONWriter
This is a stand-alone helper class for writing properly structured JSON to an SkWStream. It currently solves two problems (although this CL only uses it in one context): 1) Performance. Writing out JSON this way is about 10x faster than using JSONCPP. For the large amounts of data generated by the tracing system, that's a big win. 2) Makes it easy to emit structured JSON from code that's not fully centralized. We'd like to spit out JSON that describes a GrContext, GrGpu, GrCaps, etc... Doing that with simple string manipulation is complex, and spreads this logic over all those functions. Using JSONCPP adds yet another (large) third party library dependency (that we only build into our own tools right now). This went through several revisions. I originally planned it as a stateful SkString wrapper, so the user could just build their JSON as a string. That's O(N^2), though, because SkString grows by a (small) constant amount. Even using a better growth strategy still means needing RAM for all the resulting text, which is usually pointless. This version has a constant memory cost, so writing huge amounts of JSON to disk (tracing a long DM run can emit 100's of MBs) doesn't stress resources. Bug: skia: Change-Id: Ia716524b246db0f97d332da60d2ce9903069e748 Reviewed-on: https://skia-review.googlesource.com/31204 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'gn/utils.gni')
-rw-r--r--gn/utils.gni1
1 files changed, 1 insertions, 0 deletions
diff --git a/gn/utils.gni b/gn/utils.gni
index 14bec37def..faab5d9e1b 100644
--- a/gn/utils.gni
+++ b/gn/utils.gni
@@ -45,6 +45,7 @@ skia_utils_sources = [
"$_src/utils/SkInsetConvexPolygon.cpp",
"$_src/utils/SkInsetConvexPolygon.h",
"$_src/utils/SkInterpolator.cpp",
+ "$_src/utils/SkJSONWriter.h",
"$_src/utils/SkMatrix22.cpp",
"$_src/utils/SkMatrix22.h",
"$_src/utils/SkMultiPictureDocument.cpp",