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

Side by Side Diff: samplecode/SampleLua.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleIdentityScale.cpp ('k') | samplecode/SamplePdfFileViewer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 "" 34 ""
35 "function onDrawContent(canvas)" 35 "function onDrawContent(canvas)"
36 " canvas:drawText('missing \"test.lua\"', 20, 50, paint)" 36 " canvas:drawText('missing \"test.lua\"', 20, 50, paint)"
37 "end" 37 "end"
38 ; 38 ;
39 39
40 class LuaView : public SampleView { 40 class LuaView : public SampleView {
41 public: 41 public:
42 LuaView() : fLua(NULL) {} 42 LuaView() : fLua(NULL) {}
43 43
44 virtual ~LuaView() { 44 virtual ~LuaView() { delete fLua; }
45 SkDELETE(fLua);
46 }
47 45
48 void setImageFilename(lua_State* L) { 46 void setImageFilename(lua_State* L) {
49 SkString str = GetResourcePath("mandrill_256.png"); 47 SkString str = GetResourcePath("mandrill_256.png");
50 48
51 lua_getglobal(L, "setImageFilename"); 49 lua_getglobal(L, "setImageFilename");
52 if (lua_isfunction(L, -1)) { 50 if (lua_isfunction(L, -1)) {
53 fLua->pushString(str.c_str()); 51 fLua->pushString(str.c_str());
54 if (lua_pcall(L, 1, 0, 0) != LUA_OK) { 52 if (lua_pcall(L, 1, 0, 0) != LUA_OK) {
55 SkDebugf("lua err: %s\n", lua_tostring(L, -1)); 53 SkDebugf("lua err: %s\n", lua_tostring(L, -1));
56 } 54 }
57 } 55 }
58 } 56 }
59 57
60 lua_State* ensureLua() { 58 lua_State* ensureLua() {
61 if (NULL == fLua) { 59 if (NULL == fLua) {
62 fLua = SkNEW(SkLua); 60 fLua = new SkLua;
63 61
64 SkString str = GetResourcePath(LUA_FILENAME); 62 SkString str = GetResourcePath(LUA_FILENAME);
65 SkData* data = SkData::NewFromFileName(str.c_str()); 63 SkData* data = SkData::NewFromFileName(str.c_str());
66 if (data) { 64 if (data) {
67 fLua->runCode(data->data(), data->size()); 65 fLua->runCode(data->data(), data->size());
68 data->unref(); 66 data->unref();
69 this->setImageFilename(fLua->get()); 67 this->setImageFilename(fLua->get());
70 } else { 68 } else {
71 fLua->runCode(gMissingCode); 69 fLua->runCode(gMissingCode);
72 } 70 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 private: 177 private:
180 SkLua* fLua; 178 SkLua* fLua;
181 179
182 typedef SampleView INHERITED; 180 typedef SampleView INHERITED;
183 }; 181 };
184 182
185 ////////////////////////////////////////////////////////////////////////////// 183 //////////////////////////////////////////////////////////////////////////////
186 184
187 static SkView* MyFactory() { return new LuaView; } 185 static SkView* MyFactory() { return new LuaView; }
188 static SkViewRegister reg(MyFactory); 186 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleIdentityScale.cpp ('k') | samplecode/SamplePdfFileViewer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698