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