Reland "Switch persistent cache to use SkReadBuffer/SkWriteBuffer"
These are much safer than SkReader32/SkWriter32 (they do validation and
ensure we never read past the end of the buffer).
Where we used to just assert that the contents of the cache were valid,
we now validate everything, and fail gracefully by discarding the cache
contents if it's corrupted or invalid.
Reland includes a new skipByteArray API. The previous technique for
reading into an std::string relied on data(), which doesn't return a
writeable pointer until the C++17 standard library.
Bug: skia:9402
Change-Id: I3b88efbf8ca590c8ad4f8164f7c07eee12696ec6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295441
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index ad8e7c3..7a1d4e3 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -2223,7 +2223,7 @@
entry.fKeyString.appendf("%02x", digest.data[i]);
}
- SkReader32 reader(data->data(), data->size());
+ SkReadBuffer reader(data->data(), data->size());
entry.fShaderType = GrPersistentCacheUtils::GetType(&reader);
GrPersistentCacheUtils::UnpackCachedShaders(&reader, entry.fShader,
entry.fInputs,