reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkLuaCanvas.h" |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 9 | #include "SkLua.h" |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 10 | |
| 11 | extern "C" { |
| 12 | #include "lua.h" |
mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 13 | #include "lauxlib.h" |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 14 | } |
| 15 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 16 | class AutoCallLua : public SkLua { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 17 | public: |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 18 | AutoCallLua(lua_State* L, const char func[], const char verb[]) : INHERITED(L) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 19 | lua_getglobal(L, func); |
| 20 | if (!lua_isfunction(L, -1)) { |
| 21 | int t = lua_type(L, -1); |
| 22 | SkDebugf("--- expected function %d\n", t); |
| 23 | } |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 24 | |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 25 | lua_newtable(L); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 26 | this->pushString(verb, "verb"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | ~AutoCallLua() { |
reed@google.com | 3597b73 | 2013-05-22 20:12:50 +0000 | [diff] [blame] | 30 | lua_State* L = this->get(); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 31 | if (lua_pcall(L, 1, 0, 0) != LUA_OK) { |
| 32 | SkDebugf("lua err: %s\n", lua_tostring(L, -1)); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 33 | } |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 34 | lua_settop(L, -1); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 35 | } |
| 36 | |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 37 | void pushEncodedText(SkPaint::TextEncoding, const void*, size_t); |
| 38 | |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 39 | private: |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 40 | typedef SkLua INHERITED; |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 43 | #define AUTO_LUA(verb) AutoCallLua lua(fL, fFunc.c_str(), verb) |
reed@google.com | 9a73104 | 2013-05-21 17:52:33 +0000 | [diff] [blame] | 44 | |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 45 | |
| 46 | /////////////////////////////////////////////////////////////////////////////// |
| 47 | |
| 48 | void AutoCallLua::pushEncodedText(SkPaint::TextEncoding enc, const void* text, |
| 49 | size_t length) { |
| 50 | switch (enc) { |
| 51 | case SkPaint::kUTF8_TextEncoding: |
| 52 | this->pushString((const char*)text, length, "text"); |
| 53 | break; |
| 54 | case SkPaint::kUTF16_TextEncoding: { |
| 55 | SkString str; |
| 56 | str.setUTF16((const uint16_t*)text, length); |
| 57 | this->pushString(str, "text"); |
| 58 | } break; |
| 59 | case SkPaint::kGlyphID_TextEncoding: |
| 60 | this->pushArrayU16((const uint16_t*)text, length >> 1, "glyphs"); |
| 61 | break; |
| 62 | case SkPaint::kUTF32_TextEncoding: |
| 63 | break; |
| 64 | } |
| 65 | } |
| 66 | |
reed@google.com | 9a73104 | 2013-05-21 17:52:33 +0000 | [diff] [blame] | 67 | /////////////////////////////////////////////////////////////////////////////// |
| 68 | |
mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 69 | void SkLuaCanvas::pushThis() { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 70 | SkLua(fL).pushCanvas(this); |
mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | /////////////////////////////////////////////////////////////////////////////// |
| 74 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 75 | static SkBitmap make_bm(int width, int height) { |
| 76 | SkBitmap bm; |
| 77 | bm.setConfig(SkBitmap::kNo_Config, width, height); |
| 78 | return bm; |
| 79 | } |
| 80 | |
| 81 | SkLuaCanvas::SkLuaCanvas(int width, int height, lua_State* L, const char func[]) |
| 82 | : INHERITED(make_bm(width, height)) |
| 83 | , fL(L) |
| 84 | , fFunc(func) { |
| 85 | } |
| 86 | |
| 87 | SkLuaCanvas::~SkLuaCanvas() {} |
| 88 | |
| 89 | int SkLuaCanvas::save(SaveFlags flags) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 90 | AUTO_LUA("save"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 91 | return this->INHERITED::save(flags); |
| 92 | } |
| 93 | |
| 94 | int SkLuaCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 95 | SaveFlags flags) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 96 | AUTO_LUA("saveLayer"); |
| 97 | if (bounds) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 98 | lua.pushRect(*bounds, "bounds"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 99 | } |
| 100 | if (paint) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 101 | lua.pushPaint(*paint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 102 | } |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 103 | return this->INHERITED::save(flags); |
| 104 | } |
| 105 | |
| 106 | void SkLuaCanvas::restore() { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 107 | AUTO_LUA("restore"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 108 | this->INHERITED::restore(); |
| 109 | } |
| 110 | |
| 111 | bool SkLuaCanvas::translate(SkScalar dx, SkScalar dy) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 112 | AUTO_LUA("translate"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 113 | lua.pushScalar(dx, "dx"); |
| 114 | lua.pushScalar(dy, "dy"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 115 | return this->INHERITED::translate(dx, dy); |
| 116 | } |
| 117 | |
| 118 | bool SkLuaCanvas::scale(SkScalar sx, SkScalar sy) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 119 | AUTO_LUA("scale"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 120 | lua.pushScalar(sx, "sx"); |
| 121 | lua.pushScalar(sy, "sy"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 122 | return this->INHERITED::scale(sx, sy); |
| 123 | } |
| 124 | |
| 125 | bool SkLuaCanvas::rotate(SkScalar degrees) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 126 | AUTO_LUA("rotate"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 127 | lua.pushScalar(degrees, "degrees"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 128 | return this->INHERITED::rotate(degrees); |
| 129 | } |
| 130 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 131 | bool SkLuaCanvas::skew(SkScalar kx, SkScalar ky) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 132 | AUTO_LUA("skew"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 133 | lua.pushScalar(kx, "kx"); |
| 134 | lua.pushScalar(ky, "ky"); |
| 135 | return this->INHERITED::skew(kx, ky); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | bool SkLuaCanvas::concat(const SkMatrix& matrix) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 139 | AUTO_LUA("concat"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 140 | return this->INHERITED::concat(matrix); |
| 141 | } |
| 142 | |
| 143 | void SkLuaCanvas::setMatrix(const SkMatrix& matrix) { |
| 144 | this->INHERITED::setMatrix(matrix); |
| 145 | } |
| 146 | |
| 147 | bool SkLuaCanvas::clipRect(const SkRect& r, SkRegion::Op op, bool doAA) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 148 | AUTO_LUA("clipRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 149 | lua.pushRect(r, "rect"); |
| 150 | lua.pushBool(doAA, "aa"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 151 | return this->INHERITED::clipRect(r, op, doAA); |
| 152 | } |
| 153 | |
| 154 | bool SkLuaCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 155 | AUTO_LUA("clipRRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 156 | lua.pushRRect(rrect, "rrect"); |
| 157 | lua.pushBool(doAA, "aa"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 158 | return this->INHERITED::clipRRect(rrect, op, doAA); |
| 159 | } |
| 160 | |
| 161 | bool SkLuaCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 162 | AUTO_LUA("clipPath"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 163 | lua.pushPath(path, "path"); |
| 164 | lua.pushBool(doAA, "aa"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 165 | return this->INHERITED::clipPath(path, op, doAA); |
| 166 | } |
| 167 | |
| 168 | bool SkLuaCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 169 | AUTO_LUA("clipRegion"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 170 | return this->INHERITED::clipRegion(deviceRgn, op); |
| 171 | } |
| 172 | |
| 173 | void SkLuaCanvas::drawPaint(const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 174 | AUTO_LUA("drawPaint"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 175 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void SkLuaCanvas::drawPoints(PointMode mode, size_t count, |
| 179 | const SkPoint pts[], const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 180 | AUTO_LUA("drawPoints"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 181 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | void SkLuaCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 185 | AUTO_LUA("drawOval"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 186 | lua.pushRect(rect, "rect"); |
| 187 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 188 | } |
| 189 | |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 190 | void SkLuaCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 191 | AUTO_LUA("drawRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 192 | lua.pushRect(rect, "rect"); |
| 193 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | void SkLuaCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 197 | AUTO_LUA("drawRRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 198 | lua.pushRRect(rrect, "rrect"); |
| 199 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 200 | } |
| 201 | |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 202 | void SkLuaCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 203 | AUTO_LUA("drawPath"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 204 | lua.pushPath(path, "path"); |
| 205 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | void SkLuaCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 209 | const SkPaint* paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 210 | AUTO_LUA("drawBitmap"); |
| 211 | if (paint) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 212 | lua.pushPaint(*paint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 213 | } |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void SkLuaCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 217 | const SkRect& dst, const SkPaint* paint, |
| 218 | DrawBitmapRectFlags flags) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 219 | AUTO_LUA("drawBitmapRectToRect"); |
| 220 | if (paint) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 221 | lua.pushPaint(*paint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 222 | } |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | void SkLuaCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 226 | const SkPaint* paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 227 | AUTO_LUA("drawBitmapMatrix"); |
| 228 | if (paint) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 229 | lua.pushPaint(*paint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 230 | } |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | void SkLuaCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
| 234 | const SkPaint* paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 235 | AUTO_LUA("drawSprite"); |
| 236 | if (paint) { |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 237 | lua.pushPaint(*paint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 238 | } |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void SkLuaCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
| 242 | SkScalar y, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 243 | AUTO_LUA("drawText"); |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 244 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 245 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | void SkLuaCanvas::drawPosText(const void* text, size_t byteLength, |
| 249 | const SkPoint pos[], const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 250 | AUTO_LUA("drawPosText"); |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 251 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 252 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | void SkLuaCanvas::drawPosTextH(const void* text, size_t byteLength, |
| 256 | const SkScalar xpos[], SkScalar constY, |
| 257 | const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 258 | AUTO_LUA("drawPosTextH"); |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 259 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 260 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void SkLuaCanvas::drawTextOnPath(const void* text, size_t byteLength, |
| 264 | const SkPath& path, const SkMatrix* matrix, |
| 265 | const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 266 | AUTO_LUA("drawTextOnPath"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 267 | lua.pushPath(path, "path"); |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 268 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 269 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | void SkLuaCanvas::drawPicture(SkPicture& picture) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 273 | AUTO_LUA("drawPicture"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 274 | // call through so we can see the nested picture ops |
| 275 | this->INHERITED::drawPicture(picture); |
| 276 | } |
| 277 | |
| 278 | void SkLuaCanvas::drawVertices(VertexMode vmode, int vertexCount, |
| 279 | const SkPoint vertices[], const SkPoint texs[], |
| 280 | const SkColor colors[], SkXfermode* xmode, |
| 281 | const uint16_t indices[], int indexCount, |
| 282 | const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 283 | AUTO_LUA("drawVertices"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 284 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | void SkLuaCanvas::drawData(const void* data, size_t length) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 288 | AUTO_LUA("drawData"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 289 | } |