blob: 3efbdb95bcd010496ac33b4a0da7da062b904134 [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 void drawPaint(const SkPaint& paint) SK_OVERRIDE;
24 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
25 const SkPaint& paint) SK_OVERRIDE;
26 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000027 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000028 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000029 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000030 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
31 const SkPaint* paint) SK_OVERRIDE;
32 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +000033 const SkRect& dst, const SkPaint* paint,
34 DrawBitmapRectFlags flags) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000035 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
36 const SkPaint* paint) SK_OVERRIDE;
37 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
38 const SkPaint* paint) SK_OVERRIDE;
reed@google.comdff7e112013-05-15 19:34:20 +000039 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
40 virtual void drawVertices(VertexMode vmode, int vertexCount,
41 const SkPoint vertices[], const SkPoint texs[],
42 const SkColor colors[], SkXfermode* xmode,
43 const uint16_t indices[], int indexCount,
44 const SkPaint& paint) SK_OVERRIDE;
45 virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
46
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000047protected:
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000048 virtual void willSave(SaveFlags) SK_OVERRIDE;
49 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) SK_OVERRIDE;
50 virtual void willRestore() SK_OVERRIDE;
51
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000052 virtual void didConcat(const SkMatrix&) SK_OVERRIDE;
53 virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
54
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000055 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
reed@google.come0d9ce82014-04-23 04:00:17 +000056 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
57 const SkPaint&) SK_OVERRIDE;
58 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
59 const SkPaint&) SK_OVERRIDE;
60 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
61 SkScalar constY, const SkPaint&) SK_OVERRIDE;
62 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
63 const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE;
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000064
robertphillips@google.com8f90a892014-02-28 18:19:39 +000065 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
66 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
67 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
68 virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE;
69
reed@google.comdff7e112013-05-15 19:34:20 +000070private:
71 lua_State* fL;
72 SkString fFunc;
skia.committer@gmail.com539f3642013-05-16 07:01:00 +000073
reed@google.comdff7e112013-05-15 19:34:20 +000074 void sendverb(const char verb[]);
75
76 typedef SkCanvas INHERITED;
77};
78
79#endif