SkLuaCanvas.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 "include/core/SkCanvas.h"
  10. #include "include/core/SkString.h"
  11. #include "include/core/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. bool onDoSaveBehind(const SkRect*) override;
  22. void willRestore() override;
  23. void didConcat(const SkMatrix&) override;
  24. void didSetMatrix(const SkMatrix&) override;
  25. void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
  26. virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
  27. const SkPaint& paint) override;
  28. void onDrawPaint(const SkPaint&) override;
  29. void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
  30. void onDrawRect(const SkRect&, const SkPaint&) override;
  31. void onDrawOval(const SkRect&, const SkPaint&) override;
  32. void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
  33. void onDrawRRect(const SkRRect&, const SkPaint&) override;
  34. void onDrawPath(const SkPath&, const SkPaint&) override;
  35. void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
  36. void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
  37. SrcRectConstraint) override;
  38. void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
  39. void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
  40. const SkPaint*, SrcRectConstraint) override;
  41. void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
  42. const SkPaint*) override;
  43. void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
  44. SkBlendMode, const SkPaint&) override;
  45. void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
  46. void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
  47. void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
  48. void onClipRegion(const SkRegion&, SkClipOp) override;
  49. void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
  50. void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
  51. private:
  52. lua_State* fL;
  53. SkString fFunc;
  54. void sendverb(const char verb[]);
  55. typedef SkCanvas INHERITED;
  56. };
  57. #endif