SkLuaCanvas.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #ifndef SkLuaCanvas_DEFINED
  8. #define SkLuaCanvas_DEFINED
  9. #include "SkCanvas.h"
  10. #include "SkString.h"
  11. #include "SkVertices.h"
  12. struct lua_State;
  13. class SkLuaCanvas : public SkCanvas {
  14. public:
  15. void pushThis();
  16. SkLuaCanvas(int width, int height, lua_State*, const char function[]);
  17. ~SkLuaCanvas() override;
  18. protected:
  19. void willSave() override;
  20. SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
  21. void willRestore() override;
  22. void didConcat(const SkMatrix&) override;
  23. void didSetMatrix(const SkMatrix&) override;
  24. void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
  25. virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
  26. const SkPaint&) override;
  27. virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
  28. const SkPaint&) override;
  29. virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
  30. SkScalar constY, const SkPaint&) override;
  31. void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
  32. const SkRect* cull, const SkPaint& paint) override;
  33. virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
  34. const SkPaint& paint) override;
  35. void onDrawPaint(const SkPaint&) override;
  36. void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
  37. void onDrawRect(const SkRect&, const SkPaint&) override;
  38. void onDrawOval(const SkRect&, const SkPaint&) override;
  39. void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
  40. void onDrawRRect(const SkRRect&, const SkPaint&) override;
  41. void onDrawPath(const SkPath&, const SkPaint&) override;
  42. void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
  43. void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
  44. SrcRectConstraint) override;
  45. void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
  46. void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
  47. const SkPaint*, SrcRectConstraint) override;
  48. void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
  49. const SkPaint*) override;
  50. void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
  51. SkBlendMode, const SkPaint&) override;
  52. void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
  53. void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
  54. void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
  55. void onClipRegion(const SkRegion&, SkClipOp) override;
  56. void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
  57. void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
  58. private:
  59. lua_State* fL;
  60. SkString fFunc;
  61. void sendverb(const char verb[]);
  62. typedef SkCanvas INHERITED;
  63. };
  64. #endif