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 | |
| 23 | virtual int save(SaveFlags flags) SK_OVERRIDE; |
| 24 | virtual int saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 25 | SaveFlags flags) SK_OVERRIDE; |
| 26 | virtual void restore() SK_OVERRIDE; |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 27 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 28 | virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE; |
| 29 | virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE; |
| 30 | virtual bool rotate(SkScalar degrees) SK_OVERRIDE; |
| 31 | virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; |
| 32 | virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; |
| 33 | virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 34 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 35 | virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE; |
| 36 | virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE; |
| 37 | virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE; |
| 38 | virtual bool clipRegion(const SkRegion& deviceRgn, |
| 39 | SkRegion::Op) SK_OVERRIDE; |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 40 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 41 | virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
| 42 | virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[], |
| 43 | const SkPaint& paint) SK_OVERRIDE; |
| 44 | virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE; |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 45 | virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE; |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 46 | virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE; |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 47 | virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 48 | virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 49 | const SkPaint* paint) SK_OVERRIDE; |
| 50 | virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 51 | const SkRect& dst, const SkPaint* paint, |
| 52 | DrawBitmapRectFlags flags) SK_OVERRIDE; |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 53 | virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
| 54 | const SkPaint* paint) SK_OVERRIDE; |
| 55 | virtual void drawSprite(const SkBitmap& bitmap, int left, int top, |
| 56 | const SkPaint* paint) SK_OVERRIDE; |
| 57 | virtual void drawText(const void* text, size_t byteLength, SkScalar x, |
| 58 | SkScalar y, const SkPaint& paint) SK_OVERRIDE; |
| 59 | virtual void drawPosText(const void* text, size_t byteLength, |
| 60 | const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE; |
| 61 | virtual void drawPosTextH(const void* text, size_t byteLength, |
| 62 | const SkScalar xpos[], SkScalar constY, |
| 63 | const SkPaint& paint) SK_OVERRIDE; |
| 64 | virtual void drawTextOnPath(const void* text, size_t byteLength, |
| 65 | const SkPath& path, const SkMatrix* matrix, |
| 66 | const SkPaint& paint) SK_OVERRIDE; |
| 67 | virtual void drawPicture(SkPicture&) SK_OVERRIDE; |
| 68 | virtual void drawVertices(VertexMode vmode, int vertexCount, |
| 69 | const SkPoint vertices[], const SkPoint texs[], |
| 70 | const SkColor colors[], SkXfermode* xmode, |
| 71 | const uint16_t indices[], int indexCount, |
| 72 | const SkPaint& paint) SK_OVERRIDE; |
| 73 | virtual void drawData(const void* data, size_t length) SK_OVERRIDE; |
| 74 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 75 | protected: |
| 76 | virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; |
| 77 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 78 | private: |
| 79 | lua_State* fL; |
| 80 | SkString fFunc; |
skia.committer@gmail.com | 539f364 | 2013-05-16 07:01:00 +0000 | [diff] [blame] | 81 | |
reed@google.com | dff7e11 | 2013-05-15 19:34:20 +0000 | [diff] [blame] | 82 | void sendverb(const char verb[]); |
| 83 | |
| 84 | typedef SkCanvas INHERITED; |
| 85 | }; |
| 86 | |
| 87 | #endif |