| 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: |
| reed@google.com | 7fa2a65 | 2014-01-27 13:42:58 +0000 | [diff] [blame^] | 60 | this->pushArrayU16((const uint16_t*)text, SkToInt(length >> 1), |
| 61 | "glyphs"); |
| reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 62 | break; |
| 63 | case SkPaint::kUTF32_TextEncoding: |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | |
| reed@google.com | 9a73104 | 2013-05-21 17:52:33 +0000 | [diff] [blame] | 68 | /////////////////////////////////////////////////////////////////////////////// |
| 69 | |
| mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 70 | void SkLuaCanvas::pushThis() { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 71 | SkLua(fL).pushCanvas(this); |
| mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /////////////////////////////////////////////////////////////////////////////// |
| 75 | |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 76 | static SkBitmap make_bm(int width, int height) { |
| 77 | SkBitmap bm; |
| 78 | bm.setConfig(SkBitmap::kNo_Config, width, height); |
| 79 | return bm; |
| 80 | } |
| 81 | |
| 82 | SkLuaCanvas::SkLuaCanvas(int width, int height, lua_State* L, const char func[]) |
| 83 | : INHERITED(make_bm(width, height)) |
| 84 | , fL(L) |
| 85 | , fFunc(func) { |
| 86 | } |
| 87 | |
| 88 | SkLuaCanvas::~SkLuaCanvas() {} |
| 89 | |
| 90 | int SkLuaCanvas::save(SaveFlags flags) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 91 | AUTO_LUA("save"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 92 | return this->INHERITED::save(flags); |
| 93 | } |
| 94 | |
| 95 | int SkLuaCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 96 | SaveFlags flags) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 97 | AUTO_LUA("saveLayer"); |
| 98 | if (bounds) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 99 | lua.pushRect(*bounds, "bounds"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 100 | } |
| 101 | if (paint) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 102 | lua.pushPaint(*paint, "paint"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 103 | } |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 104 | return this->INHERITED::save(flags); |
| 105 | } |
| 106 | |
| 107 | void SkLuaCanvas::restore() { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 108 | AUTO_LUA("restore"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 109 | this->INHERITED::restore(); |
| 110 | } |
| 111 | |
| 112 | bool SkLuaCanvas::translate(SkScalar dx, SkScalar dy) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 113 | AUTO_LUA("translate"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 114 | lua.pushScalar(dx, "dx"); |
| 115 | lua.pushScalar(dy, "dy"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 116 | return this->INHERITED::translate(dx, dy); |
| 117 | } |
| 118 | |
| 119 | bool SkLuaCanvas::scale(SkScalar sx, SkScalar sy) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 120 | AUTO_LUA("scale"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 121 | lua.pushScalar(sx, "sx"); |
| 122 | lua.pushScalar(sy, "sy"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 123 | return this->INHERITED::scale(sx, sy); |
| 124 | } |
| 125 | |
| 126 | bool SkLuaCanvas::rotate(SkScalar degrees) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 127 | AUTO_LUA("rotate"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 128 | lua.pushScalar(degrees, "degrees"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 129 | return this->INHERITED::rotate(degrees); |
| 130 | } |
| 131 | |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 132 | bool SkLuaCanvas::skew(SkScalar kx, SkScalar ky) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 133 | AUTO_LUA("skew"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 134 | lua.pushScalar(kx, "kx"); |
| 135 | lua.pushScalar(ky, "ky"); |
| 136 | return this->INHERITED::skew(kx, ky); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | bool SkLuaCanvas::concat(const SkMatrix& matrix) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 140 | AUTO_LUA("concat"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 141 | return this->INHERITED::concat(matrix); |
| 142 | } |
| 143 | |
| 144 | void SkLuaCanvas::setMatrix(const SkMatrix& matrix) { |
| 145 | this->INHERITED::setMatrix(matrix); |
| 146 | } |
| 147 | |
| 148 | bool SkLuaCanvas::clipRect(const SkRect& r, SkRegion::Op op, bool doAA) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 149 | AUTO_LUA("clipRect"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 150 | lua.pushRect(r, "rect"); |
| 151 | lua.pushBool(doAA, "aa"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 152 | return this->INHERITED::clipRect(r, op, doAA); |
| 153 | } |
| 154 | |
| 155 | bool SkLuaCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 156 | AUTO_LUA("clipRRect"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 157 | lua.pushRRect(rrect, "rrect"); |
| 158 | lua.pushBool(doAA, "aa"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 159 | return this->INHERITED::clipRRect(rrect, op, doAA); |
| 160 | } |
| 161 | |
| 162 | bool SkLuaCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 163 | AUTO_LUA("clipPath"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 164 | lua.pushPath(path, "path"); |
| 165 | lua.pushBool(doAA, "aa"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 166 | return this->INHERITED::clipPath(path, op, doAA); |
| 167 | } |
| 168 | |
| 169 | bool SkLuaCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 170 | AUTO_LUA("clipRegion"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 171 | return this->INHERITED::clipRegion(deviceRgn, op); |
| 172 | } |
| 173 | |
| 174 | void SkLuaCanvas::drawPaint(const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 175 | AUTO_LUA("drawPaint"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 176 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | void SkLuaCanvas::drawPoints(PointMode mode, size_t count, |
| 180 | const SkPoint pts[], const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 181 | AUTO_LUA("drawPoints"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 182 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | void SkLuaCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 186 | AUTO_LUA("drawOval"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 187 | lua.pushRect(rect, "rect"); |
| 188 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 191 | void SkLuaCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 192 | AUTO_LUA("drawRect"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 193 | lua.pushRect(rect, "rect"); |
| 194 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void SkLuaCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 198 | AUTO_LUA("drawRRect"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 199 | lua.pushRRect(rrect, "rrect"); |
| 200 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 203 | void SkLuaCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 204 | AUTO_LUA("drawPath"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 205 | lua.pushPath(path, "path"); |
| 206 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | void SkLuaCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 210 | const SkPaint* paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 211 | AUTO_LUA("drawBitmap"); |
| 212 | if (paint) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 213 | lua.pushPaint(*paint, "paint"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 214 | } |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | void SkLuaCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 218 | const SkRect& dst, const SkPaint* paint, |
| 219 | DrawBitmapRectFlags flags) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 220 | AUTO_LUA("drawBitmapRectToRect"); |
| 221 | if (paint) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 222 | lua.pushPaint(*paint, "paint"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 223 | } |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void SkLuaCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
| commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 227 | const SkPaint* paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 228 | AUTO_LUA("drawBitmapMatrix"); |
| 229 | if (paint) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 230 | lua.pushPaint(*paint, "paint"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 231 | } |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void SkLuaCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
| 235 | const SkPaint* paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 236 | AUTO_LUA("drawSprite"); |
| 237 | if (paint) { |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 238 | lua.pushPaint(*paint, "paint"); |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 239 | } |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | void SkLuaCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
| 243 | SkScalar y, const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 244 | AUTO_LUA("drawText"); |
| reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 245 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 246 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | void SkLuaCanvas::drawPosText(const void* text, size_t byteLength, |
| 250 | const SkPoint pos[], const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 251 | AUTO_LUA("drawPosText"); |
| reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 252 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 253 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | void SkLuaCanvas::drawPosTextH(const void* text, size_t byteLength, |
| 257 | const SkScalar xpos[], SkScalar constY, |
| 258 | const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 259 | AUTO_LUA("drawPosTextH"); |
| reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 260 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 261 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | void SkLuaCanvas::drawTextOnPath(const void* text, size_t byteLength, |
| 265 | const SkPath& path, const SkMatrix* matrix, |
| 266 | const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 267 | AUTO_LUA("drawTextOnPath"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 268 | lua.pushPath(path, "path"); |
| reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 269 | lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 270 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | void SkLuaCanvas::drawPicture(SkPicture& picture) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 274 | AUTO_LUA("drawPicture"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 275 | // call through so we can see the nested picture ops |
| 276 | this->INHERITED::drawPicture(picture); |
| 277 | } |
| 278 | |
| 279 | void SkLuaCanvas::drawVertices(VertexMode vmode, int vertexCount, |
| 280 | const SkPoint vertices[], const SkPoint texs[], |
| 281 | const SkColor colors[], SkXfermode* xmode, |
| 282 | const uint16_t indices[], int indexCount, |
| 283 | const SkPaint& paint) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 284 | AUTO_LUA("drawVertices"); |
| reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 285 | lua.pushPaint(paint, "paint"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void SkLuaCanvas::drawData(const void* data, size_t length) { |
| mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 289 | AUTO_LUA("drawData"); |
| reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 290 | } |