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