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 | #ifndef SkLuaCanvas_DEFINED |
| 9 | #define SkLuaCanvas_DEFINED |
| 10 | |
| 11 | #include "SkCanvas.h" |
| 12 | #include "SkString.h" |
| 13 | |
| 14 | struct lua_State; |
| 15 | |
| 16 | class SkLuaCanvas : public SkCanvas { |
| 17 | public: |
mike@reedtribe.org | f02fe3d | 2013-05-21 12:20:39 +0000 | [diff] [blame] | 18 | void pushThis(); |
| 19 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 20 | SkLuaCanvas(int width, int height, lua_State*, const char function[]); |
| 21 | virtual ~SkLuaCanvas(); |
| 22 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 23 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 24 | void willSave() override; |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 25 | SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 26 | void willRestore() override; |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 27 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 28 | void didConcat(const SkMatrix&) override; |
| 29 | void didSetMatrix(const SkMatrix&) override; |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 30 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 31 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 32 | virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 33 | const SkPaint&) override; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 34 | virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 35 | const SkPaint&) override; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 36 | virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 37 | SkScalar constY, const SkPaint&) override; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 38 | virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 39 | const SkMatrix* matrix, const SkPaint&) override; |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 40 | virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | const SkPaint& paint) override; |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 42 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 43 | void onDrawPaint(const SkPaint&) override; |
| 44 | void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override; |
| 45 | void onDrawRect(const SkRect&, const SkPaint&) override; |
| 46 | void onDrawOval(const SkRect&, const SkPaint&) override; |
| 47 | void onDrawRRect(const SkRRect&, const SkPaint&) override; |
| 48 | void onDrawPath(const SkPath&, const SkPaint&) override; |
| 49 | void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 50 | void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 51 | SrcRectConstraint) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 52 | void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 53 | void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 54 | const SkPaint*, SrcRectConstraint) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 55 | void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 56 | const SkPaint*) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 57 | void onDrawVertices(VertexMode vmode, int vertexCount, |
| 58 | const SkPoint vertices[], const SkPoint texs[], |
| 59 | const SkColor colors[], SkXfermode* xmode, |
| 60 | const uint16_t indices[], int indexCount, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 61 | const SkPaint&) override; |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 62 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 63 | void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 64 | void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; |
| 65 | void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; |
| 66 | void onClipRegion(const SkRegion&, SkRegion::Op) override; |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 67 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 68 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 69 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 70 | private: |
| 71 | lua_State* fL; |
| 72 | SkString fFunc; |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 73 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 74 | void sendverb(const char verb[]); |
| 75 | |
| 76 | typedef SkCanvas INHERITED; |
| 77 | }; |
| 78 | |
| 79 | #endif |