• 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 didConcat(const SkMatrix&) override;
31     void didSetMatrix(const SkMatrix&) override;
32 
33     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
34     virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
35                                 const SkPaint& paint) override;
36 
37     void onDrawPaint(const SkPaint&) override;
38     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
39     void onDrawRect(const SkRect&, const SkPaint&) override;
40     void onDrawOval(const SkRect&, const SkPaint&) override;
41     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
42     void onDrawRRect(const SkRRect&, const SkPaint&) override;
43     void onDrawPath(const SkPath&, const SkPaint&) override;
44     void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
45     void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
46                           SrcRectConstraint) override;
47     void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
48     void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
49                          const SkPaint*, SrcRectConstraint) override;
50     void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
51                           const SkPaint*) override;
52     void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
53                               SkBlendMode, const SkPaint&) override;
54 
55     void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
56     void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
57     void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
58     void onClipRegion(const SkRegion&, SkClipOp) override;
59 
60     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
61     void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
62 
63 private:
64     lua_State*  fL;
65     SkString    fFunc;
66 
67     void sendverb(const char verb[]);
68 
69     typedef SkCanvas INHERITED;
70 };
71 
72 #endif
73