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