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