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

Side by Side Diff: src/utils/SkLua.cpp

Issue 499413002: SkTextBlob plumbing (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review comments 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 unified diff | Download patch
« no previous file with comments | « src/utils/SkDumpCanvas.cpp ('k') | src/utils/SkLuaCanvas.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 "SkLua.h" 8 #include "SkLua.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrReducedClip.h" 11 #include "GrReducedClip.h"
12 #endif 12 #endif
13 13
14 #include "SkCanvas.h" 14 #include "SkCanvas.h"
15 #include "SkData.h" 15 #include "SkData.h"
16 #include "SkDocument.h" 16 #include "SkDocument.h"
17 #include "SkImage.h" 17 #include "SkImage.h"
18 #include "SkMatrix.h" 18 #include "SkMatrix.h"
19 #include "SkPaint.h" 19 #include "SkPaint.h"
20 #include "SkPath.h" 20 #include "SkPath.h"
21 #include "SkPixelRef.h" 21 #include "SkPixelRef.h"
22 #include "SkRRect.h" 22 #include "SkRRect.h"
23 #include "SkString.h" 23 #include "SkString.h"
24 #include "SkTextBlob.h"
24 #include "SkTypeface.h" 25 #include "SkTypeface.h"
25 26
26 extern "C" { 27 extern "C" {
27 #include "lua.h" 28 #include "lua.h"
28 #include "lualib.h" 29 #include "lualib.h"
29 #include "lauxlib.h" 30 #include "lauxlib.h"
30 } 31 }
31 32
32 // return the metatable name for a given class 33 // return the metatable name for a given class
33 template <typename T> const char* get_mtname(); 34 template <typename T> const char* get_mtname();
34 #define DEF_MTNAME(T) \ 35 #define DEF_MTNAME(T) \
35 template <> const char* get_mtname<T>() { \ 36 template <> const char* get_mtname<T>() { \
36 return #T "_LuaMetaTableName"; \ 37 return #T "_LuaMetaTableName"; \
37 } 38 }
38 39
39 DEF_MTNAME(SkCanvas) 40 DEF_MTNAME(SkCanvas)
40 DEF_MTNAME(SkDocument) 41 DEF_MTNAME(SkDocument)
41 DEF_MTNAME(SkImage) 42 DEF_MTNAME(SkImage)
42 DEF_MTNAME(SkMatrix) 43 DEF_MTNAME(SkMatrix)
43 DEF_MTNAME(SkRRect) 44 DEF_MTNAME(SkRRect)
44 DEF_MTNAME(SkPath) 45 DEF_MTNAME(SkPath)
45 DEF_MTNAME(SkPaint) 46 DEF_MTNAME(SkPaint)
46 DEF_MTNAME(SkPathEffect) 47 DEF_MTNAME(SkPathEffect)
47 DEF_MTNAME(SkShader) 48 DEF_MTNAME(SkShader)
49 DEF_MTNAME(SkTextBlob)
48 DEF_MTNAME(SkTypeface) 50 DEF_MTNAME(SkTypeface)
49 51
50 template <typename T> T* push_new(lua_State* L) { 52 template <typename T> T* push_new(lua_State* L) {
51 T* addr = (T*)lua_newuserdata(L, sizeof(T)); 53 T* addr = (T*)lua_newuserdata(L, sizeof(T));
52 new (addr) T; 54 new (addr) T;
53 luaL_getmetatable(L, get_mtname<T>()); 55 luaL_getmetatable(L, get_mtname<T>());
54 lua_setmetatable(L, -2); 56 lua_setmetatable(L, -2);
55 return addr; 57 return addr;
56 } 58 }
57 59
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 void SkLua::pushPath(const SkPath& path, const char key[]) { 268 void SkLua::pushPath(const SkPath& path, const char key[]) {
267 push_obj(fL, path); 269 push_obj(fL, path);
268 CHECK_SETFIELD(key); 270 CHECK_SETFIELD(key);
269 } 271 }
270 272
271 void SkLua::pushCanvas(SkCanvas* canvas, const char key[]) { 273 void SkLua::pushCanvas(SkCanvas* canvas, const char key[]) {
272 push_ref(fL, canvas); 274 push_ref(fL, canvas);
273 CHECK_SETFIELD(key); 275 CHECK_SETFIELD(key);
274 } 276 }
275 277
278 void SkLua::pushTextBlob(const SkTextBlob* blob, const char key[]) {
279 push_ref(fL, const_cast<SkTextBlob*>(blob));
280 CHECK_SETFIELD(key);
281 }
282
276 static const char* element_type(SkClipStack::Element::Type type) { 283 static const char* element_type(SkClipStack::Element::Type type) {
277 switch (type) { 284 switch (type) {
278 case SkClipStack::Element::kEmpty_Type: 285 case SkClipStack::Element::kEmpty_Type:
279 return "empty"; 286 return "empty";
280 case SkClipStack::Element::kRect_Type: 287 case SkClipStack::Element::kRect_Type:
281 return "rect"; 288 return "rect";
282 case SkClipStack::Element::kRRect_Type: 289 case SkClipStack::Element::kRRect_Type:
283 return "rrect"; 290 return "rrect";
284 case SkClipStack::Element::kPath_Type: 291 case SkClipStack::Element::kPath_Type:
285 return "path"; 292 return "path";
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 REG_CLASS(L, SkShader); 1507 REG_CLASS(L, SkShader);
1501 REG_CLASS(L, SkTypeface); 1508 REG_CLASS(L, SkTypeface);
1502 REG_CLASS(L, SkMatrix); 1509 REG_CLASS(L, SkMatrix);
1503 } 1510 }
1504 1511
1505 extern "C" int luaopen_skia(lua_State* L); 1512 extern "C" int luaopen_skia(lua_State* L);
1506 extern "C" int luaopen_skia(lua_State* L) { 1513 extern "C" int luaopen_skia(lua_State* L) {
1507 SkLua::Load(L); 1514 SkLua::Load(L);
1508 return 0; 1515 return 0;
1509 } 1516 }
OLDNEW
« no previous file with comments | « src/utils/SkDumpCanvas.cpp ('k') | src/utils/SkLuaCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698