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

Side by Side Diff: samplecode/SampleLua.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkLua.h" 10 #include "SkLua.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 SkDebugf("lua err: %s\n", lua_tostring(L, -1)); 53 SkDebugf("lua err: %s\n", lua_tostring(L, -1));
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 lua_State* ensureLua() { 58 lua_State* ensureLua() {
59 if (nullptr == fLua) { 59 if (nullptr == fLua) {
60 fLua = new SkLua; 60 fLua = new SkLua;
61 61
62 SkString str = GetResourcePath(LUA_FILENAME); 62 SkString str = GetResourcePath(LUA_FILENAME);
63 SkData* data = SkData::NewFromFileName(str.c_str()); 63 sk_sp<SkData> data(SkData::MakeFromFileName(str.c_str()));
64 if (data) { 64 if (data) {
65 fLua->runCode(data->data(), data->size()); 65 fLua->runCode(data->data(), data->size());
66 data->unref();
67 this->setImageFilename(fLua->get()); 66 this->setImageFilename(fLua->get());
68 } else { 67 } else {
69 fLua->runCode(gMissingCode); 68 fLua->runCode(gMissingCode);
70 } 69 }
71 } 70 }
72 return fLua->get(); 71 return fLua->get();
73 } 72 }
74 73
75 protected: 74 protected:
76 bool onQuery(SkEvent* evt) override { 75 bool onQuery(SkEvent* evt) override {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 private: 176 private:
178 SkLua* fLua; 177 SkLua* fLua;
179 178
180 typedef SampleView INHERITED; 179 typedef SampleView INHERITED;
181 }; 180 };
182 181
183 ////////////////////////////////////////////////////////////////////////////// 182 //////////////////////////////////////////////////////////////////////////////
184 183
185 static SkView* MyFactory() { return new LuaView; } 184 static SkView* MyFactory() { return new LuaView; }
186 static SkViewRegister reg(MyFactory); 185 static SkViewRegister reg(MyFactory);
OLDNEW
« include/core/SkData.h ('K') | « samplecode/DecodeFile.h ('k') | src/codec/SkIcoCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698