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