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 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 10 | #include "SkDrawCommand.h" |
| 11 | #include "SkObjectParser.h" |
| 12 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 13 | #include "SkTextBlob.h" |
| 14 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 15 | // TODO(chudy): Refactor into non subclass model. |
| 16 | |
skia.committer@gmail.com | a5d3e77 | 2013-05-30 07:01:29 +0000 | [diff] [blame] | 17 | SkDrawCommand::SkDrawCommand(DrawType type) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 18 | : fDrawType(type) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 19 | , fOffset(0) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 20 | , fVisible(true) { |
| 21 | } |
| 22 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 23 | SkDrawCommand::~SkDrawCommand() { |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 24 | fInfo.deleteAll(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | const char* SkDrawCommand::GetCommandString(DrawType type) { |
| 28 | switch (type) { |
| 29 | case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break; |
| 30 | case DRAW_CLEAR: return "Clear"; |
| 31 | case CLIP_PATH: return "Clip Path"; |
| 32 | case CLIP_REGION: return "Clip Region"; |
| 33 | case CLIP_RECT: return "Clip Rect"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 34 | case CLIP_RRECT: return "Clip RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 35 | case CONCAT: return "Concat"; |
| 36 | case DRAW_BITMAP: return "Draw Bitmap"; |
| 37 | case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix"; |
| 38 | case DRAW_BITMAP_NINE: return "Draw Bitmap Nine"; |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 39 | case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 40 | case DRAW_DATA: return "Draw Data"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 41 | case DRAW_OVAL: return "Draw Oval"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 42 | case DRAW_PAINT: return "Draw Paint"; |
| 43 | case DRAW_PATH: return "Draw Path"; |
| 44 | case DRAW_PICTURE: return "Draw Picture"; |
| 45 | case DRAW_POINTS: return "Draw Points"; |
| 46 | case DRAW_POS_TEXT: return "Draw Pos Text"; |
| 47 | case DRAW_POS_TEXT_H: return "Draw Pos Text H"; |
| 48 | case DRAW_RECT: return "Draw Rect"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 49 | case DRAW_RRECT: return "Draw RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 50 | case DRAW_SPRITE: return "Draw Sprite"; |
| 51 | case DRAW_TEXT: return "Draw Text"; |
fmalita | 3031350 | 2014-08-27 08:41:25 -0700 | [diff] [blame] | 52 | case DRAW_TEXT_BLOB: return "Draw Text Blob"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 53 | case DRAW_TEXT_ON_PATH: return "Draw Text On Path"; |
| 54 | case DRAW_VERTICES: return "Draw Vertices"; |
| 55 | case RESTORE: return "Restore"; |
| 56 | case ROTATE: return "Rotate"; |
| 57 | case SAVE: return "Save"; |
| 58 | case SAVE_LAYER: return "Save Layer"; |
| 59 | case SCALE: return "Scale"; |
| 60 | case SET_MATRIX: return "Set Matrix"; |
| 61 | case SKEW: return "Skew"; |
| 62 | case TRANSLATE: return "Translate"; |
robertphillips@google.com | e4ce5b8 | 2013-02-15 17:19:15 +0000 | [diff] [blame] | 63 | case NOOP: return "NoOp"; |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 64 | case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; |
| 65 | case COMMENT: return "Comment"; |
| 66 | case END_COMMENT_GROUP: return "EndCommentGroup"; |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 67 | case DRAW_DRRECT: return "Draw DRRect"; |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 68 | case PUSH_CULL: return "PushCull"; |
| 69 | case POP_CULL: return "PopCull"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 70 | default: |
| 71 | SkDebugf("DrawType error 0x%08x\n", type); |
| 72 | SkASSERT(0); |
| 73 | break; |
| 74 | } |
| 75 | SkDEBUGFAIL("DrawType UNUSED\n"); |
| 76 | return NULL; |
| 77 | } |
| 78 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 79 | SkString SkDrawCommand::toString() const { |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 80 | return SkString(GetCommandString(fDrawType)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 81 | } |
| 82 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 83 | SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 84 | fColor = color; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 85 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 86 | } |
| 87 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 88 | void SkClearCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 89 | canvas->clear(fColor); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 90 | } |
| 91 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 92 | namespace { |
| 93 | |
| 94 | void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { |
| 95 | const SkISize& size = canvas->getDeviceSize(); |
| 96 | |
| 97 | static const SkScalar kInsetFrac = 0.9f; // Leave a border around object |
| 98 | |
| 99 | canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f); |
| 100 | if (bounds.width() > bounds.height()) { |
| 101 | canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()), |
| 102 | SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width())); |
| 103 | } else { |
| 104 | canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()), |
| 105 | SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height())); |
| 106 | } |
| 107 | canvas->translate(-bounds.centerX(), -bounds.centerY()); |
| 108 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 109 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 110 | |
| 111 | void render_path(SkCanvas* canvas, const SkPath& path) { |
| 112 | canvas->clear(0xFFFFFFFF); |
| 113 | canvas->save(); |
| 114 | |
| 115 | const SkRect& bounds = path.getBounds(); |
| 116 | |
| 117 | xlate_and_scale_to_bounds(canvas, bounds); |
| 118 | |
| 119 | SkPaint p; |
| 120 | p.setColor(SK_ColorBLACK); |
| 121 | p.setStyle(SkPaint::kStroke_Style); |
| 122 | |
| 123 | canvas->drawPath(path, p); |
| 124 | canvas->restore(); |
| 125 | } |
| 126 | |
| 127 | void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = NULL) { |
| 128 | const SkISize& size = canvas->getDeviceSize(); |
| 129 | |
| 130 | SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width(); |
| 131 | SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height(); |
| 132 | |
| 133 | if (input.width() > input.height()) { |
| 134 | yScale *= input.height() / (float) input.width(); |
| 135 | } else { |
| 136 | xScale *= input.width() / (float) input.height(); |
| 137 | } |
| 138 | |
| 139 | SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1, |
| 140 | xScale * input.width(), |
| 141 | yScale * input.height()); |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 142 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 143 | canvas->clear(0xFFFFFFFF); |
| 144 | canvas->drawBitmapRect(input, NULL, dst); |
| 145 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 146 | if (srcRect) { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 147 | SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1, |
| 148 | srcRect->fTop * yScale + SK_Scalar1, |
| 149 | srcRect->fRight * xScale + SK_Scalar1, |
| 150 | srcRect->fBottom * yScale + SK_Scalar1); |
| 151 | SkPaint p; |
| 152 | p.setColor(SK_ColorRED); |
| 153 | p.setStyle(SkPaint::kStroke_Style); |
| 154 | |
| 155 | canvas->drawRect(r, p); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | void render_rrect(SkCanvas* canvas, const SkRRect& rrect) { |
| 160 | canvas->clear(0xFFFFFFFF); |
| 161 | canvas->save(); |
| 162 | |
| 163 | const SkRect& bounds = rrect.getBounds(); |
| 164 | |
| 165 | xlate_and_scale_to_bounds(canvas, bounds); |
| 166 | |
| 167 | SkPaint p; |
| 168 | p.setColor(SK_ColorBLACK); |
| 169 | p.setStyle(SkPaint::kStroke_Style); |
| 170 | |
| 171 | canvas->drawRRect(rrect, p); |
| 172 | canvas->restore(); |
| 173 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 174 | |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 175 | void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner) { |
| 176 | canvas->clear(0xFFFFFFFF); |
| 177 | canvas->save(); |
| 178 | |
| 179 | const SkRect& bounds = outer.getBounds(); |
| 180 | |
| 181 | xlate_and_scale_to_bounds(canvas, bounds); |
| 182 | |
| 183 | SkPaint p; |
| 184 | p.setColor(SK_ColorBLACK); |
| 185 | p.setStyle(SkPaint::kStroke_Style); |
| 186 | |
| 187 | canvas->drawDRRect(outer, inner, p); |
| 188 | canvas->restore(); |
| 189 | } |
| 190 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 194 | SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA) |
| 195 | : INHERITED(CLIP_PATH) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 196 | fPath = path; |
| 197 | fOp = op; |
| 198 | fDoAA = doAA; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 199 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 200 | fInfo.push(SkObjectParser::PathToString(path)); |
| 201 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 202 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 203 | } |
| 204 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 205 | void SkClipPathCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 206 | canvas->clipPath(fPath, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 207 | } |
| 208 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 209 | bool SkClipPathCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 210 | render_path(canvas, fPath); |
| 211 | return true; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 212 | } |
| 213 | |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 214 | SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 215 | : INHERITED(CLIP_REGION) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 216 | fRegion = region; |
| 217 | fOp = op; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 218 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 219 | fInfo.push(SkObjectParser::RegionToString(region)); |
| 220 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 221 | } |
| 222 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 223 | void SkClipRegionCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 224 | canvas->clipRegion(fRegion, fOp); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 225 | } |
| 226 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 227 | SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA) |
| 228 | : INHERITED(CLIP_RECT) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 229 | fRect = rect; |
| 230 | fOp = op; |
| 231 | fDoAA = doAA; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 232 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 233 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 234 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 235 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 236 | } |
| 237 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 238 | void SkClipRectCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 239 | canvas->clipRect(fRect, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 240 | } |
| 241 | |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 242 | SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 243 | : INHERITED(CLIP_RRECT) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 244 | fRRect = rrect; |
| 245 | fOp = op; |
| 246 | fDoAA = doAA; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 247 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 248 | fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 249 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 250 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 251 | } |
| 252 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 253 | void SkClipRRectCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 254 | canvas->clipRRect(fRRect, fOp, fDoAA); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 255 | } |
| 256 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 257 | bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 258 | render_rrect(canvas, fRRect); |
| 259 | return true; |
| 260 | } |
| 261 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 262 | SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
| 263 | : INHERITED(CONCAT) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 264 | fMatrix = matrix; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 265 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 266 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 267 | } |
| 268 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 269 | void SkConcatCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 270 | canvas->concat(fMatrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 271 | } |
| 272 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 273 | SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 274 | const SkPaint* paint) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 275 | : INHERITED(DRAW_BITMAP) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 276 | fBitmap = bitmap; |
| 277 | fLeft = left; |
| 278 | fTop = top; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 279 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 280 | fPaint = *paint; |
| 281 | fPaintPtr = &fPaint; |
| 282 | } else { |
| 283 | fPaintPtr = NULL; |
| 284 | } |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 285 | |
| 286 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 287 | fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 288 | fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 289 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 290 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 291 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 292 | } |
| 293 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 294 | void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 295 | canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 296 | } |
| 297 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 298 | bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 299 | render_bitmap(canvas, fBitmap); |
| 300 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 301 | } |
| 302 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 303 | SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, |
| 304 | const SkMatrix& matrix, |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 305 | const SkPaint* paint) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 306 | : INHERITED(DRAW_BITMAP_MATRIX) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 307 | fBitmap = bitmap; |
| 308 | fMatrix = matrix; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 309 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 310 | fPaint = *paint; |
| 311 | fPaintPtr = &fPaint; |
| 312 | } else { |
| 313 | fPaintPtr = NULL; |
| 314 | } |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 315 | |
| 316 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 317 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 318 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 319 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 320 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 321 | } |
| 322 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 323 | void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 324 | canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 325 | } |
| 326 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 327 | bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 328 | render_bitmap(canvas, fBitmap); |
| 329 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 330 | } |
| 331 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 332 | SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 333 | const SkRect& dst, const SkPaint* paint) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 334 | : INHERITED(DRAW_BITMAP_NINE) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 335 | fBitmap = bitmap; |
| 336 | fCenter = center; |
| 337 | fDst = dst; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 338 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 339 | fPaint = *paint; |
| 340 | fPaintPtr = &fPaint; |
| 341 | } else { |
| 342 | fPaintPtr = NULL; |
| 343 | } |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 344 | |
| 345 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 346 | fInfo.push(SkObjectParser::IRectToString(center)); |
| 347 | fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 348 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 349 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 350 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 351 | } |
| 352 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 353 | void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 354 | canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 355 | } |
| 356 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 357 | bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 358 | render_bitmap(canvas, fBitmap); |
| 359 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 360 | } |
| 361 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 362 | SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 363 | const SkRect& dst, const SkPaint* paint, |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 364 | SkCanvas::DrawBitmapRectFlags flags) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 365 | : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 366 | fBitmap = bitmap; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 367 | if (src) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 368 | fSrc = *src; |
| 369 | } else { |
| 370 | fSrc.setEmpty(); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 371 | } |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 372 | fDst = dst; |
| 373 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 374 | if (paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 375 | fPaint = *paint; |
| 376 | fPaintPtr = &fPaint; |
| 377 | } else { |
| 378 | fPaintPtr = NULL; |
| 379 | } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 380 | fFlags = flags; |
| 381 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 382 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 383 | if (src) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 384 | fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 385 | } |
| 386 | fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 387 | if (paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 388 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 389 | } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 390 | fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 391 | } |
| 392 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 393 | void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 394 | canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 395 | } |
| 396 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 397 | bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 398 | render_bitmap(canvas, fBitmap, this->srcRect()); |
| 399 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 400 | } |
| 401 | |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 402 | SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 403 | : INHERITED(DRAW_DATA) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 404 | fData = new char[length]; |
| 405 | memcpy(fData, data, length); |
| 406 | fLength = length; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 407 | |
| 408 | // TODO: add display of actual data? |
| 409 | SkString* str = new SkString; |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 410 | str->appendf("length: %d", (int) length); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 411 | fInfo.push(str); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 412 | } |
| 413 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 414 | void SkDrawDataCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 415 | canvas->drawData(fData, fLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 416 | } |
| 417 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 418 | SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 419 | : INHERITED(BEGIN_COMMENT_GROUP) |
| 420 | , fDescription(description) { |
| 421 | SkString* temp = new SkString; |
| 422 | temp->appendf("Description: %s", description); |
| 423 | fInfo.push(temp); |
| 424 | } |
| 425 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 426 | SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 427 | : INHERITED(COMMENT) |
| 428 | , fKywd(kywd) |
| 429 | , fValue(value) { |
| 430 | SkString* temp = new SkString; |
| 431 | temp->appendf("%s: %s", kywd, value); |
| 432 | fInfo.push(temp); |
| 433 | } |
| 434 | |
skia.committer@gmail.com | db35dab | 2014-03-27 03:02:48 +0000 | [diff] [blame] | 435 | SkEndCommentGroupCommand::SkEndCommentGroupCommand() |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 436 | : INHERITED(END_COMMENT_GROUP) { |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 437 | } |
| 438 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 439 | SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
| 440 | : INHERITED(DRAW_OVAL) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 441 | fOval = oval; |
| 442 | fPaint = paint; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 443 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 444 | fInfo.push(SkObjectParser::RectToString(oval)); |
| 445 | fInfo.push(SkObjectParser::PaintToString(paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 446 | } |
| 447 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 448 | void SkDrawOvalCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 449 | canvas->drawOval(fOval, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 450 | } |
| 451 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 452 | bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 453 | canvas->clear(0xFFFFFFFF); |
| 454 | canvas->save(); |
| 455 | |
| 456 | xlate_and_scale_to_bounds(canvas, fOval); |
| 457 | |
| 458 | SkPaint p; |
| 459 | p.setColor(SK_ColorBLACK); |
| 460 | p.setStyle(SkPaint::kStroke_Style); |
| 461 | |
| 462 | canvas->drawOval(fOval, p); |
| 463 | canvas->restore(); |
| 464 | |
| 465 | return true; |
| 466 | } |
| 467 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 468 | SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
| 469 | : INHERITED(DRAW_PAINT) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 470 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 471 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 472 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 473 | } |
| 474 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 475 | void SkDrawPaintCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 476 | canvas->drawPaint(fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 477 | } |
| 478 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 479 | bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 480 | canvas->clear(0xFFFFFFFF); |
| 481 | canvas->drawPaint(fPaint); |
| 482 | return true; |
| 483 | } |
| 484 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 485 | SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
| 486 | : INHERITED(DRAW_PATH) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 487 | fPath = path; |
| 488 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 489 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 490 | fInfo.push(SkObjectParser::PathToString(path)); |
| 491 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 492 | } |
| 493 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 494 | void SkDrawPathCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 495 | canvas->drawPath(fPath, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 496 | } |
| 497 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 498 | bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 499 | render_path(canvas, fPath); |
| 500 | return true; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 501 | } |
| 502 | |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 503 | SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, |
| 504 | const SkMatrix* matrix, |
| 505 | const SkPaint* paint) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 506 | : INHERITED(DRAW_PICTURE) |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 507 | , fPicture(SkRef(picture)) |
| 508 | , fMatrixPtr(NULL) |
| 509 | , fPaintPtr(NULL) { |
| 510 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 511 | if (matrix) { |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 512 | fMatrix = *matrix; |
| 513 | fMatrixPtr = &fMatrix; |
| 514 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 515 | if (paint) { |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 516 | fPaint = *paint; |
| 517 | fPaintPtr = &fPaint; |
| 518 | } |
| 519 | |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 520 | SkString* temp = new SkString; |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 521 | temp->appendf("SkPicture: L: %f T: %f R: %f B: %f", |
| 522 | picture->cullRect().fLeft, picture->cullRect().fTop, |
| 523 | picture->cullRect().fRight, picture->cullRect().fBottom); |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 524 | fInfo.push(temp); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 525 | if (matrix) { |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 526 | fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 527 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 528 | if (paint) { |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 529 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 530 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 531 | } |
| 532 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 533 | void SkDrawPictureCommand::execute(SkCanvas* canvas) const { |
robertphillips | b3f319f | 2014-08-13 10:46:23 -0700 | [diff] [blame] | 534 | canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 535 | } |
| 536 | |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 537 | bool SkDrawPictureCommand::render(SkCanvas* canvas) const { |
| 538 | canvas->clear(0xFFFFFFFF); |
| 539 | canvas->save(); |
| 540 | |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 541 | xlate_and_scale_to_bounds(canvas, fPicture->cullRect()); |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 542 | |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 543 | canvas->drawPicture(fPicture.get()); |
commit-bot@chromium.org | e898e9c | 2013-11-21 17:08:12 +0000 | [diff] [blame] | 544 | |
| 545 | canvas->restore(); |
| 546 | |
| 547 | return true; |
| 548 | } |
| 549 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 550 | SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 551 | const SkPoint pts[], const SkPaint& paint) |
| 552 | : INHERITED(DRAW_POINTS) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 553 | fMode = mode; |
| 554 | fCount = count; |
| 555 | fPts = new SkPoint[count]; |
| 556 | memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 557 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 558 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 559 | fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 560 | fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count), |
| 561 | "Points: ")); |
| 562 | fInfo.push(SkObjectParser::PointModeToString(mode)); |
| 563 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 564 | } |
| 565 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 566 | void SkDrawPointsCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 567 | canvas->drawPoints(fMode, fCount, fPts, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 568 | } |
| 569 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 570 | bool SkDrawPointsCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 571 | canvas->clear(0xFFFFFFFF); |
| 572 | canvas->save(); |
| 573 | |
| 574 | SkRect bounds; |
| 575 | |
| 576 | bounds.setEmpty(); |
| 577 | for (unsigned int i = 0; i < fCount; ++i) { |
| 578 | bounds.growToInclude(fPts[i].fX, fPts[i].fY); |
| 579 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 580 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 581 | xlate_and_scale_to_bounds(canvas, bounds); |
| 582 | |
| 583 | SkPaint p; |
| 584 | p.setColor(SK_ColorBLACK); |
| 585 | p.setStyle(SkPaint::kStroke_Style); |
| 586 | |
| 587 | canvas->drawPoints(fMode, fCount, fPts, p); |
| 588 | canvas->restore(); |
| 589 | |
| 590 | return true; |
| 591 | } |
| 592 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 593 | SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 594 | const SkPoint pos[], const SkPaint& paint) |
| 595 | : INHERITED(DRAW_POS_TEXT) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 596 | size_t numPts = paint.countText(text, byteLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 597 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 598 | fText = new char[byteLength]; |
| 599 | memcpy(fText, text, byteLength); |
| 600 | fByteLength = byteLength; |
| 601 | |
| 602 | fPos = new SkPoint[numPts]; |
| 603 | memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 604 | |
| 605 | fPaint = paint; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 606 | |
| 607 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 608 | // TODO(chudy): Test that this works. |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 609 | fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 610 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 611 | } |
| 612 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 613 | void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 614 | canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 618 | SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength, |
| 619 | const SkScalar xpos[], SkScalar constY, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 620 | const SkPaint& paint) |
| 621 | : INHERITED(DRAW_POS_TEXT_H) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 622 | size_t numPts = paint.countText(text, byteLength); |
| 623 | |
| 624 | fText = new char[byteLength]; |
| 625 | memcpy(fText, text, byteLength); |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 626 | fByteLength = byteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 627 | |
| 628 | fXpos = new SkScalar[numPts]; |
| 629 | memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 630 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 631 | fConstY = constY; |
| 632 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 633 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 634 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
| 635 | fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 636 | fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 637 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 638 | } |
| 639 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 640 | void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 641 | canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 642 | } |
| 643 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 644 | SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 645 | const SkPaint& paint) |
| 646 | : INHERITED(DRAW_TEXT_BLOB) |
| 647 | , fBlob(blob) |
| 648 | , fXPos(x) |
| 649 | , fYPos(y) |
| 650 | , fPaint(paint) { |
| 651 | |
| 652 | blob->ref(); |
| 653 | |
| 654 | // FIXME: push blob info |
| 655 | fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); |
| 656 | fInfo.push(SkObjectParser::ScalarToString(x, "YPOS: ")); |
| 657 | fInfo.push(SkObjectParser::PaintToString(paint)); |
| 658 | } |
| 659 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 660 | void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const { |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 661 | canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint); |
| 662 | } |
| 663 | |
fmalita | 5577387 | 2014-08-29 15:08:20 -0700 | [diff] [blame] | 664 | bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const { |
| 665 | canvas->clear(SK_ColorWHITE); |
| 666 | canvas->save(); |
| 667 | |
| 668 | SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); |
| 669 | xlate_and_scale_to_bounds(canvas, bounds); |
| 670 | |
| 671 | canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); |
| 672 | |
| 673 | canvas->restore(); |
| 674 | |
| 675 | return true; |
| 676 | } |
| 677 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 678 | SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) |
| 679 | : INHERITED(DRAW_RECT) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 680 | fRect = rect; |
| 681 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 682 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 683 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 684 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 685 | } |
| 686 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 687 | void SkDrawRectCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 688 | canvas->drawRect(fRect, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 689 | } |
| 690 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 691 | SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint) |
| 692 | : INHERITED(DRAW_RRECT) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 693 | fRRect = rrect; |
| 694 | fPaint = paint; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 695 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 696 | fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 697 | fInfo.push(SkObjectParser::PaintToString(paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 698 | } |
| 699 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 700 | void SkDrawRRectCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 701 | canvas->drawRRect(fRRect, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 702 | } |
| 703 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 704 | bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 705 | render_rrect(canvas, fRRect); |
| 706 | return true; |
| 707 | } |
| 708 | |
skia.committer@gmail.com | 90667ba | 2014-02-25 03:05:18 +0000 | [diff] [blame] | 709 | SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 710 | const SkRRect& inner, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 711 | const SkPaint& paint) |
| 712 | : INHERITED(DRAW_DRRECT) { |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 713 | fOuter = outer; |
| 714 | fInner = inner; |
| 715 | fPaint = paint; |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 716 | |
| 717 | fInfo.push(SkObjectParser::RRectToString(outer)); |
| 718 | fInfo.push(SkObjectParser::RRectToString(inner)); |
| 719 | fInfo.push(SkObjectParser::PaintToString(paint)); |
| 720 | } |
| 721 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 722 | void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { |
commit-bot@chromium.org | 3d30520 | 2014-02-24 17:28:55 +0000 | [diff] [blame] | 723 | canvas->drawDRRect(fOuter, fInner, fPaint); |
| 724 | } |
| 725 | |
| 726 | bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
| 727 | render_drrect(canvas, fOuter, fInner); |
| 728 | return true; |
| 729 | } |
| 730 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 731 | SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 732 | const SkPaint* paint) |
| 733 | : INHERITED(DRAW_SPRITE) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 734 | fBitmap = bitmap; |
| 735 | fLeft = left; |
| 736 | fTop = top; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 737 | if (paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 738 | fPaint = *paint; |
| 739 | fPaintPtr = &fPaint; |
| 740 | } else { |
| 741 | fPaintPtr = NULL; |
| 742 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 743 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 744 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 745 | fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 746 | fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 747 | if (paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 748 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 749 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 750 | } |
| 751 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 752 | void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 753 | canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 754 | } |
| 755 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 756 | bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 757 | render_bitmap(canvas, fBitmap); |
| 758 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 759 | } |
| 760 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 761 | SkDrawTextCommand::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] | 762 | const SkPaint& paint) |
| 763 | : INHERITED(DRAW_TEXT) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 764 | fText = new char[byteLength]; |
| 765 | memcpy(fText, text, byteLength); |
| 766 | fByteLength = byteLength; |
| 767 | fX = x; |
| 768 | fY = y; |
| 769 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 770 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 771 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
| 772 | fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 773 | fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 774 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 775 | } |
| 776 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 777 | void SkDrawTextCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 778 | canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 779 | } |
| 780 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 781 | SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength, |
| 782 | const SkPath& path, const SkMatrix* matrix, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 783 | const SkPaint& paint) |
| 784 | : INHERITED(DRAW_TEXT_ON_PATH) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 785 | fText = new char[byteLength]; |
| 786 | memcpy(fText, text, byteLength); |
| 787 | fByteLength = byteLength; |
| 788 | fPath = path; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 789 | if (matrix) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 790 | fMatrix = *matrix; |
| 791 | } else { |
| 792 | fMatrix.setIdentity(); |
| 793 | } |
| 794 | fPaint = paint; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 795 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 796 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
| 797 | fInfo.push(SkObjectParser::PathToString(path)); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 798 | if (matrix) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 799 | fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 800 | } |
| 801 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 802 | } |
| 803 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 804 | void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 805 | canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 806 | fMatrix.isIdentity() ? NULL : &fMatrix, |
| 807 | fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 808 | } |
| 809 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 810 | SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount, |
| 811 | const SkPoint vertices[], const SkPoint texs[], |
| 812 | const SkColor colors[], SkXfermode* xfermode, |
| 813 | const uint16_t indices[], int indexCount, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 814 | const SkPaint& paint) |
| 815 | : INHERITED(DRAW_VERTICES) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 816 | fVmode = vmode; |
| 817 | |
| 818 | fVertexCount = vertexCount; |
| 819 | |
| 820 | fVertices = new SkPoint[vertexCount]; |
| 821 | memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 822 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 823 | if (texs) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 824 | fTexs = new SkPoint[vertexCount]; |
| 825 | memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| 826 | } else { |
| 827 | fTexs = NULL; |
| 828 | } |
| 829 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 830 | if (colors) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 831 | fColors = new SkColor[vertexCount]; |
| 832 | memcpy(fColors, colors, vertexCount * sizeof(SkColor)); |
| 833 | } else { |
| 834 | fColors = NULL; |
| 835 | } |
| 836 | |
| 837 | fXfermode = xfermode; |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 838 | if (fXfermode) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 839 | fXfermode->ref(); |
| 840 | } |
| 841 | |
| 842 | if (indexCount > 0) { |
| 843 | fIndices = new uint16_t[indexCount]; |
| 844 | memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); |
| 845 | } else { |
| 846 | fIndices = NULL; |
| 847 | } |
| 848 | |
| 849 | fIndexCount = indexCount; |
| 850 | fPaint = paint; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 851 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 852 | // TODO(chudy) |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 853 | fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
| 854 | fInfo.push(SkObjectParser::PaintToString(paint)); |
| 855 | } |
| 856 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 857 | SkDrawVerticesCommand::~SkDrawVerticesCommand() { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 858 | delete [] fVertices; |
| 859 | delete [] fTexs; |
| 860 | delete [] fColors; |
| 861 | SkSafeUnref(fXfermode); |
| 862 | delete [] fIndices; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 863 | } |
| 864 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 865 | void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 866 | canvas->drawVertices(fVmode, fVertexCount, fVertices, |
| 867 | fTexs, fColors, fXfermode, fIndices, |
| 868 | fIndexCount, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 869 | } |
| 870 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 871 | SkRestoreCommand::SkRestoreCommand() |
| 872 | : INHERITED(RESTORE) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 873 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 874 | } |
| 875 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 876 | void SkRestoreCommand::execute(SkCanvas* canvas) const { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 877 | canvas->restore(); |
| 878 | } |
| 879 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 880 | void SkRestoreCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 881 | (*state)--; |
| 882 | } |
| 883 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 884 | SkRotateCommand::SkRotateCommand(SkScalar degrees) |
| 885 | : INHERITED(ROTATE) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 886 | fDegrees = degrees; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 887 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 888 | fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 889 | } |
| 890 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 891 | void SkRotateCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 892 | canvas->rotate(fDegrees); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 893 | } |
| 894 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 895 | SkSaveCommand::SkSaveCommand() |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 896 | : INHERITED(SAVE) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 897 | } |
| 898 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 899 | void SkSaveCommand::execute(SkCanvas* canvas) const { |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 900 | canvas->save(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 901 | } |
| 902 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 903 | void SkSaveCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 904 | (*state)++; |
| 905 | } |
| 906 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 907 | SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 908 | SkCanvas::SaveFlags flags) |
| 909 | : INHERITED(SAVE_LAYER) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 910 | if (bounds) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 911 | fBounds = *bounds; |
| 912 | } else { |
| 913 | fBounds.setEmpty(); |
| 914 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 915 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 916 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 917 | fPaint = *paint; |
| 918 | fPaintPtr = &fPaint; |
| 919 | } else { |
| 920 | fPaintPtr = NULL; |
| 921 | } |
| 922 | fFlags = flags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 923 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 924 | if (bounds) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 925 | fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 926 | } |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 927 | if (paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 928 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 929 | } |
| 930 | fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 931 | } |
| 932 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 933 | void SkSaveLayerCommand::execute(SkCanvas* canvas) const { |
skia.committer@gmail.com | 7e32851 | 2013-03-23 07:01:28 +0000 | [diff] [blame] | 934 | canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 935 | fPaintPtr, |
| 936 | fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 937 | } |
| 938 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 939 | void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 940 | canvas->save(); |
| 941 | } |
| 942 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 943 | void SkSaveLayerCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 944 | (*state)++; |
| 945 | } |
| 946 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 947 | SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) |
| 948 | : INHERITED(SCALE) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 949 | fSx = sx; |
| 950 | fSy = sy; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 951 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 952 | fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 953 | fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 954 | } |
| 955 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 956 | void SkScaleCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 957 | canvas->scale(fSx, fSy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 958 | } |
| 959 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 960 | SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) |
| 961 | : INHERITED(SET_MATRIX) { |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 962 | fUserMatrix.reset(); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 963 | fMatrix = matrix; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 964 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 965 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 966 | } |
| 967 | |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 968 | void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
| 969 | fUserMatrix = userMatrix; |
| 970 | } |
| 971 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 972 | void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
robertphillips | 7017168 | 2014-10-16 14:28:28 -0700 | [diff] [blame] | 973 | SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
| 974 | canvas->setMatrix(temp); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 975 | } |
| 976 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 977 | SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) |
| 978 | : INHERITED(SKEW) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 979 | fSx = sx; |
| 980 | fSy = sy; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 981 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 982 | fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 983 | fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 984 | } |
| 985 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 986 | void SkSkewCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 987 | canvas->skew(fSx, fSy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 988 | } |
| 989 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 990 | SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) |
| 991 | : INHERITED(TRANSLATE) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 992 | fDx = dx; |
| 993 | fDy = dy; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 994 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 995 | fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 996 | fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 997 | } |
| 998 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 999 | void SkTranslateCommand::execute(SkCanvas* canvas) const { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 1000 | canvas->translate(fDx, fDy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1001 | } |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 1002 | |
| 1003 | SkPushCullCommand::SkPushCullCommand(const SkRect& cullRect) |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 1004 | : INHERITED(PUSH_CULL) |
| 1005 | , fCullRect(cullRect) { |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 1006 | fInfo.push(SkObjectParser::RectToString(cullRect)); |
| 1007 | } |
| 1008 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 1009 | void SkPushCullCommand::execute(SkCanvas* canvas) const { |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 1010 | canvas->pushCull(fCullRect); |
| 1011 | } |
| 1012 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 1013 | void SkPushCullCommand::vizExecute(SkCanvas* canvas) const { |
commit-bot@chromium.org | 1643b2c | 2014-03-03 23:25:41 +0000 | [diff] [blame] | 1014 | canvas->pushCull(fCullRect); |
| 1015 | |
| 1016 | SkPaint p; |
| 1017 | p.setColor(SK_ColorCYAN); |
| 1018 | p.setStyle(SkPaint::kStroke_Style); |
| 1019 | canvas->drawRect(fCullRect, p); |
| 1020 | } |
| 1021 | |
commit-bot@chromium.org | 57f74e0 | 2014-03-25 23:31:33 +0000 | [diff] [blame] | 1022 | SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 1023 | |
fmalita | 8c89c52 | 2014-11-08 16:18:56 -0800 | [diff] [blame^] | 1024 | void SkPopCullCommand::execute(SkCanvas* canvas) const { |
commit-bot@chromium.org | 210ae2a | 2014-02-27 17:40:13 +0000 | [diff] [blame] | 1025 | canvas->popCull(); |
| 1026 | } |