2013-05-15 19:34:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkLuaCanvas_DEFINED
|
|
|
|
#define SkLuaCanvas_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkString.h"
|
2013-05-15 19:34:20 +00:00
|
|
|
|
|
|
|
struct lua_State;
|
|
|
|
|
|
|
|
class SkLuaCanvas : public SkCanvas {
|
|
|
|
public:
|
2013-05-21 12:20:39 +00:00
|
|
|
void pushThis();
|
|
|
|
|
2013-05-15 19:34:20 +00:00
|
|
|
SkLuaCanvas(int width, int height, lua_State*, const char function[]);
|
2017-03-22 16:05:03 +00:00
|
|
|
~SkLuaCanvas() override;
|
2013-05-15 19:34:20 +00:00
|
|
|
|
2014-02-21 12:20:45 +00:00
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
void willSave() override;
|
2015-12-18 15:09:18 +00:00
|
|
|
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
|
2018-12-18 22:38:18 +00:00
|
|
|
bool onDoSaveBehind(const SkRect*) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void willRestore() override;
|
2014-03-12 20:21:48 +00:00
|
|
|
|
2020-04-07 01:32:43 +00:00
|
|
|
void didConcat44(const SkM44&) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void didConcat(const SkMatrix&) override;
|
|
|
|
void didSetMatrix(const SkMatrix&) override;
|
2020-01-10 22:21:40 +00:00
|
|
|
void didScale(SkScalar, SkScalar) override;
|
|
|
|
void didTranslate(SkScalar, SkScalar) override;
|
2014-03-13 20:03:58 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
|
2014-08-26 14:56:44 +00:00
|
|
|
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
2015-03-26 01:17:31 +00:00
|
|
|
const SkPaint& paint) override;
|
2014-02-21 12:20:45 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawPaint(const SkPaint&) override;
|
|
|
|
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
|
|
|
|
void onDrawRect(const SkRect&, const SkPaint&) override;
|
|
|
|
void onDrawOval(const SkRect&, const SkPaint&) override;
|
2016-08-19 18:25:19 +00:00
|
|
|
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawRRect(const SkRRect&, const SkPaint&) override;
|
|
|
|
void onDrawPath(const SkPath&, const SkPaint&) override;
|
2020-03-12 14:52:15 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
|
2015-01-05 15:49:08 +00:00
|
|
|
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
|
2015-07-28 14:35:14 +00:00
|
|
|
const SkPaint*, SrcRectConstraint) override;
|
2020-03-02 22:08:01 +00:00
|
|
|
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
|
2016-12-09 14:00:50 +00:00
|
|
|
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
|
|
|
|
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
|
|
|
|
void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
|
2020-03-10 18:02:56 +00:00
|
|
|
void onClipShader(sk_sp<SkShader>, SkClipOp) override;
|
2016-12-09 14:00:50 +00:00
|
|
|
void onClipRegion(const SkRegion&, SkClipOp) override;
|
2014-02-28 18:19:39 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
|
2017-09-21 19:28:29 +00:00
|
|
|
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
|
2014-06-04 12:40:44 +00:00
|
|
|
|
2013-05-15 19:34:20 +00:00
|
|
|
private:
|
|
|
|
lua_State* fL;
|
|
|
|
SkString fFunc;
|
2013-05-16 07:01:00 +00:00
|
|
|
|
2013-05-15 19:34:20 +00:00
|
|
|
void sendverb(const char verb[]);
|
|
|
|
|
|
|
|
typedef SkCanvas INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|