• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/core/SkCanvas.h"
12 #include "include/core/SkString.h"
13 #include "include/core/SkVertices.h"
14 
15 struct lua_State;
16 
17 class SkLuaCanvas : public SkCanvas {
18 public:
19     void pushThis();
20 
21     SkLuaCanvas(int width, int height, lua_State*, const char function[]);
22     ~SkLuaCanvas() override;
23 
24 protected:
25     void willSave() override;
26     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
27     bool onDoSaveBehind(const SkRect*) override;
28     void willRestore() override;
29 
30     void didConcat44(const SkScalar[16]) override;
31     void didConcat(const SkMatrix&) override;
32     void didSetMatrix(const SkMatrix&) override;
33     void didScale(SkScalar, SkScalar) override;
34     void didTranslate(SkScalar, SkScalar) override;
35 
36     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
37     virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
38                                 const SkPaint& paint) override;
39 
40     void onDrawPaint(const SkPaint&) override;
41     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
42     void onDrawRect(const SkRect&, const SkPaint&) override;
43     void onDrawOval(const SkRect&, const SkPaint&) override;
44     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
45     void onDrawRRect(const SkRRect&, const SkPaint&) override;
46     void onDrawPath(const SkPath&, const SkPaint&) override;
47     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
48     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
49                           SrcRectConstraint) override;
50     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
51     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
52                          const SkPaint*, SrcRectConstraint) override;
53     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
54                           const SkPaint*) override;
55     void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
56                               SkBlendMode, const SkPaint&) override;
57 
58     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
59     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
60     void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
61     void onClipRegion(const SkRegion&, SkClipOp) override;
62 
63     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
64     void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
65 
66 private:
67     lua_State*  fL;
68     SkString    fFunc;
69 
70     void sendverb(const char verb[]);
71 
72     typedef SkCanvas INHERITED;
73 };
74 
75 #endif
76