Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: tools/lua/lua_pictures.cpp

Issue 565803005: use SkData::NewUninitialized (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: readInData -> NewFromStream Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/lua/lua_app.cpp ('k') | tools/skdiff_utils.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lua/lua_pictures.cpp
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index 635cf0bed0152b5626231b58de855ed619d3815a..6c7087fc053389ef94c3b88cb8be86ae4fc12885 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -47,17 +47,6 @@ static SkPicture* load_picture(const char path[]) {
return pic;
}
-static SkData* read_into_data(const char file[]) {
- SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file));
- if (!stream.get()) {
- return SkData::NewEmpty();
- }
- size_t len = stream->getLength();
- void* buffer = sk_malloc_throw(len);
- stream->read(buffer, len);
- return SkData::NewFromMalloc(buffer, len);
-}
-
static void call_canvas(lua_State* L, SkLuaCanvas* canvas,
const char pictureFile[], const char funcName[]) {
lua_getglobal(L, funcName);
@@ -97,7 +86,10 @@ int tool_main(int argc, char** argv) {
SkLua L(summary);
for (int i = 0; i < FLAGS_luaFile.count(); ++i) {
- SkAutoDataUnref data(read_into_data(FLAGS_luaFile[i]));
+ SkAutoDataUnref data(SkData::NewFromFileName(FLAGS_luaFile[i]));
+ if (NULL == data.get()) {
+ data.reset(SkData::NewEmpty());
+ }
if (!FLAGS_quiet) {
SkDebugf("loading %s...\n", FLAGS_luaFile[i]);
}
« no previous file with comments | « tools/lua/lua_app.cpp ('k') | tools/skdiff_utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698