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