blob: 9bc109ee1498a7caa1afd48037602e6bdbf31578 [file] [log] [blame]
reed@google.comdff7e112013-05-15 19:34:20 +00001/*
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
14struct lua_State;
15
16class SkLuaCanvas : public SkCanvas {
17public:
mike@reedtribe.orgf02fe3d2013-05-21 12:20:39 +000018 void pushThis();
19
reed@google.comdff7e112013-05-15 19:34:20 +000020 SkLuaCanvas(int width, int height, lua_State*, const char function[]);
21 virtual ~SkLuaCanvas();
22
reed@google.comdff7e112013-05-15 19:34:20 +000023 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
24 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
25 virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
26 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
27 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
28 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
skia.committer@gmail.com539f3642013-05-16 07:01:00 +000029
reed@google.comdff7e112013-05-15 19:34:20 +000030 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
31 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
32 const SkPaint& paint) SK_OVERRIDE;
33 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000034 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000035 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000036 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000037 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
38 const SkPaint* paint) SK_OVERRIDE;
39 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +000040 const SkRect& dst, const SkPaint* paint,
41 DrawBitmapRectFlags flags) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000042 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
43 const SkPaint* paint) SK_OVERRIDE;
44 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
45 const SkPaint* paint) SK_OVERRIDE;
46 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
47 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
48 virtual void drawPosText(const void* text, size_t byteLength,
49 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
50 virtual void drawPosTextH(const void* text, size_t byteLength,
51 const SkScalar xpos[], SkScalar constY,
52 const SkPaint& paint) SK_OVERRIDE;
53 virtual void drawTextOnPath(const void* text, size_t byteLength,
54 const SkPath& path, const SkMatrix* matrix,
55 const SkPaint& paint) SK_OVERRIDE;
56 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
57 virtual void drawVertices(VertexMode vmode, int vertexCount,
58 const SkPoint vertices[], const SkPoint texs[],
59 const SkColor colors[], SkXfermode* xmode,
60 const uint16_t indices[], int indexCount,
61 const SkPaint& paint) SK_OVERRIDE;
62 virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
63
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000064protected:
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000065 virtual void willSave(SaveFlags) SK_OVERRIDE;
66 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
67 virtual void willRestore() SK_OVERRIDE;
68
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000069 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
70
robertphillips@google.com8f90a892014-02-28 18:19:39 +000071 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
72 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
73 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
74 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
75
reed@google.comdff7e112013-05-15 19:34:20 +000076private:
77 lua_State* fL;
78 SkString fFunc;
skia.committer@gmail.com539f3642013-05-16 07:01:00 +000079
reed@google.comdff7e112013-05-15 19:34:20 +000080 void sendverb(const char verb[]);
81
82 typedef SkCanvas INHERITED;
83};
84
85#endif