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" |
Hal Canary | ee08b4a | 2018-03-01 15:56:37 -0500 | [diff] [blame] | 9 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 10 | #include "SkLua.h" |
Hal Canary | ee08b4a | 2018-03-01 15:56:37 -0500 | [diff] [blame] | 11 | #include "SkStringUtils.h" |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 12 | #include "SkTo.h" |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 13 | |
| 14 | extern "C" { |
| 15 | #include "lua.h" |
mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 16 | #include "lauxlib.h" |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 17 | } |
| 18 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 19 | class AutoCallLua : public SkLua { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 20 | public: |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 21 | 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] | 22 | lua_getglobal(L, func); |
| 23 | if (!lua_isfunction(L, -1)) { |
| 24 | int t = lua_type(L, -1); |
| 25 | SkDebugf("--- expected function %d\n", t); |
| 26 | } |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 27 | |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 28 | lua_newtable(L); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 29 | this->pushString(verb, "verb"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | ~AutoCallLua() { |
reed@google.com | 3597b73 | 2013-05-22 20:12:50 +0000 | [diff] [blame] | 33 | lua_State* L = this->get(); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 34 | if (lua_pcall(L, 1, 0, 0) != LUA_OK) { |
| 35 | SkDebugf("lua err: %s\n", lua_tostring(L, -1)); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 36 | } |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 37 | lua_settop(L, -1); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 40 | void pushEncodedText(SkTextEncoding, const void*, size_t); |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 41 | |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 42 | private: |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 43 | typedef SkLua INHERITED; |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 46 | #define AUTO_LUA(verb) AutoCallLua lua(fL, fFunc.c_str(), verb) |
reed@google.com | 9a73104 | 2013-05-21 17:52:33 +0000 | [diff] [blame] | 47 | |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 48 | |
| 49 | /////////////////////////////////////////////////////////////////////////////// |
| 50 | |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 51 | void AutoCallLua::pushEncodedText(SkTextEncoding enc, const void* text, size_t length) { |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 52 | switch (enc) { |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 53 | case kUTF8_SkTextEncoding: |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 54 | this->pushString((const char*)text, length, "text"); |
| 55 | break; |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 56 | case kUTF16_SkTextEncoding: |
Hal Canary | ee08b4a | 2018-03-01 15:56:37 -0500 | [diff] [blame] | 57 | this->pushString(SkStringFromUTF16((const uint16_t*)text, length), "text"); |
| 58 | break; |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 59 | case kGlyphID_SkTextEncoding: |
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; |
Mike Reed | 97f3cc2 | 2018-12-03 09:45:17 -0500 | [diff] [blame] | 63 | case kUTF32_SkTextEncoding: |
reed@google.com | e3823fd | 2013-05-30 18:55:14 +0000 | [diff] [blame] | 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 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 84 | void SkLuaCanvas::willSave() { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 85 | AUTO_LUA("save"); |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 86 | this->INHERITED::willSave(); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 87 | } |
| 88 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 89 | SkCanvas::SaveLayerStrategy SkLuaCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 90 | AUTO_LUA("saveLayer"); |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 91 | if (rec.fBounds) { |
| 92 | lua.pushRect(*rec.fBounds, "bounds"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 93 | } |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 94 | if (rec.fPaint) { |
| 95 | lua.pushPaint(*rec.fPaint, "paint"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 96 | } |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 97 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 98 | (void)this->INHERITED::getSaveLayerStrategy(rec); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 99 | // No need for a layer. |
| 100 | return kNoLayer_SaveLayerStrategy; |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Mike Reed | 148b7fd | 2018-12-18 17:38:18 -0500 | [diff] [blame] | 103 | bool SkLuaCanvas::onDoSaveBehind(const SkRect*) { |
| 104 | // TODO |
| 105 | return false; |
| 106 | } |
| 107 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 108 | void SkLuaCanvas::willRestore() { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 109 | AUTO_LUA("restore"); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 110 | this->INHERITED::willRestore(); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 111 | } |
| 112 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 113 | void SkLuaCanvas::didConcat(const SkMatrix& matrix) { |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 114 | switch (matrix.getType()) { |
| 115 | case SkMatrix::kTranslate_Mask: { |
| 116 | AUTO_LUA("translate"); |
| 117 | lua.pushScalar(matrix.getTranslateX(), "dx"); |
| 118 | lua.pushScalar(matrix.getTranslateY(), "dy"); |
| 119 | break; |
| 120 | } |
| 121 | case SkMatrix::kScale_Mask: { |
| 122 | AUTO_LUA("scale"); |
| 123 | lua.pushScalar(matrix.getScaleX(), "sx"); |
| 124 | lua.pushScalar(matrix.getScaleY(), "sy"); |
| 125 | break; |
| 126 | } |
| 127 | default: { |
| 128 | AUTO_LUA("concat"); |
commit-bot@chromium.org | ab885be | 2014-05-13 20:32:32 +0000 | [diff] [blame] | 129 | // pushMatrix added in https://codereview.chromium.org/203203004/ |
| 130 | // Doesn't seem to have ever been working correctly since added |
| 131 | // lua.pushMatrix(matrix); |
commit-bot@chromium.org | d9ea09e | 2014-03-25 17:32:26 +0000 | [diff] [blame] | 132 | break; |
| 133 | } |
| 134 | } |
| 135 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 136 | this->INHERITED::didConcat(matrix); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 137 | } |
| 138 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 139 | void SkLuaCanvas::didSetMatrix(const SkMatrix& matrix) { |
| 140 | this->INHERITED::didSetMatrix(matrix); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 143 | void SkLuaCanvas::onClipRect(const SkRect& r, SkClipOp op, ClipEdgeStyle edgeStyle) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 144 | AUTO_LUA("clipRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 145 | lua.pushRect(r, "rect"); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 146 | lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); |
| 147 | this->INHERITED::onClipRect(r, op, edgeStyle); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 150 | void SkLuaCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 151 | AUTO_LUA("clipRRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 152 | lua.pushRRect(rrect, "rrect"); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 153 | lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); |
| 154 | this->INHERITED::onClipRRect(rrect, op, edgeStyle); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 157 | void SkLuaCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 158 | AUTO_LUA("clipPath"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 159 | lua.pushPath(path, "path"); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 160 | lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); |
| 161 | this->INHERITED::onClipPath(path, op, edgeStyle); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 164 | void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 165 | AUTO_LUA("clipRegion"); |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 166 | this->INHERITED::onClipRegion(deviceRgn, op); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 167 | } |
| 168 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 169 | void SkLuaCanvas::onDrawPaint(const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 170 | AUTO_LUA("drawPaint"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 171 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 172 | } |
| 173 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 174 | void SkLuaCanvas::onDrawPoints(PointMode mode, size_t count, |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 175 | const SkPoint pts[], const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 176 | AUTO_LUA("drawPoints"); |
commit-bot@chromium.org | 2cfa320 | 2014-04-19 22:00:40 +0000 | [diff] [blame] | 177 | lua.pushArrayPoint(pts, SkToInt(count), "points"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 178 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 179 | } |
| 180 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 181 | void SkLuaCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 182 | AUTO_LUA("drawOval"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 183 | lua.pushRect(rect, "rect"); |
| 184 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 185 | } |
| 186 | |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 187 | void SkLuaCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle, |
| 188 | bool useCenter, const SkPaint& paint) { |
| 189 | AUTO_LUA("drawArc"); |
| 190 | lua.pushRect(rect, "rect"); |
| 191 | lua.pushScalar(startAngle, "startAngle"); |
| 192 | lua.pushScalar(sweepAngle, "sweepAngle"); |
| 193 | lua.pushBool(useCenter, "useCenter"); |
| 194 | lua.pushPaint(paint, "paint"); |
| 195 | } |
| 196 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 197 | void SkLuaCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 198 | AUTO_LUA("drawRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 199 | lua.pushRect(rect, "rect"); |
| 200 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 201 | } |
| 202 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 203 | void SkLuaCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 204 | AUTO_LUA("drawRRect"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 205 | lua.pushRRect(rrect, "rrect"); |
| 206 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 207 | } |
| 208 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 209 | void SkLuaCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
| 210 | const SkPaint& paint) { |
| 211 | AUTO_LUA("drawDRRect"); |
| 212 | lua.pushRRect(outer, "outer"); |
| 213 | lua.pushRRect(inner, "inner"); |
| 214 | lua.pushPaint(paint, "paint"); |
| 215 | } |
| 216 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 217 | void SkLuaCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 218 | AUTO_LUA("drawPath"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 219 | lua.pushPath(path, "path"); |
| 220 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 221 | } |
| 222 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 223 | void SkLuaCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
| 224 | const SkPaint* paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 225 | AUTO_LUA("drawBitmap"); |
| 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 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 231 | void SkLuaCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 232 | const SkPaint* paint, SrcRectConstraint) { |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 233 | AUTO_LUA("drawBitmapRect"); |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 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 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 239 | void SkLuaCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, |
| 240 | const SkPaint* paint) { |
| 241 | AUTO_LUA("drawBitmapNine"); |
| 242 | if (paint) { |
| 243 | lua.pushPaint(*paint, "paint"); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | void SkLuaCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) { |
| 248 | AUTO_LUA("drawImage"); |
| 249 | if (paint) { |
| 250 | lua.pushPaint(*paint, "paint"); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | void SkLuaCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 255 | const SkPaint* paint, SrcRectConstraint) { |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 256 | AUTO_LUA("drawImageRect"); |
| 257 | if (paint) { |
| 258 | lua.pushPaint(*paint, "paint"); |
| 259 | } |
| 260 | } |
| 261 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 262 | void SkLuaCanvas::onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, |
| 263 | const SkPaint &paint) { |
| 264 | AUTO_LUA("drawTextBlob"); |
| 265 | lua.pushTextBlob(blob, "blob"); |
| 266 | lua.pushScalar(x, "x"); |
| 267 | lua.pushScalar(y, "y"); |
| 268 | lua.pushPaint(paint, "paint"); |
| 269 | } |
| 270 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 271 | void SkLuaCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
| 272 | const SkPaint* paint) { |
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 |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 275 | this->INHERITED::onDrawPicture(picture, matrix, paint); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Florin Malita | adaeaed | 2017-09-21 15:28:29 -0400 | [diff] [blame] | 278 | void SkLuaCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) { |
| 279 | AUTO_LUA("drawDrawable"); |
| 280 | // call through so we can see the nested ops |
| 281 | this->INHERITED::onDrawDrawable(drawable, matrix); |
| 282 | } |
| 283 | |
Ruiqi Mao | c97a339 | 2018-08-15 10:44:19 -0400 | [diff] [blame] | 284 | void SkLuaCanvas::onDrawVerticesObject(const SkVertices*, const SkVertices::Bone[], int, |
| 285 | SkBlendMode, const SkPaint& paint) { |
mike@reedtribe.org | 1c5a94f | 2013-05-16 04:20:23 +0000 | [diff] [blame] | 286 | AUTO_LUA("drawVertices"); |
reed@google.com | 74ce6f0 | 2013-05-22 15:13:18 +0000 | [diff] [blame] | 287 | lua.pushPaint(paint, "paint"); |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 288 | } |