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