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