blob: 16ea5538ab1ae92c5c99c56d0a131c149f8b0d68 [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:
18 SkLuaCanvas(int width, int height, lua_State*, const char function[]);
19 virtual ~SkLuaCanvas();
20
21 virtual int save(SaveFlags flags) SK_OVERRIDE;
22 virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
23 SaveFlags flags) SK_OVERRIDE;
24 virtual void restore() SK_OVERRIDE;
25
26 virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
27 virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
28 virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
29 virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
30 virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
31 virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
32
33 virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
34 virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE;
35 virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
36 virtual bool clipRegion(const SkRegion& deviceRgn,
37 SkRegion::Op) SK_OVERRIDE;
38
39 virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
40 virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
41 const SkPaint& paint) SK_OVERRIDE;
42 virtual void drawOval(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
43 virtual void drawRect(const SkRect&, const SkPaint& paint) SK_OVERRIDE;
44 virtual void drawRRect(const SkRRect&, const SkPaint& paint) SK_OVERRIDE;
45 virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
46 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
47 const SkPaint* paint) SK_OVERRIDE;
48 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
49 const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
50 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
51 const SkPaint* paint) SK_OVERRIDE;
52 virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
53 const SkPaint* paint) SK_OVERRIDE;
54 virtual void drawText(const void* text, size_t byteLength, SkScalar x,
55 SkScalar y, const SkPaint& paint) SK_OVERRIDE;
56 virtual void drawPosText(const void* text, size_t byteLength,
57 const SkPoint pos[], const SkPaint& paint) SK_OVERRIDE;
58 virtual void drawPosTextH(const void* text, size_t byteLength,
59 const SkScalar xpos[], SkScalar constY,
60 const SkPaint& paint) SK_OVERRIDE;
61 virtual void drawTextOnPath(const void* text, size_t byteLength,
62 const SkPath& path, const SkMatrix* matrix,
63 const SkPaint& paint) SK_OVERRIDE;
64 virtual void drawPicture(SkPicture&) SK_OVERRIDE;
65 virtual void drawVertices(VertexMode vmode, int vertexCount,
66 const SkPoint vertices[], const SkPoint texs[],
67 const SkColor colors[], SkXfermode* xmode,
68 const uint16_t indices[], int indexCount,
69 const SkPaint& paint) SK_OVERRIDE;
70 virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
71
72private:
73 lua_State* fL;
74 SkString fFunc;
75
76 void sendverb(const char verb[]);
77
78 typedef SkCanvas INHERITED;
79};
80
81#endif