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 "SkCanvas.h" 12 #include "SkString.h" 13 14 struct lua_State; 15 16 class SkLuaCanvas : public SkCanvas { 17 public: 18 void pushThis(); 19 20 SkLuaCanvas(int width, int height, lua_State*, const char function[]); 21 virtual ~SkLuaCanvas(); 22 23 protected: 24 void willSave() override; 25 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; 26 void willRestore() override; 27 28 void didConcat(const SkMatrix&) override; 29 void didSetMatrix(const SkMatrix&) override; 30 31 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override; 32 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, 33 const SkPaint&) override; 34 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 35 const SkPaint&) override; 36 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 37 SkScalar constY, const SkPaint&) override; 38 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 39 const SkMatrix* matrix, const SkPaint&) override; 40 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 41 const SkPaint& paint) override; 42 43 void onDrawPaint(const SkPaint&) override; 44 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override; 45 void onDrawRect(const SkRect&, const SkPaint&) override; 46 void onDrawOval(const SkRect&, const SkPaint&) override; 47 void onDrawRRect(const SkRRect&, const SkPaint&) override; 48 void onDrawPath(const SkPath&, const SkPaint&) override; 49 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override; 50 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*, 51 SrcRectConstraint) override; 52 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override; 53 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst, 54 const SkPaint*, SrcRectConstraint) override; 55 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 56 const SkPaint*) override; 57 void onDrawVertices(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&) override; 62 63 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; 64 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; 65 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; 66 void onClipRegion(const SkRegion&, SkRegion::Op) override; 67 68 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override; 69 70 private: 71 lua_State* fL; 72 SkString fFunc; 73 74 void sendverb(const char verb[]); 75 76 typedef SkCanvas INHERITED; 77 }; 78 79 #endif 80