blob: 37e82be51dc1fb86a108e99de484d4ca8708fada [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"
13
14struct lua_State;
15
16class SkLuaCanvas : public SkCanvas {
17public:
mike@reedtribe.orgf02fe3d2013-05-21 12:20:39 +000018 void pushThis();
19
reed@google.comdff7e112013-05-15 19:34:20 +000020 SkLuaCanvas(int width, int height, lua_State*, const char function[]);
21 virtual ~SkLuaCanvas();
22
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000023protected:
mtklein36352bf2015-03-25 18:17:31 -070024 void willSave() override;
reed4960eee2015-12-18 07:09:18 -080025 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
mtklein36352bf2015-03-25 18:17:31 -070026 void willRestore() override;
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000027
mtklein36352bf2015-03-25 18:17:31 -070028 void didConcat(const SkMatrix&) override;
29 void didSetMatrix(const SkMatrix&) override;
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000030
mtklein36352bf2015-03-25 18:17:31 -070031 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
reed@google.come0d9ce82014-04-23 04:00:17 +000032 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
mtklein36352bf2015-03-25 18:17:31 -070033 const SkPaint&) override;
reed@google.come0d9ce82014-04-23 04:00:17 +000034 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
mtklein36352bf2015-03-25 18:17:31 -070035 const SkPaint&) override;
reed@google.come0d9ce82014-04-23 04:00:17 +000036 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
mtklein36352bf2015-03-25 18:17:31 -070037 SkScalar constY, const SkPaint&) override;
reed@google.come0d9ce82014-04-23 04:00:17 +000038 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
mtklein36352bf2015-03-25 18:17:31 -070039 const SkMatrix* matrix, const SkPaint&) override;
fmalitab7425172014-08-26 07:56:44 -070040 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
mtklein36352bf2015-03-25 18:17:31 -070041 const SkPaint& paint) override;
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000042
mtklein36352bf2015-03-25 18:17:31 -070043 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;
reed41af9662015-01-05 07:49:08 -080050 void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
reed562fe472015-07-28 07:35:14 -070051 SrcRectConstraint) override;
mtklein36352bf2015-03-25 18:17:31 -070052 void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
reed41af9662015-01-05 07:49:08 -080053 void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
reed562fe472015-07-28 07:35:14 -070054 const SkPaint*, SrcRectConstraint) override;
reed41af9662015-01-05 07:49:08 -080055 void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
mtklein36352bf2015-03-25 18:17:31 -070056 const SkPaint*) override;
reed41af9662015-01-05 07:49:08 -080057 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,
mtklein36352bf2015-03-25 18:17:31 -070061 const SkPaint&) override;
reed41af9662015-01-05 07:49:08 -080062
mtklein36352bf2015-03-25 18:17:31 -070063 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;
robertphillips@google.com8f90a892014-02-28 18:19:39 +000067
mtklein36352bf2015-03-25 18:17:31 -070068 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
robertphillips9b14f262014-06-04 05:40:44 -070069
reed@google.comdff7e112013-05-15 19:34:20 +000070private:
71 lua_State* fL;
72 SkString fFunc;
skia.committer@gmail.com539f3642013-05-16 07:01:00 +000073
reed@google.comdff7e112013-05-15 19:34:20 +000074 void sendverb(const char verb[]);
75
76 typedef SkCanvas INHERITED;
77};
78
79#endif