blob: ddefdcc29d351ddcb15e531a19be8024c678abc8 [file] [log] [blame]
reed@google.comdff7e112013-05-15 19:34:20 +00001/*
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"
Hal Canary6b20a552017-02-07 14:09:38 -050013#include "SkVertices.h"
reed@google.comdff7e112013-05-15 19:34:20 +000014
15struct lua_State;
16
17class SkLuaCanvas : public SkCanvas {
18public:
mike@reedtribe.orgf02fe3d2013-05-21 12:20:39 +000019 void pushThis();
20
reed@google.comdff7e112013-05-15 19:34:20 +000021 SkLuaCanvas(int width, int height, lua_State*, const char function[]);
Brian Salomond3b65972017-03-22 12:05:03 -040022 ~SkLuaCanvas() override;
reed@google.comdff7e112013-05-15 19:34:20 +000023
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000024protected:
mtklein36352bf2015-03-25 18:17:31 -070025 void willSave() override;
reed4960eee2015-12-18 07:09:18 -080026 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
mtklein36352bf2015-03-25 18:17:31 -070027 void willRestore() override;
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000028
mtklein36352bf2015-03-25 18:17:31 -070029 void didConcat(const SkMatrix&) override;
30 void didSetMatrix(const SkMatrix&) override;
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000031
mtklein36352bf2015-03-25 18:17:31 -070032 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
reed45561a02016-07-07 12:47:17 -070033 void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
34 const SkRect* cull, const SkPaint& paint) override;
fmalitab7425172014-08-26 07:56:44 -070035 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
mtklein36352bf2015-03-25 18:17:31 -070036 const SkPaint& paint) override;
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000037
mtklein36352bf2015-03-25 18:17:31 -070038 void onDrawPaint(const SkPaint&) override;
39 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
40 void onDrawRect(const SkRect&, const SkPaint&) override;
41 void onDrawOval(const SkRect&, const SkPaint&) override;
bsalomonac3aa242016-08-19 11:25:19 -070042 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
mtklein36352bf2015-03-25 18:17:31 -070043 void onDrawRRect(const SkRRect&, const SkPaint&) override;
44 void onDrawPath(const SkPath&, const SkPaint&) override;
45 void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
reed41af9662015-01-05 07:49:08 -080046 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
reed562fe472015-07-28 07:35:14 -070047 SrcRectConstraint) override;
mtklein36352bf2015-03-25 18:17:31 -070048 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
reed41af9662015-01-05 07:49:08 -080049 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
reed562fe472015-07-28 07:35:14 -070050 const SkPaint*, SrcRectConstraint) override;
reed41af9662015-01-05 07:49:08 -080051 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
mtklein36352bf2015-03-25 18:17:31 -070052 const SkPaint*) override;
Ruiqi Maoc97a3392018-08-15 10:44:19 -040053 void onDrawVerticesObject(const SkVertices*, const SkVertices::Bone bones[], int boneCount,
54 SkBlendMode, const SkPaint&) override;
reed41af9662015-01-05 07:49:08 -080055
Mike Reedc1f77742016-12-09 09:00:50 -050056 void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
57 void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
58 void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
59 void onClipRegion(const SkRegion&, SkClipOp) override;
robertphillips@google.com8f90a892014-02-28 18:19:39 +000060
mtklein36352bf2015-03-25 18:17:31 -070061 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
Florin Malitaadaeaed2017-09-21 15:28:29 -040062 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
robertphillips9b14f262014-06-04 05:40:44 -070063
reed@google.comdff7e112013-05-15 19:34:20 +000064private:
65 lua_State* fL;
66 SkString fFunc;
skia.committer@gmail.com539f3642013-05-16 07:01:00 +000067
reed@google.comdff7e112013-05-15 19:34:20 +000068 void sendverb(const char verb[]);
69
70 typedef SkCanvas INHERITED;
71};
72
73#endif