OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
11 #include "SkObjectParser.h" | 11 #include "SkObjectParser.h" |
12 #include "SkPicture.h" | 12 |
13 #include "SkTextBlob.h" | 13 #include "SkTextBlob.h" |
14 | 14 |
15 // TODO(chudy): Refactor into non subclass model. | 15 // TODO(chudy): Refactor into non subclass model. |
16 | 16 |
17 SkDrawCommand::SkDrawCommand(OpType type) | 17 SkDrawCommand::SkDrawCommand(DrawType type) |
18 : fOpType(type) | 18 : fDrawType(type) |
19 , fOffset(0) | 19 , fOffset(0) |
20 , fVisible(true) { | 20 , fVisible(true) { |
21 } | 21 } |
22 | 22 |
23 SkDrawCommand::~SkDrawCommand() { | 23 SkDrawCommand::~SkDrawCommand() { |
24 fInfo.deleteAll(); | 24 fInfo.deleteAll(); |
25 } | 25 } |
26 | 26 |
27 const char* SkDrawCommand::GetCommandString(OpType type) { | 27 const char* SkDrawCommand::GetCommandString(DrawType type) { |
28 switch (type) { | 28 switch (type) { |
29 case kBeginCommentGroup_OpType: return "BeginCommentGroup"; | 29 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break; |
30 case kClipPath_OpType: return "ClipPath"; | 30 case DRAW_CLEAR: return "Clear"; |
31 case kClipRegion_OpType: return "ClipRegion"; | 31 case CLIP_PATH: return "Clip Path"; |
32 case kClipRect_OpType: return "ClipRect"; | 32 case CLIP_REGION: return "Clip Region"; |
33 case kClipRRect_OpType: return "ClipRRect"; | 33 case CLIP_RECT: return "Clip Rect"; |
34 case kComment_OpType: return "Comment"; | 34 case CLIP_RRECT: return "Clip RRect"; |
35 case kConcat_OpType: return "Concat"; | 35 case CONCAT: return "Concat"; |
36 case kDrawBitmap_OpType: return "DrawBitmap"; | 36 case DRAW_BITMAP: return "Draw Bitmap"; |
37 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; | 37 case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix"; |
38 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; | 38 case DRAW_BITMAP_NINE: return "Draw Bitmap Nine"; |
39 case kDrawClear_OpType: return "DrawClear"; | 39 case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; |
40 case kDrawDRRect_OpType: return "DrawDRRect"; | 40 case DRAW_DATA: return "Draw Data"; |
41 case kDrawOval_OpType: return "DrawOval"; | 41 case DRAW_OVAL: return "Draw Oval"; |
42 case kDrawPaint_OpType: return "DrawPaint"; | 42 case DRAW_PAINT: return "Draw Paint"; |
43 case kDrawPatch_OpType: return "DrawPatch"; | 43 case DRAW_PATH: return "Draw Path"; |
44 case kDrawPath_OpType: return "DrawPath"; | 44 case DRAW_PICTURE: return "Draw Picture"; |
45 case kDrawPicture_OpType: return "DrawPicture"; | 45 case DRAW_POINTS: return "Draw Points"; |
46 case kDrawPoints_OpType: return "DrawPoints"; | 46 case DRAW_POS_TEXT: return "Draw Pos Text"; |
47 case kDrawPosText_OpType: return "DrawPosText"; | 47 case DRAW_POS_TEXT_H: return "Draw Pos Text H"; |
48 case kDrawPosTextH_OpType: return "DrawPosTextH"; | 48 case DRAW_RECT: return "Draw Rect"; |
49 case kDrawRect_OpType: return "DrawRect"; | 49 case DRAW_RRECT: return "Draw RRect"; |
50 case kDrawRRect_OpType: return "DrawRRect"; | 50 case DRAW_SPRITE: return "Draw Sprite"; |
51 case kDrawSprite_OpType: return "DrawSprite"; | 51 case DRAW_TEXT: return "Draw Text"; |
52 case kDrawText_OpType: return "DrawText"; | 52 case DRAW_TEXT_BLOB: return "Draw Text Blob"; |
53 case kDrawTextBlob_OpType: return "DrawTextBlob"; | 53 case DRAW_TEXT_ON_PATH: return "Draw Text On Path"; |
54 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; | 54 case DRAW_VERTICES: return "Draw Vertices"; |
55 case kDrawVertices_OpType: return "DrawVertices"; | 55 case RESTORE: return "Restore"; |
56 case kEndCommentGroup_OpType: return "EndCommentGroup"; | 56 case ROTATE: return "Rotate"; |
57 case kRestore_OpType: return "Restore"; | 57 case SAVE: return "Save"; |
58 case kSave_OpType: return "Save"; | 58 case SAVE_LAYER: return "Save Layer"; |
59 case kSaveLayer_OpType: return "SaveLayer"; | 59 case SCALE: return "Scale"; |
60 case kSetMatrix_OpType: return "SetMatrix"; | 60 case SET_MATRIX: return "Set Matrix"; |
| 61 case SKEW: return "Skew"; |
| 62 case TRANSLATE: return "Translate"; |
| 63 case NOOP: return "NoOp"; |
| 64 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; |
| 65 case COMMENT: return "Comment"; |
| 66 case END_COMMENT_GROUP: return "EndCommentGroup"; |
| 67 case DRAW_DRRECT: return "Draw DRRect"; |
61 default: | 68 default: |
62 SkDebugf("OpType error 0x%08x\n", type); | 69 SkDebugf("DrawType error 0x%08x\n", type); |
63 SkASSERT(0); | 70 SkASSERT(0); |
64 break; | 71 break; |
65 } | 72 } |
66 SkDEBUGFAIL("DrawType UNUSED\n"); | 73 SkDEBUGFAIL("DrawType UNUSED\n"); |
67 return NULL; | 74 return NULL; |
68 } | 75 } |
69 | 76 |
70 SkString SkDrawCommand::toString() const { | 77 SkString SkDrawCommand::toString() const { |
71 return SkString(GetCommandString(fOpType)); | 78 return SkString(GetCommandString(fDrawType)); |
72 } | 79 } |
73 | 80 |
74 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { | 81 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) { |
75 fColor = color; | 82 fColor = color; |
76 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 83 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
77 } | 84 } |
78 | 85 |
79 void SkClearCommand::execute(SkCanvas* canvas) const { | 86 void SkClearCommand::execute(SkCanvas* canvas) const { |
80 canvas->clear(fColor); | 87 canvas->clear(fColor); |
81 } | 88 } |
82 | 89 |
83 namespace { | 90 namespace { |
84 | 91 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 p.setStyle(SkPaint::kStroke_Style); | 183 p.setStyle(SkPaint::kStroke_Style); |
177 | 184 |
178 canvas->drawDRRect(outer, inner, p); | 185 canvas->drawDRRect(outer, inner, p); |
179 canvas->restore(); | 186 canvas->restore(); |
180 } | 187 } |
181 | 188 |
182 }; | 189 }; |
183 | 190 |
184 | 191 |
185 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) | 192 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) |
186 : INHERITED(kClipPath_OpType) { | 193 : INHERITED(CLIP_PATH) { |
187 fPath = path; | 194 fPath = path; |
188 fOp = op; | 195 fOp = op; |
189 fDoAA = doAA; | 196 fDoAA = doAA; |
190 | 197 |
191 fInfo.push(SkObjectParser::PathToString(path)); | 198 fInfo.push(SkObjectParser::PathToString(path)); |
192 fInfo.push(SkObjectParser::RegionOpToString(op)); | 199 fInfo.push(SkObjectParser::RegionOpToString(op)); |
193 fInfo.push(SkObjectParser::BoolToString(doAA)); | 200 fInfo.push(SkObjectParser::BoolToString(doAA)); |
194 } | 201 } |
195 | 202 |
196 void SkClipPathCommand::execute(SkCanvas* canvas) const { | 203 void SkClipPathCommand::execute(SkCanvas* canvas) const { |
197 canvas->clipPath(fPath, fOp, fDoAA); | 204 canvas->clipPath(fPath, fOp, fDoAA); |
198 } | 205 } |
199 | 206 |
200 bool SkClipPathCommand::render(SkCanvas* canvas) const { | 207 bool SkClipPathCommand::render(SkCanvas* canvas) const { |
201 render_path(canvas, fPath); | 208 render_path(canvas, fPath); |
202 return true; | 209 return true; |
203 } | 210 } |
204 | 211 |
205 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) | 212 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) |
206 : INHERITED(kClipRegion_OpType) { | 213 : INHERITED(CLIP_REGION) { |
207 fRegion = region; | 214 fRegion = region; |
208 fOp = op; | 215 fOp = op; |
209 | 216 |
210 fInfo.push(SkObjectParser::RegionToString(region)); | 217 fInfo.push(SkObjectParser::RegionToString(region)); |
211 fInfo.push(SkObjectParser::RegionOpToString(op)); | 218 fInfo.push(SkObjectParser::RegionOpToString(op)); |
212 } | 219 } |
213 | 220 |
214 void SkClipRegionCommand::execute(SkCanvas* canvas) const { | 221 void SkClipRegionCommand::execute(SkCanvas* canvas) const { |
215 canvas->clipRegion(fRegion, fOp); | 222 canvas->clipRegion(fRegion, fOp); |
216 } | 223 } |
217 | 224 |
218 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) | 225 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) |
219 : INHERITED(kClipRect_OpType) { | 226 : INHERITED(CLIP_RECT) { |
220 fRect = rect; | 227 fRect = rect; |
221 fOp = op; | 228 fOp = op; |
222 fDoAA = doAA; | 229 fDoAA = doAA; |
223 | 230 |
224 fInfo.push(SkObjectParser::RectToString(rect)); | 231 fInfo.push(SkObjectParser::RectToString(rect)); |
225 fInfo.push(SkObjectParser::RegionOpToString(op)); | 232 fInfo.push(SkObjectParser::RegionOpToString(op)); |
226 fInfo.push(SkObjectParser::BoolToString(doAA)); | 233 fInfo.push(SkObjectParser::BoolToString(doAA)); |
227 } | 234 } |
228 | 235 |
229 void SkClipRectCommand::execute(SkCanvas* canvas) const { | 236 void SkClipRectCommand::execute(SkCanvas* canvas) const { |
230 canvas->clipRect(fRect, fOp, fDoAA); | 237 canvas->clipRect(fRect, fOp, fDoAA); |
231 } | 238 } |
232 | 239 |
233 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) | 240 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) |
234 : INHERITED(kClipRRect_OpType) { | 241 : INHERITED(CLIP_RRECT) { |
235 fRRect = rrect; | 242 fRRect = rrect; |
236 fOp = op; | 243 fOp = op; |
237 fDoAA = doAA; | 244 fDoAA = doAA; |
238 | 245 |
239 fInfo.push(SkObjectParser::RRectToString(rrect)); | 246 fInfo.push(SkObjectParser::RRectToString(rrect)); |
240 fInfo.push(SkObjectParser::RegionOpToString(op)); | 247 fInfo.push(SkObjectParser::RegionOpToString(op)); |
241 fInfo.push(SkObjectParser::BoolToString(doAA)); | 248 fInfo.push(SkObjectParser::BoolToString(doAA)); |
242 } | 249 } |
243 | 250 |
244 void SkClipRRectCommand::execute(SkCanvas* canvas) const { | 251 void SkClipRRectCommand::execute(SkCanvas* canvas) const { |
245 canvas->clipRRect(fRRect, fOp, fDoAA); | 252 canvas->clipRRect(fRRect, fOp, fDoAA); |
246 } | 253 } |
247 | 254 |
248 bool SkClipRRectCommand::render(SkCanvas* canvas) const { | 255 bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
249 render_rrect(canvas, fRRect); | 256 render_rrect(canvas, fRRect); |
250 return true; | 257 return true; |
251 } | 258 } |
252 | 259 |
253 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) | 260 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
254 : INHERITED(kConcat_OpType) { | 261 : INHERITED(CONCAT) { |
255 fMatrix = matrix; | 262 fMatrix = matrix; |
256 | 263 |
257 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 264 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
258 } | 265 } |
259 | 266 |
260 void SkConcatCommand::execute(SkCanvas* canvas) const { | 267 void SkConcatCommand::execute(SkCanvas* canvas) const { |
261 canvas->concat(fMatrix); | 268 canvas->concat(fMatrix); |
262 } | 269 } |
263 | 270 |
264 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 271 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
265 const SkPaint* paint) | 272 const SkPaint* paint) |
266 : INHERITED(kDrawBitmap_OpType) { | 273 : INHERITED(DRAW_BITMAP) { |
267 fBitmap = bitmap; | 274 fBitmap = bitmap; |
268 fLeft = left; | 275 fLeft = left; |
269 fTop = top; | 276 fTop = top; |
270 if (paint) { | 277 if (paint) { |
271 fPaint = *paint; | 278 fPaint = *paint; |
272 fPaintPtr = &fPaint; | 279 fPaintPtr = &fPaint; |
273 } else { | 280 } else { |
274 fPaintPtr = NULL; | 281 fPaintPtr = NULL; |
275 } | 282 } |
276 | 283 |
277 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 284 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
278 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); | 285 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
279 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); | 286 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
280 if (paint) { | 287 if (paint) { |
281 fInfo.push(SkObjectParser::PaintToString(*paint)); | 288 fInfo.push(SkObjectParser::PaintToString(*paint)); |
282 } | 289 } |
283 } | 290 } |
284 | 291 |
285 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { | 292 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { |
286 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); | 293 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
287 } | 294 } |
288 | 295 |
289 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { | 296 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
290 render_bitmap(canvas, fBitmap); | 297 render_bitmap(canvas, fBitmap); |
291 return true; | 298 return true; |
292 } | 299 } |
293 | 300 |
294 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, | 301 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
295 const SkRect& dst, const SkPain
t* paint) | 302 const SkRect& dst, const SkPain
t* paint) |
296 : INHERITED(kDrawBitmapNine_OpType) { | 303 : INHERITED(DRAW_BITMAP_NINE) { |
297 fBitmap = bitmap; | 304 fBitmap = bitmap; |
298 fCenter = center; | 305 fCenter = center; |
299 fDst = dst; | 306 fDst = dst; |
300 if (paint) { | 307 if (paint) { |
301 fPaint = *paint; | 308 fPaint = *paint; |
302 fPaintPtr = &fPaint; | 309 fPaintPtr = &fPaint; |
303 } else { | 310 } else { |
304 fPaintPtr = NULL; | 311 fPaintPtr = NULL; |
305 } | 312 } |
306 | 313 |
(...skipping 10 matching lines...) Expand all Loading... |
317 } | 324 } |
318 | 325 |
319 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { | 326 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
320 render_bitmap(canvas, fBitmap); | 327 render_bitmap(canvas, fBitmap); |
321 return true; | 328 return true; |
322 } | 329 } |
323 | 330 |
324 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, | 331 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, |
325 const SkRect& dst, const SkPain
t* paint, | 332 const SkRect& dst, const SkPain
t* paint, |
326 SkCanvas::DrawBitmapRectFlags f
lags) | 333 SkCanvas::DrawBitmapRectFlags f
lags) |
327 : INHERITED(kDrawBitmapRect_OpType) { | 334 : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { |
328 fBitmap = bitmap; | 335 fBitmap = bitmap; |
329 if (src) { | 336 if (src) { |
330 fSrc = *src; | 337 fSrc = *src; |
331 } else { | 338 } else { |
332 fSrc.setEmpty(); | 339 fSrc.setEmpty(); |
333 } | 340 } |
334 fDst = dst; | 341 fDst = dst; |
335 | 342 |
336 if (paint) { | 343 if (paint) { |
337 fPaint = *paint; | 344 fPaint = *paint; |
(...skipping 17 matching lines...) Expand all Loading... |
355 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { | 362 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { |
356 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); | 363 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); |
357 } | 364 } |
358 | 365 |
359 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 366 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
360 render_bitmap(canvas, fBitmap, this->srcRect()); | 367 render_bitmap(canvas, fBitmap, this->srcRect()); |
361 return true; | 368 return true; |
362 } | 369 } |
363 | 370 |
364 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) | 371 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
365 : INHERITED(kBeginCommentGroup_OpType) | 372 : INHERITED(BEGIN_COMMENT_GROUP) |
366 , fDescription(description) { | 373 , fDescription(description) { |
367 SkString* temp = new SkString; | 374 SkString* temp = new SkString; |
368 temp->appendf("Description: %s", description); | 375 temp->appendf("Description: %s", description); |
369 fInfo.push(temp); | 376 fInfo.push(temp); |
370 } | 377 } |
371 | 378 |
372 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) | 379 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
373 : INHERITED(kComment_OpType) | 380 : INHERITED(COMMENT) |
374 , fKywd(kywd) | 381 , fKywd(kywd) |
375 , fValue(value) { | 382 , fValue(value) { |
376 SkString* temp = new SkString; | 383 SkString* temp = new SkString; |
377 temp->appendf("%s: %s", kywd, value); | 384 temp->appendf("%s: %s", kywd, value); |
378 fInfo.push(temp); | 385 fInfo.push(temp); |
379 } | 386 } |
380 | 387 |
381 SkEndCommentGroupCommand::SkEndCommentGroupCommand() | 388 SkEndCommentGroupCommand::SkEndCommentGroupCommand() |
382 : INHERITED(kEndCommentGroup_OpType) { | 389 : INHERITED(END_COMMENT_GROUP) { |
383 } | 390 } |
384 | 391 |
385 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) | 392 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
386 : INHERITED(kDrawOval_OpType) { | 393 : INHERITED(DRAW_OVAL) { |
387 fOval = oval; | 394 fOval = oval; |
388 fPaint = paint; | 395 fPaint = paint; |
389 | 396 |
390 fInfo.push(SkObjectParser::RectToString(oval)); | 397 fInfo.push(SkObjectParser::RectToString(oval)); |
391 fInfo.push(SkObjectParser::PaintToString(paint)); | 398 fInfo.push(SkObjectParser::PaintToString(paint)); |
392 } | 399 } |
393 | 400 |
394 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { | 401 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { |
395 canvas->drawOval(fOval, fPaint); | 402 canvas->drawOval(fOval, fPaint); |
396 } | 403 } |
397 | 404 |
398 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { | 405 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
399 canvas->clear(0xFFFFFFFF); | 406 canvas->clear(0xFFFFFFFF); |
400 canvas->save(); | 407 canvas->save(); |
401 | 408 |
402 xlate_and_scale_to_bounds(canvas, fOval); | 409 xlate_and_scale_to_bounds(canvas, fOval); |
403 | 410 |
404 SkPaint p; | 411 SkPaint p; |
405 p.setColor(SK_ColorBLACK); | 412 p.setColor(SK_ColorBLACK); |
406 p.setStyle(SkPaint::kStroke_Style); | 413 p.setStyle(SkPaint::kStroke_Style); |
407 | 414 |
408 canvas->drawOval(fOval, p); | 415 canvas->drawOval(fOval, p); |
409 canvas->restore(); | 416 canvas->restore(); |
410 | 417 |
411 return true; | 418 return true; |
412 } | 419 } |
413 | 420 |
414 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) | 421 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
415 : INHERITED(kDrawPaint_OpType) { | 422 : INHERITED(DRAW_PAINT) { |
416 fPaint = paint; | 423 fPaint = paint; |
417 | 424 |
418 fInfo.push(SkObjectParser::PaintToString(paint)); | 425 fInfo.push(SkObjectParser::PaintToString(paint)); |
419 } | 426 } |
420 | 427 |
421 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { | 428 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { |
422 canvas->drawPaint(fPaint); | 429 canvas->drawPaint(fPaint); |
423 } | 430 } |
424 | 431 |
425 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { | 432 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
426 canvas->clear(0xFFFFFFFF); | 433 canvas->clear(0xFFFFFFFF); |
427 canvas->drawPaint(fPaint); | 434 canvas->drawPaint(fPaint); |
428 return true; | 435 return true; |
429 } | 436 } |
430 | 437 |
431 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) | 438 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
432 : INHERITED(kDrawPath_OpType) { | 439 : INHERITED(DRAW_PATH) { |
433 fPath = path; | 440 fPath = path; |
434 fPaint = paint; | 441 fPaint = paint; |
435 | 442 |
436 fInfo.push(SkObjectParser::PathToString(path)); | 443 fInfo.push(SkObjectParser::PathToString(path)); |
437 fInfo.push(SkObjectParser::PaintToString(paint)); | 444 fInfo.push(SkObjectParser::PaintToString(paint)); |
438 } | 445 } |
439 | 446 |
440 void SkDrawPathCommand::execute(SkCanvas* canvas) const { | 447 void SkDrawPathCommand::execute(SkCanvas* canvas) const { |
441 canvas->drawPath(fPath, fPaint); | 448 canvas->drawPath(fPath, fPaint); |
442 } | 449 } |
443 | 450 |
444 bool SkDrawPathCommand::render(SkCanvas* canvas) const { | 451 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
445 render_path(canvas, fPath); | 452 render_path(canvas, fPath); |
446 return true; | 453 return true; |
447 } | 454 } |
448 | 455 |
449 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, | 456 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, |
450 const SkMatrix* matrix, | 457 const SkMatrix* matrix, |
451 const SkPaint* paint) | 458 const SkPaint* paint) |
452 : INHERITED(kDrawPicture_OpType) | 459 : INHERITED(DRAW_PICTURE) |
453 , fPicture(SkRef(picture)) | 460 , fPicture(SkRef(picture)) |
454 , fMatrixPtr(NULL) | 461 , fMatrixPtr(NULL) |
455 , fPaintPtr(NULL) { | 462 , fPaintPtr(NULL) { |
456 | 463 |
457 if (matrix) { | 464 if (matrix) { |
458 fMatrix = *matrix; | 465 fMatrix = *matrix; |
459 fMatrixPtr = &fMatrix; | 466 fMatrixPtr = &fMatrix; |
460 } | 467 } |
461 if (paint) { | 468 if (paint) { |
462 fPaint = *paint; | 469 fPaint = *paint; |
(...skipping 25 matching lines...) Expand all Loading... |
488 | 495 |
489 canvas->drawPicture(fPicture.get()); | 496 canvas->drawPicture(fPicture.get()); |
490 | 497 |
491 canvas->restore(); | 498 canvas->restore(); |
492 | 499 |
493 return true; | 500 return true; |
494 } | 501 } |
495 | 502 |
496 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, | 503 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
497 const SkPoint pts[], const SkPaint& pai
nt) | 504 const SkPoint pts[], const SkPaint& pai
nt) |
498 : INHERITED(kDrawPoints_OpType) { | 505 : INHERITED(DRAW_POINTS) { |
499 fMode = mode; | 506 fMode = mode; |
500 fCount = count; | 507 fCount = count; |
501 fPts = new SkPoint[count]; | 508 fPts = new SkPoint[count]; |
502 memcpy(fPts, pts, count * sizeof(SkPoint)); | 509 memcpy(fPts, pts, count * sizeof(SkPoint)); |
503 fPaint = paint; | 510 fPaint = paint; |
504 | 511 |
505 fInfo.push(SkObjectParser::PointsToString(pts, count)); | 512 fInfo.push(SkObjectParser::PointsToString(pts, count)); |
506 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, | 513 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, |
507 "Points: ")); | 514 "Points: ")); |
508 fInfo.push(SkObjectParser::PointModeToString(mode)); | 515 fInfo.push(SkObjectParser::PointModeToString(mode)); |
(...skipping 22 matching lines...) Expand all Loading... |
531 p.setStyle(SkPaint::kStroke_Style); | 538 p.setStyle(SkPaint::kStroke_Style); |
532 | 539 |
533 canvas->drawPoints(fMode, fCount, fPts, p); | 540 canvas->drawPoints(fMode, fCount, fPts, p); |
534 canvas->restore(); | 541 canvas->restore(); |
535 | 542 |
536 return true; | 543 return true; |
537 } | 544 } |
538 | 545 |
539 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, | 546 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
540 const SkPoint pos[], const SkPaint& p
aint) | 547 const SkPoint pos[], const SkPaint& p
aint) |
541 : INHERITED(kDrawPosText_OpType) { | 548 : INHERITED(DRAW_POS_TEXT) { |
542 size_t numPts = paint.countText(text, byteLength); | 549 size_t numPts = paint.countText(text, byteLength); |
543 | 550 |
544 fText = new char[byteLength]; | 551 fText = new char[byteLength]; |
545 memcpy(fText, text, byteLength); | 552 memcpy(fText, text, byteLength); |
546 fByteLength = byteLength; | 553 fByteLength = byteLength; |
547 | 554 |
548 fPos = new SkPoint[numPts]; | 555 fPos = new SkPoint[numPts]; |
549 memcpy(fPos, pos, numPts * sizeof(SkPoint)); | 556 memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
550 | 557 |
551 fPaint = paint; | 558 fPaint = paint; |
552 | 559 |
553 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 560 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
554 // TODO(chudy): Test that this works. | 561 // TODO(chudy): Test that this works. |
555 fInfo.push(SkObjectParser::PointsToString(pos, 1)); | 562 fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
556 fInfo.push(SkObjectParser::PaintToString(paint)); | 563 fInfo.push(SkObjectParser::PaintToString(paint)); |
557 } | 564 } |
558 | 565 |
559 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { | 566 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { |
560 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 567 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
561 } | 568 } |
562 | 569 |
563 | 570 |
564 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, | 571 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, |
565 const SkScalar xpos[], SkScalar con
stY, | 572 const SkScalar xpos[], SkScalar con
stY, |
566 const SkPaint& paint) | 573 const SkPaint& paint) |
567 : INHERITED(kDrawPosTextH_OpType) { | 574 : INHERITED(DRAW_POS_TEXT_H) { |
568 size_t numPts = paint.countText(text, byteLength); | 575 size_t numPts = paint.countText(text, byteLength); |
569 | 576 |
570 fText = new char[byteLength]; | 577 fText = new char[byteLength]; |
571 memcpy(fText, text, byteLength); | 578 memcpy(fText, text, byteLength); |
572 fByteLength = byteLength; | 579 fByteLength = byteLength; |
573 | 580 |
574 fXpos = new SkScalar[numPts]; | 581 fXpos = new SkScalar[numPts]; |
575 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); | 582 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
576 | 583 |
577 fConstY = constY; | 584 fConstY = constY; |
578 fPaint = paint; | 585 fPaint = paint; |
579 | 586 |
580 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 587 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
581 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); | 588 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
582 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); | 589 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
583 fInfo.push(SkObjectParser::PaintToString(paint)); | 590 fInfo.push(SkObjectParser::PaintToString(paint)); |
584 } | 591 } |
585 | 592 |
586 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { | 593 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { |
587 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 594 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
588 } | 595 } |
589 | 596 |
590 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, | 597 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, |
591 const SkPaint& paint) | 598 const SkPaint& paint) |
592 : INHERITED(kDrawTextBlob_OpType) | 599 : INHERITED(DRAW_TEXT_BLOB) |
593 , fBlob(blob) | 600 , fBlob(blob) |
594 , fXPos(x) | 601 , fXPos(x) |
595 , fYPos(y) | 602 , fYPos(y) |
596 , fPaint(paint) { | 603 , fPaint(paint) { |
597 | 604 |
598 blob->ref(); | 605 blob->ref(); |
599 | 606 |
600 // FIXME: push blob info | 607 // FIXME: push blob info |
601 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); | 608 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); |
602 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); | 609 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); |
(...skipping 12 matching lines...) Expand all Loading... |
615 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); | 622 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); |
616 xlate_and_scale_to_bounds(canvas, bounds); | 623 xlate_and_scale_to_bounds(canvas, bounds); |
617 | 624 |
618 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); | 625 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); |
619 | 626 |
620 canvas->restore(); | 627 canvas->restore(); |
621 | 628 |
622 return true; | 629 return true; |
623 } | 630 } |
624 | 631 |
625 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], | |
626 const SkPoint texCoords[4], SkXfermode* x
fermode, | |
627 const SkPaint& paint) | |
628 : INHERITED(kDrawPatch_OpType) { | |
629 memcpy(fCubics, cubics, sizeof(fCubics)); | |
630 memcpy(fColors, colors, sizeof(fColors)); | |
631 memcpy(fTexCoords, texCoords, sizeof(fTexCoords)); | |
632 fXfermode.reset(xfermode); | |
633 fPaint = paint; | |
634 | |
635 fInfo.push(SkObjectParser::PaintToString(paint)); | |
636 } | |
637 | |
638 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { | |
639 canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint); | |
640 } | |
641 | |
642 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) | 632 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) |
643 : INHERITED(kDrawRect_OpType) { | 633 : INHERITED(DRAW_RECT) { |
644 fRect = rect; | 634 fRect = rect; |
645 fPaint = paint; | 635 fPaint = paint; |
646 | 636 |
647 fInfo.push(SkObjectParser::RectToString(rect)); | 637 fInfo.push(SkObjectParser::RectToString(rect)); |
648 fInfo.push(SkObjectParser::PaintToString(paint)); | 638 fInfo.push(SkObjectParser::PaintToString(paint)); |
649 } | 639 } |
650 | 640 |
651 void SkDrawRectCommand::execute(SkCanvas* canvas) const { | 641 void SkDrawRectCommand::execute(SkCanvas* canvas) const { |
652 canvas->drawRect(fRect, fPaint); | 642 canvas->drawRect(fRect, fPaint); |
653 } | 643 } |
654 | 644 |
655 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) | 645 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) |
656 : INHERITED(kDrawRRect_OpType) { | 646 : INHERITED(DRAW_RRECT) { |
657 fRRect = rrect; | 647 fRRect = rrect; |
658 fPaint = paint; | 648 fPaint = paint; |
659 | 649 |
660 fInfo.push(SkObjectParser::RRectToString(rrect)); | 650 fInfo.push(SkObjectParser::RRectToString(rrect)); |
661 fInfo.push(SkObjectParser::PaintToString(paint)); | 651 fInfo.push(SkObjectParser::PaintToString(paint)); |
662 } | 652 } |
663 | 653 |
664 void SkDrawRRectCommand::execute(SkCanvas* canvas) const { | 654 void SkDrawRRectCommand::execute(SkCanvas* canvas) const { |
665 canvas->drawRRect(fRRect, fPaint); | 655 canvas->drawRRect(fRRect, fPaint); |
666 } | 656 } |
667 | 657 |
668 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { | 658 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
669 render_rrect(canvas, fRRect); | 659 render_rrect(canvas, fRRect); |
670 return true; | 660 return true; |
671 } | 661 } |
672 | 662 |
673 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, | 663 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
674 const SkRRect& inner, | 664 const SkRRect& inner, |
675 const SkPaint& paint) | 665 const SkPaint& paint) |
676 : INHERITED(kDrawDRRect_OpType) { | 666 : INHERITED(DRAW_DRRECT) { |
677 fOuter = outer; | 667 fOuter = outer; |
678 fInner = inner; | 668 fInner = inner; |
679 fPaint = paint; | 669 fPaint = paint; |
680 | 670 |
681 fInfo.push(SkObjectParser::RRectToString(outer)); | 671 fInfo.push(SkObjectParser::RRectToString(outer)); |
682 fInfo.push(SkObjectParser::RRectToString(inner)); | 672 fInfo.push(SkObjectParser::RRectToString(inner)); |
683 fInfo.push(SkObjectParser::PaintToString(paint)); | 673 fInfo.push(SkObjectParser::PaintToString(paint)); |
684 } | 674 } |
685 | 675 |
686 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { | 676 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { |
687 canvas->drawDRRect(fOuter, fInner, fPaint); | 677 canvas->drawDRRect(fOuter, fInner, fPaint); |
688 } | 678 } |
689 | 679 |
690 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { | 680 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
691 render_drrect(canvas, fOuter, fInner); | 681 render_drrect(canvas, fOuter, fInner); |
692 return true; | 682 return true; |
693 } | 683 } |
694 | 684 |
695 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, | 685 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
696 const SkPaint* paint) | 686 const SkPaint* paint) |
697 : INHERITED(kDrawSprite_OpType) { | 687 : INHERITED(DRAW_SPRITE) { |
698 fBitmap = bitmap; | 688 fBitmap = bitmap; |
699 fLeft = left; | 689 fLeft = left; |
700 fTop = top; | 690 fTop = top; |
701 if (paint) { | 691 if (paint) { |
702 fPaint = *paint; | 692 fPaint = *paint; |
703 fPaintPtr = &fPaint; | 693 fPaintPtr = &fPaint; |
704 } else { | 694 } else { |
705 fPaintPtr = NULL; | 695 fPaintPtr = NULL; |
706 } | 696 } |
707 | 697 |
708 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 698 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
709 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); | 699 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
710 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); | 700 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
711 if (paint) { | 701 if (paint) { |
712 fInfo.push(SkObjectParser::PaintToString(*paint)); | 702 fInfo.push(SkObjectParser::PaintToString(*paint)); |
713 } | 703 } |
714 } | 704 } |
715 | 705 |
716 void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { | 706 void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { |
717 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); | 707 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
718 } | 708 } |
719 | 709 |
720 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { | 710 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
721 render_bitmap(canvas, fBitmap); | 711 render_bitmap(canvas, fBitmap); |
722 return true; | 712 return true; |
723 } | 713 } |
724 | 714 |
725 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, | 715 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, |
726 const SkPaint& paint) | 716 const SkPaint& paint) |
727 : INHERITED(kDrawText_OpType) { | 717 : INHERITED(DRAW_TEXT) { |
728 fText = new char[byteLength]; | 718 fText = new char[byteLength]; |
729 memcpy(fText, text, byteLength); | 719 memcpy(fText, text, byteLength); |
730 fByteLength = byteLength; | 720 fByteLength = byteLength; |
731 fX = x; | 721 fX = x; |
732 fY = y; | 722 fY = y; |
733 fPaint = paint; | 723 fPaint = paint; |
734 | 724 |
735 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 725 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
736 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); | 726 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
737 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); | 727 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
738 fInfo.push(SkObjectParser::PaintToString(paint)); | 728 fInfo.push(SkObjectParser::PaintToString(paint)); |
739 } | 729 } |
740 | 730 |
741 void SkDrawTextCommand::execute(SkCanvas* canvas) const { | 731 void SkDrawTextCommand::execute(SkCanvas* canvas) const { |
742 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 732 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
743 } | 733 } |
744 | 734 |
745 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, | 735 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
746 const SkPath& path, const SkMat
rix* matrix, | 736 const SkPath& path, const SkMat
rix* matrix, |
747 const SkPaint& paint) | 737 const SkPaint& paint) |
748 : INHERITED(kDrawTextOnPath_OpType) { | 738 : INHERITED(DRAW_TEXT_ON_PATH) { |
749 fText = new char[byteLength]; | 739 fText = new char[byteLength]; |
750 memcpy(fText, text, byteLength); | 740 memcpy(fText, text, byteLength); |
751 fByteLength = byteLength; | 741 fByteLength = byteLength; |
752 fPath = path; | 742 fPath = path; |
753 if (matrix) { | 743 if (matrix) { |
754 fMatrix = *matrix; | 744 fMatrix = *matrix; |
755 } else { | 745 } else { |
756 fMatrix.setIdentity(); | 746 fMatrix.setIdentity(); |
757 } | 747 } |
758 fPaint = paint; | 748 fPaint = paint; |
(...skipping 10 matching lines...) Expand all Loading... |
769 canvas->drawTextOnPath(fText, fByteLength, fPath, | 759 canvas->drawTextOnPath(fText, fByteLength, fPath, |
770 fMatrix.isIdentity() ? NULL : &fMatrix, | 760 fMatrix.isIdentity() ? NULL : &fMatrix, |
771 fPaint); | 761 fPaint); |
772 } | 762 } |
773 | 763 |
774 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, | 764 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, |
775 const SkPoint vertices[], const SkP
oint texs[], | 765 const SkPoint vertices[], const SkP
oint texs[], |
776 const SkColor colors[], SkXfermode*
xfermode, | 766 const SkColor colors[], SkXfermode*
xfermode, |
777 const uint16_t indices[], int index
Count, | 767 const uint16_t indices[], int index
Count, |
778 const SkPaint& paint) | 768 const SkPaint& paint) |
779 : INHERITED(kDrawVertices_OpType) { | 769 : INHERITED(DRAW_VERTICES) { |
780 fVmode = vmode; | 770 fVmode = vmode; |
781 | 771 |
782 fVertexCount = vertexCount; | 772 fVertexCount = vertexCount; |
783 | 773 |
784 fVertices = new SkPoint[vertexCount]; | 774 fVertices = new SkPoint[vertexCount]; |
785 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); | 775 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
786 | 776 |
787 if (texs) { | 777 if (texs) { |
788 fTexs = new SkPoint[vertexCount]; | 778 fTexs = new SkPoint[vertexCount]; |
789 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); | 779 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 delete [] fIndices; | 816 delete [] fIndices; |
827 } | 817 } |
828 | 818 |
829 void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { | 819 void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { |
830 canvas->drawVertices(fVmode, fVertexCount, fVertices, | 820 canvas->drawVertices(fVmode, fVertexCount, fVertices, |
831 fTexs, fColors, fXfermode, fIndices, | 821 fTexs, fColors, fXfermode, fIndices, |
832 fIndexCount, fPaint); | 822 fIndexCount, fPaint); |
833 } | 823 } |
834 | 824 |
835 SkRestoreCommand::SkRestoreCommand() | 825 SkRestoreCommand::SkRestoreCommand() |
836 : INHERITED(kRestore_OpType) { | 826 : INHERITED(RESTORE) { |
837 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 827 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
838 } | 828 } |
839 | 829 |
840 void SkRestoreCommand::execute(SkCanvas* canvas) const { | 830 void SkRestoreCommand::execute(SkCanvas* canvas) const { |
841 canvas->restore(); | 831 canvas->restore(); |
842 } | 832 } |
843 | 833 |
| 834 SkRotateCommand::SkRotateCommand(SkScalar degrees) |
| 835 : INHERITED(ROTATE) { |
| 836 fDegrees = degrees; |
| 837 |
| 838 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
| 839 } |
| 840 |
| 841 void SkRotateCommand::execute(SkCanvas* canvas) const { |
| 842 canvas->rotate(fDegrees); |
| 843 } |
| 844 |
844 SkSaveCommand::SkSaveCommand() | 845 SkSaveCommand::SkSaveCommand() |
845 : INHERITED(kSave_OpType) { | 846 : INHERITED(SAVE) { |
846 } | 847 } |
847 | 848 |
848 void SkSaveCommand::execute(SkCanvas* canvas) const { | 849 void SkSaveCommand::execute(SkCanvas* canvas) const { |
849 canvas->save(); | 850 canvas->save(); |
850 } | 851 } |
851 | 852 |
852 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, | 853 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, |
853 SkCanvas::SaveFlags flags) | 854 SkCanvas::SaveFlags flags) |
854 : INHERITED(kSaveLayer_OpType) { | 855 : INHERITED(SAVE_LAYER) { |
855 if (bounds) { | 856 if (bounds) { |
856 fBounds = *bounds; | 857 fBounds = *bounds; |
857 } else { | 858 } else { |
858 fBounds.setEmpty(); | 859 fBounds.setEmpty(); |
859 } | 860 } |
860 | 861 |
861 if (paint) { | 862 if (paint) { |
862 fPaint = *paint; | 863 fPaint = *paint; |
863 fPaintPtr = &fPaint; | 864 fPaintPtr = &fPaint; |
864 } else { | 865 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
878 void SkSaveLayerCommand::execute(SkCanvas* canvas) const { | 879 void SkSaveLayerCommand::execute(SkCanvas* canvas) const { |
879 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, | 880 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
880 fPaintPtr, | 881 fPaintPtr, |
881 fFlags); | 882 fFlags); |
882 } | 883 } |
883 | 884 |
884 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { | 885 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { |
885 canvas->save(); | 886 canvas->save(); |
886 } | 887 } |
887 | 888 |
| 889 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) |
| 890 : INHERITED(SCALE) { |
| 891 fSx = sx; |
| 892 fSy = sy; |
| 893 |
| 894 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 895 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 896 } |
| 897 |
| 898 void SkScaleCommand::execute(SkCanvas* canvas) const { |
| 899 canvas->scale(fSx, fSy); |
| 900 } |
| 901 |
888 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) | 902 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) |
889 : INHERITED(kSetMatrix_OpType) { | 903 : INHERITED(SET_MATRIX) { |
890 fUserMatrix.reset(); | 904 fUserMatrix.reset(); |
891 fMatrix = matrix; | 905 fMatrix = matrix; |
892 | 906 |
893 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 907 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
894 } | 908 } |
895 | 909 |
896 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 910 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
897 fUserMatrix = userMatrix; | 911 fUserMatrix = userMatrix; |
898 } | 912 } |
899 | 913 |
900 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 914 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
901 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 915 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
902 canvas->setMatrix(temp); | 916 canvas->setMatrix(temp); |
903 } | 917 } |
904 | 918 |
| 919 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) |
| 920 : INHERITED(SKEW) { |
| 921 fSx = sx; |
| 922 fSy = sy; |
| 923 |
| 924 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 925 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 926 } |
| 927 |
| 928 void SkSkewCommand::execute(SkCanvas* canvas) const { |
| 929 canvas->skew(fSx, fSy); |
| 930 } |
| 931 |
| 932 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) |
| 933 : INHERITED(TRANSLATE) { |
| 934 fDx = dx; |
| 935 fDy = dy; |
| 936 |
| 937 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 938 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
| 939 } |
| 940 |
| 941 void SkTranslateCommand::execute(SkCanvas* canvas) const { |
| 942 canvas->translate(fDx, fDy); |
| 943 } |
| 944 |
OLD | NEW |