chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #ifndef SKDRAWCOMMAND_H_ |
| 10 | #define SKDRAWCOMMAND_H_ |
| 11 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 12 | #include "SkCanvas.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 13 | #include "SkTLazy.h" |
| 14 | #include "SkPath.h" |
| 15 | #include "SkRRect.h" |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 16 | #include "SkString.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 17 | #include "SkTDArray.h" |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 18 | #include "SkJSONCPP.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 19 | |
fmalita@google.com | 86681b3 | 2013-06-13 20:59:14 +0000 | [diff] [blame] | 20 | class SK_API SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 21 | public: |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 22 | enum OpType { |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 23 | kBeginDrawPicture_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 24 | kClipPath_OpType, |
| 25 | kClipRegion_OpType, |
| 26 | kClipRect_OpType, |
| 27 | kClipRRect_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 28 | kConcat_OpType, |
| 29 | kDrawBitmap_OpType, |
| 30 | kDrawBitmapNine_OpType, |
| 31 | kDrawBitmapRect_OpType, |
| 32 | kDrawClear_OpType, |
| 33 | kDrawDRRect_OpType, |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 34 | kDrawImage_OpType, |
| 35 | kDrawImageRect_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 36 | kDrawOval_OpType, |
| 37 | kDrawPaint_OpType, |
| 38 | kDrawPatch_OpType, |
| 39 | kDrawPath_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 40 | kDrawPoints_OpType, |
| 41 | kDrawPosText_OpType, |
| 42 | kDrawPosTextH_OpType, |
| 43 | kDrawRect_OpType, |
| 44 | kDrawRRect_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 45 | kDrawText_OpType, |
| 46 | kDrawTextBlob_OpType, |
| 47 | kDrawTextOnPath_OpType, |
| 48 | kDrawVertices_OpType, |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 49 | kEndDrawPicture_OpType, |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 50 | kRestore_OpType, |
| 51 | kSave_OpType, |
| 52 | kSaveLayer_OpType, |
| 53 | kSetMatrix_OpType, |
robertphillips | 72942b8 | 2015-02-12 06:37:12 -0800 | [diff] [blame] | 54 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 55 | kLast_OpType = kSetMatrix_OpType |
| 56 | }; |
| 57 | |
| 58 | static const int kOpTypeCount = kLast_OpType + 1; |
| 59 | |
| 60 | SkDrawCommand(OpType opType); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 61 | |
| 62 | virtual ~SkDrawCommand(); |
| 63 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame] | 64 | virtual SkString toString() const; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 65 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame] | 66 | virtual const char* toCString() const { |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 67 | return GetCommandString(fOpType); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 68 | } |
| 69 | |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 70 | bool isVisible() const { |
| 71 | return fVisible; |
| 72 | } |
| 73 | |
| 74 | void setVisible(bool toggle) { |
| 75 | fVisible = toggle; |
| 76 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 77 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame] | 78 | const SkTDArray<SkString*>* Info() const { return &fInfo; } |
| 79 | virtual void execute(SkCanvas*) const = 0; |
| 80 | virtual void vizExecute(SkCanvas*) const {} |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 81 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame] | 82 | virtual void setUserMatrix(const SkMatrix&) {} |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 83 | |
mtklein | f0f1411 | 2014-12-12 08:46:25 -0800 | [diff] [blame] | 84 | // The next "active" system is only used by save, saveLayer, and restore. |
| 85 | // It is used to determine which saveLayers are currently active (at a |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 86 | // given point in the rendering). |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 87 | // saves just return a kPushLayer action but don't track active state |
| 88 | // restores just return a kPopLayer action |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 89 | // saveLayers return kPushLayer but also track the active state |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 90 | enum Action { |
| 91 | kNone_Action, |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 92 | kPopLayer_Action, |
| 93 | kPushLayer_Action, |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 94 | }; |
| 95 | virtual Action action() const { return kNone_Action; } |
| 96 | virtual void setActive(bool active) {} |
| 97 | virtual bool active() const { return false; } |
| 98 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 99 | OpType getType() const { return fOpType; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 100 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 101 | virtual bool render(SkCanvas* canvas) const { return false; } |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 102 | |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 103 | virtual Json::Value toJSON() const; |
| 104 | |
| 105 | /* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It |
| 106 | * is the caller's responsibility to delete this object. This method may return null if an error |
| 107 | * occurs. |
| 108 | */ |
| 109 | static SkDrawCommand* fromJSON(Json::Value& command); |
| 110 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 111 | static const char* GetCommandString(OpType type); |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 112 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 113 | protected: |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 114 | SkTDArray<SkString*> fInfo; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 115 | |
| 116 | private: |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 117 | OpType fOpType; |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 118 | bool fVisible; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 121 | class SkRestoreCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 122 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 123 | SkRestoreCommand(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 124 | void execute(SkCanvas* canvas) const override; |
| 125 | Action action() const override { return kPopLayer_Action; } |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 126 | static SkRestoreCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 127 | |
| 128 | private: |
| 129 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 132 | class SkClearCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 133 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 134 | SkClearCommand(SkColor color); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 135 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 136 | Json::Value toJSON() const override; |
| 137 | static SkClearCommand* fromJSON(Json::Value& command); |
| 138 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 139 | private: |
| 140 | SkColor fColor; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 141 | |
| 142 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 145 | class SkClipPathCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 146 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 147 | SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 148 | void execute(SkCanvas* canvas) const override; |
| 149 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 150 | Json::Value toJSON() const override; |
| 151 | static SkClipPathCommand* fromJSON(Json::Value& command); |
| 152 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 153 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 154 | SkPath fPath; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 155 | SkRegion::Op fOp; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 156 | bool fDoAA; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 157 | |
| 158 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 161 | class SkClipRegionCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 162 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 163 | SkClipRegionCommand(const SkRegion& region, SkRegion::Op op); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 164 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 165 | Json::Value toJSON() const override; |
| 166 | static SkClipRegionCommand* fromJSON(Json::Value& command); |
| 167 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 168 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 169 | SkRegion fRegion; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 170 | SkRegion::Op fOp; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 171 | |
| 172 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 175 | class SkClipRectCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 176 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 177 | SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 178 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 179 | Json::Value toJSON() const override; |
| 180 | static SkClipRectCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 181 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 182 | const SkRect& rect() const { return fRect; } |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 183 | SkRegion::Op op() const { return fOp; } |
| 184 | bool doAA() const { return fDoAA; } |
| 185 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 186 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 187 | SkRect fRect; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 188 | SkRegion::Op fOp; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 189 | bool fDoAA; |
| 190 | |
| 191 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 192 | }; |
| 193 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 194 | class SkClipRRectCommand : public SkDrawCommand { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 195 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 196 | SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 197 | void execute(SkCanvas* canvas) const override; |
| 198 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 199 | Json::Value toJSON() const override; |
| 200 | static SkClipRRectCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 201 | |
| 202 | const SkRRect& rrect() const { return fRRect; } |
| 203 | SkRegion::Op op() const { return fOp; } |
| 204 | bool doAA() const { return fDoAA; } |
| 205 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 206 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 207 | SkRRect fRRect; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 208 | SkRegion::Op fOp; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 209 | bool fDoAA; |
| 210 | |
| 211 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 212 | }; |
| 213 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 214 | class SkConcatCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 215 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 216 | SkConcatCommand(const SkMatrix& matrix); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 217 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 218 | Json::Value toJSON() const override; |
| 219 | static SkConcatCommand* fromJSON(Json::Value& command); |
| 220 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 221 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 222 | SkMatrix fMatrix; |
| 223 | |
| 224 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 225 | }; |
| 226 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 227 | class SkDrawBitmapCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 228 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 229 | SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 230 | const SkPaint* paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 231 | void execute(SkCanvas* canvas) const override; |
| 232 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 233 | Json::Value toJSON() const override; |
| 234 | static SkDrawBitmapCommand* fromJSON(Json::Value& command); |
| 235 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 236 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 237 | SkBitmap fBitmap; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 238 | SkScalar fLeft; |
| 239 | SkScalar fTop; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 240 | SkPaint fPaint; |
| 241 | SkPaint* fPaintPtr; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 242 | |
| 243 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 244 | }; |
| 245 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 246 | class SkDrawBitmapNineCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 247 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 248 | SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 249 | const SkRect& dst, const SkPaint* paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 250 | void execute(SkCanvas* canvas) const override; |
| 251 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 252 | Json::Value toJSON() const override; |
| 253 | static SkDrawBitmapNineCommand* fromJSON(Json::Value& command); |
| 254 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 255 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 256 | SkBitmap fBitmap; |
| 257 | SkIRect fCenter; |
| 258 | SkRect fDst; |
| 259 | SkPaint fPaint; |
| 260 | SkPaint* fPaintPtr; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 261 | |
| 262 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 263 | }; |
| 264 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 265 | class SkDrawBitmapRectCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 266 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 267 | SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 268 | const SkRect& dst, const SkPaint* paint, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 269 | SkCanvas::SrcRectConstraint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 270 | void execute(SkCanvas* canvas) const override; |
| 271 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 272 | Json::Value toJSON() const override; |
| 273 | static SkDrawBitmapRectCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 274 | |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame] | 275 | const SkBitmap& bitmap() const { return fBitmap; } |
| 276 | |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 277 | // The non-const 'paint' method allows modification of this object's |
| 278 | // SkPaint. For this reason the ctor and setPaint method make a local copy. |
| 279 | // The 'fPaintPtr' member acts a signal that the local SkPaint is valid |
| 280 | // (since only an SkPaint* is passed into the ctor). |
| 281 | const SkPaint* paint() const { return fPaintPtr; } |
| 282 | SkPaint* paint() { return fPaintPtr; } |
| 283 | |
| 284 | void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; } |
| 285 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 286 | const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; } |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame] | 287 | void setSrcRect(const SkRect& src) { fSrc = src; } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 288 | |
| 289 | const SkRect& dstRect() const { return fDst; } |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame] | 290 | void setDstRect(const SkRect& dst) { fDst = dst; } |
| 291 | |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 292 | SkCanvas::SrcRectConstraint constraint() const { return fConstraint; } |
| 293 | void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 294 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 295 | private: |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 296 | SkBitmap fBitmap; |
| 297 | SkRect fSrc; |
| 298 | SkRect fDst; |
| 299 | SkPaint fPaint; |
| 300 | SkPaint* fPaintPtr; |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 301 | SkCanvas::SrcRectConstraint fConstraint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 302 | |
| 303 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 304 | }; |
| 305 | |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 306 | class SkDrawImageCommand : public SkDrawCommand { |
| 307 | public: |
| 308 | SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint); |
| 309 | void execute(SkCanvas* canvas) const override; |
| 310 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 311 | Json::Value toJSON() const override; |
| 312 | static SkDrawImageCommand* fromJSON(Json::Value& command); |
| 313 | |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 314 | private: |
| 315 | SkAutoTUnref<const SkImage> fImage; |
| 316 | SkScalar fLeft; |
| 317 | SkScalar fTop; |
| 318 | SkTLazy<SkPaint> fPaint; |
| 319 | |
| 320 | typedef SkDrawCommand INHERITED; |
| 321 | }; |
| 322 | |
| 323 | class SkDrawImageRectCommand : public SkDrawCommand { |
| 324 | public: |
| 325 | SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst, |
| 326 | const SkPaint* paint, SkCanvas::SrcRectConstraint constraint); |
| 327 | void execute(SkCanvas* canvas) const override; |
| 328 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 329 | Json::Value toJSON() const override; |
| 330 | static SkDrawImageRectCommand* fromJSON(Json::Value& command); |
| 331 | |
fmalita | 651c920 | 2015-07-22 10:23:01 -0700 | [diff] [blame] | 332 | private: |
| 333 | SkAutoTUnref<const SkImage> fImage; |
| 334 | SkTLazy<SkRect> fSrc; |
| 335 | SkRect fDst; |
| 336 | SkTLazy<SkPaint> fPaint; |
| 337 | SkCanvas::SrcRectConstraint fConstraint; |
| 338 | |
| 339 | typedef SkDrawCommand INHERITED; |
| 340 | }; |
| 341 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 342 | class SkDrawOvalCommand : public SkDrawCommand { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 343 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 344 | SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 345 | void execute(SkCanvas* canvas) const override; |
| 346 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 347 | Json::Value toJSON() const override; |
| 348 | static SkDrawOvalCommand* fromJSON(Json::Value& command); |
| 349 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 350 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 351 | SkRect fOval; |
| 352 | SkPaint fPaint; |
| 353 | |
| 354 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 355 | }; |
| 356 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 357 | class SkDrawPaintCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 358 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 359 | SkDrawPaintCommand(const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 360 | void execute(SkCanvas* canvas) const override; |
| 361 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 362 | Json::Value toJSON() const override; |
| 363 | static SkDrawPaintCommand* fromJSON(Json::Value& command); |
| 364 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 365 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 366 | SkPaint fPaint; |
| 367 | |
| 368 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 369 | }; |
| 370 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 371 | class SkDrawPathCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 372 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 373 | SkDrawPathCommand(const SkPath& path, const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 374 | void execute(SkCanvas* canvas) const override; |
| 375 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 376 | Json::Value toJSON() const override; |
| 377 | static SkDrawPathCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 378 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 379 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 380 | SkPath fPath; |
| 381 | SkPaint fPaint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 382 | |
| 383 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 384 | }; |
| 385 | |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 386 | class SkBeginDrawPictureCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 387 | public: |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 388 | SkBeginDrawPictureCommand(const SkPicture* picture, |
| 389 | const SkMatrix* matrix, |
| 390 | const SkPaint* paint); |
| 391 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 392 | void execute(SkCanvas* canvas) const override; |
| 393 | bool render(SkCanvas* canvas) const override; |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 394 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 395 | private: |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 396 | SkAutoTUnref<const SkPicture> fPicture; |
fmalita | 160ebb2 | 2015-04-01 20:58:37 -0700 | [diff] [blame] | 397 | SkTLazy<SkMatrix> fMatrix; |
| 398 | SkTLazy<SkPaint> fPaint; |
| 399 | |
| 400 | typedef SkDrawCommand INHERITED; |
| 401 | }; |
| 402 | |
| 403 | class SkEndDrawPictureCommand : public SkDrawCommand { |
| 404 | public: |
| 405 | SkEndDrawPictureCommand(bool restore); |
| 406 | |
| 407 | void execute(SkCanvas* canvas) const override; |
| 408 | |
| 409 | private: |
| 410 | bool fRestore; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 411 | |
| 412 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 413 | }; |
| 414 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 415 | class SkDrawPointsCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 416 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 417 | SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 418 | const SkPaint& paint); |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 419 | virtual ~SkDrawPointsCommand() { delete [] fPts; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 420 | void execute(SkCanvas* canvas) const override; |
| 421 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 422 | Json::Value toJSON() const override; |
| 423 | static SkDrawPointsCommand* fromJSON(Json::Value& command); |
| 424 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 425 | private: |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 426 | SkCanvas::PointMode fMode; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 427 | size_t fCount; |
| 428 | SkPoint* fPts; |
| 429 | SkPaint fPaint; |
| 430 | |
| 431 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 432 | }; |
| 433 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 434 | class SkDrawTextCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 435 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 436 | SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 437 | const SkPaint& paint); |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 438 | virtual ~SkDrawTextCommand() { delete [] fText; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 439 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 440 | Json::Value toJSON() const override; |
| 441 | static SkDrawTextCommand* fromJSON(Json::Value& command); |
| 442 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 443 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 444 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 445 | size_t fByteLength; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 446 | SkScalar fX; |
| 447 | SkScalar fY; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 448 | SkPaint fPaint; |
| 449 | |
| 450 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 451 | }; |
| 452 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 453 | class SkDrawPosTextCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 454 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 455 | SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[], |
| 456 | const SkPaint& paint); |
| 457 | virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 458 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 459 | Json::Value toJSON() const override; |
| 460 | static SkDrawPosTextCommand* fromJSON(Json::Value& command); |
| 461 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 462 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 463 | char* fText; |
| 464 | size_t fByteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 465 | SkPoint* fPos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 466 | SkPaint fPaint; |
| 467 | |
| 468 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 469 | }; |
| 470 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 471 | class SkDrawTextOnPathCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 472 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 473 | SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path, |
| 474 | const SkMatrix* matrix, const SkPaint& paint); |
| 475 | virtual ~SkDrawTextOnPathCommand() { delete [] fText; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 476 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 477 | Json::Value toJSON() const override; |
| 478 | static SkDrawTextOnPathCommand* fromJSON(Json::Value& command); |
| 479 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 480 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 481 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 482 | size_t fByteLength; |
| 483 | SkPath fPath; |
| 484 | SkMatrix fMatrix; |
| 485 | SkPaint fPaint; |
| 486 | |
| 487 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 488 | }; |
| 489 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 490 | class SkDrawPosTextHCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 491 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 492 | SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[], |
| 493 | SkScalar constY, const SkPaint& paint); |
| 494 | virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 495 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 496 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 497 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 498 | SkScalar* fXpos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 499 | char* fText; |
| 500 | size_t fByteLength; |
| 501 | SkScalar fConstY; |
| 502 | SkPaint fPaint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 503 | |
| 504 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 505 | }; |
| 506 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 507 | class SkDrawTextBlobCommand : public SkDrawCommand { |
| 508 | public: |
| 509 | SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint); |
| 510 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 511 | void execute(SkCanvas* canvas) const override; |
| 512 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 513 | Json::Value toJSON() const override; |
| 514 | static SkDrawTextBlobCommand* fromJSON(Json::Value& command); |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 515 | |
| 516 | private: |
| 517 | SkAutoTUnref<const SkTextBlob> fBlob; |
| 518 | SkScalar fXPos; |
| 519 | SkScalar fYPos; |
| 520 | SkPaint fPaint; |
| 521 | |
| 522 | typedef SkDrawCommand INHERITED; |
| 523 | }; |
| 524 | |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 525 | class SkDrawPatchCommand : public SkDrawCommand { |
| 526 | public: |
| 527 | SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4], |
| 528 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 529 | const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 530 | void execute(SkCanvas* canvas) const override; |
robertphillips | 9bafc30 | 2015-02-13 11:13:00 -0800 | [diff] [blame] | 531 | |
| 532 | private: |
| 533 | SkPoint fCubics[12]; |
| 534 | SkColor fColors[4]; |
| 535 | SkPoint fTexCoords[4]; |
| 536 | SkAutoTUnref<SkXfermode> fXfermode; |
| 537 | SkPaint fPaint; |
| 538 | |
| 539 | typedef SkDrawCommand INHERITED; |
| 540 | }; |
| 541 | |
| 542 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 543 | class SkDrawRectCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 544 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 545 | SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 546 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 547 | Json::Value toJSON() const override; |
| 548 | static SkDrawRectCommand* fromJSON(Json::Value& command); |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 549 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 550 | const SkRect& rect() const { return fRect; } |
| 551 | const SkPaint& paint() const { return fPaint; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 552 | private: |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 553 | SkRect fRect; |
| 554 | SkPaint fPaint; |
| 555 | |
| 556 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 557 | }; |
| 558 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 559 | class SkDrawRRectCommand : public SkDrawCommand { |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 560 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 561 | SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 562 | void execute(SkCanvas* canvas) const override; |
| 563 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 564 | Json::Value toJSON() const override; |
| 565 | static SkDrawRRectCommand* fromJSON(Json::Value& command); |
| 566 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 567 | private: |
| 568 | SkRRect fRRect; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 569 | SkPaint fPaint; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 570 | |
| 571 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 572 | }; |
| 573 | |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 574 | class SkDrawDRRectCommand : public SkDrawCommand { |
| 575 | public: |
| 576 | SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner, |
| 577 | const SkPaint& paint); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 578 | void execute(SkCanvas* canvas) const override; |
| 579 | bool render(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 580 | Json::Value toJSON() const override; |
| 581 | static SkDrawDRRectCommand* fromJSON(Json::Value& command); |
| 582 | |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 583 | private: |
| 584 | SkRRect fOuter; |
| 585 | SkRRect fInner; |
| 586 | SkPaint fPaint; |
| 587 | |
| 588 | typedef SkDrawCommand INHERITED; |
| 589 | }; |
| 590 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 591 | class SkDrawVerticesCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 592 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 593 | SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount, |
| 594 | const SkPoint vertices[], const SkPoint texs[], |
| 595 | const SkColor colors[], SkXfermode* xfermode, |
| 596 | const uint16_t indices[], int indexCount, |
| 597 | const SkPaint& paint); |
| 598 | virtual ~SkDrawVerticesCommand(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 599 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 600 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 601 | private: |
| 602 | SkCanvas::VertexMode fVmode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 603 | int fVertexCount; |
| 604 | SkPoint* fVertices; |
| 605 | SkPoint* fTexs; |
| 606 | SkColor* fColors; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 607 | SkXfermode* fXfermode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 608 | uint16_t* fIndices; |
| 609 | int fIndexCount; |
| 610 | SkPaint fPaint; |
| 611 | |
| 612 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 613 | }; |
| 614 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 615 | class SkSaveCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 616 | public: |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 617 | SkSaveCommand(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 618 | void execute(SkCanvas* canvas) const override; |
| 619 | Action action() const override { return kPushLayer_Action; } |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 620 | static SkSaveCommand* fromJSON(Json::Value& command); |
| 621 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 622 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 623 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 624 | }; |
| 625 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 626 | class SkSaveLayerCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 627 | public: |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 628 | SkSaveLayerCommand(const SkCanvas::SaveLayerRec&); |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 629 | virtual ~SkSaveLayerCommand(); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 630 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 631 | Json::Value toJSON() const override; |
| 632 | static SkSaveLayerCommand* fromJSON(Json::Value& command); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 633 | void vizExecute(SkCanvas* canvas) const override; |
| 634 | Action action() const override{ return kPushLayer_Action; } |
| 635 | void setActive(bool active) override { fActive = active; } |
| 636 | bool active() const override { return fActive; } |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 637 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 638 | const SkPaint* paint() const { return fPaintPtr; } |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 639 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 640 | private: |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 641 | SkRect fBounds; |
| 642 | SkPaint fPaint; |
| 643 | SkPaint* fPaintPtr; |
| 644 | const SkImageFilter* fBackdrop; |
| 645 | uint32_t fSaveLayerFlags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 646 | |
reed | 4960eee | 2015-12-18 07:09:18 -0800 | [diff] [blame] | 647 | bool fActive; |
commit-bot@chromium.org | 768ac85 | 2014-03-03 16:32:17 +0000 | [diff] [blame] | 648 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 649 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 650 | }; |
| 651 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 652 | class SkSetMatrixCommand : public SkDrawCommand { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 653 | public: |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 654 | SkSetMatrixCommand(const SkMatrix& matrix); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 655 | void setUserMatrix(const SkMatrix&) override; |
| 656 | void execute(SkCanvas* canvas) const override; |
ethannicholas | 50a8dd0 | 2016-02-10 05:40:46 -0800 | [diff] [blame^] | 657 | Json::Value toJSON() const override; |
| 658 | static SkSetMatrixCommand* fromJSON(Json::Value& command); |
| 659 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 660 | private: |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 661 | SkMatrix fUserMatrix; |
robertphillips@google.com | b94b1e7 | 2013-02-19 21:00:26 +0000 | [diff] [blame] | 662 | SkMatrix fMatrix; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 663 | |
| 664 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 665 | }; |
| 666 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 667 | #endif |