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 #ifndef SKDRAWCOMMAND_H_ | 9 #ifndef SKDRAWCOMMAND_H_ |
10 #define SKDRAWCOMMAND_H_ | 10 #define SKDRAWCOMMAND_H_ |
11 | 11 |
12 #include "SkPictureFlat.h" | |
13 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
14 #include "SkString.h" | 13 #include "SkString.h" |
15 | 14 |
16 class SK_API SkDrawCommand { | 15 class SK_API SkDrawCommand { |
17 public: | 16 public: |
18 // Staging for Chromium | 17 // Staging for Chromium |
19 typedef DrawType OpType; | |
20 | |
21 static const int kOpTypeCount = LAST_DRAWTYPE_ENUM+1; | |
22 | |
23 static const char* kDrawRectString; | 18 static const char* kDrawRectString; |
24 static const char* kClipRectString; | 19 static const char* kClipRectString; |
25 | |
26 static const OpType kSave_OpType; | |
27 static const OpType kClipRect_OpType; | |
28 static const OpType kDrawRect_OpType; | |
29 static const OpType kRestore_OpType; | |
30 static const OpType kSetMatrix_OpType; | |
31 // End Staging | 20 // End Staging |
32 | 21 |
| 22 enum OpType { |
| 23 kBeginCommentGroup_OpType, |
| 24 kClipPath_OpType, |
| 25 kClipRegion_OpType, |
| 26 kClipRect_OpType, |
| 27 kClipRRect_OpType, |
| 28 kComment_OpType, |
| 29 kConcat_OpType, |
| 30 kDrawBitmap_OpType, |
| 31 kDrawBitmapNine_OpType, |
| 32 kDrawBitmapRect_OpType, |
| 33 kDrawClear_OpType, |
| 34 kDrawDRRect_OpType, |
| 35 kDrawOval_OpType, |
| 36 kDrawPaint_OpType, |
| 37 kDrawPatch_OpType, |
| 38 kDrawPath_OpType, |
| 39 kDrawPicture_OpType, |
| 40 kDrawPoints_OpType, |
| 41 kDrawPosText_OpType, |
| 42 kDrawPosTextH_OpType, |
| 43 kDrawRect_OpType, |
| 44 kDrawRRect_OpType, |
| 45 kDrawSprite_OpType, |
| 46 kDrawText_OpType, |
| 47 kDrawTextBlob_OpType, |
| 48 kDrawTextOnPath_OpType, |
| 49 kDrawVertices_OpType, |
| 50 kEndCommentGroup_OpType, |
| 51 kRestore_OpType, |
| 52 kSave_OpType, |
| 53 kSaveLayer_OpType, |
| 54 kSetMatrix_OpType, |
33 | 55 |
34 SkDrawCommand(DrawType drawType); | 56 kLast_OpType = kSetMatrix_OpType |
| 57 }; |
| 58 |
| 59 static const int kOpTypeCount = kLast_OpType + 1; |
| 60 |
| 61 SkDrawCommand(OpType opType); |
35 | 62 |
36 virtual ~SkDrawCommand(); | 63 virtual ~SkDrawCommand(); |
37 | 64 |
38 virtual SkString toString() const; | 65 virtual SkString toString() const; |
39 | 66 |
40 void setOffset(size_t offset) { fOffset = offset; } | 67 void setOffset(size_t offset) { fOffset = offset; } |
41 size_t offset() const { return fOffset; } | 68 size_t offset() const { return fOffset; } |
42 | 69 |
43 virtual const char* toCString() const { | 70 virtual const char* toCString() const { |
44 return GetCommandString(fDrawType); | 71 return GetCommandString(fOpType); |
45 } | 72 } |
46 | 73 |
47 bool isVisible() const { | 74 bool isVisible() const { |
48 return fVisible; | 75 return fVisible; |
49 } | 76 } |
50 | 77 |
51 void setVisible(bool toggle) { | 78 void setVisible(bool toggle) { |
52 fVisible = toggle; | 79 fVisible = toggle; |
53 } | 80 } |
54 | 81 |
(...skipping 11 matching lines...) Expand all Loading... |
66 // saveLayers return kPushLayer but also track the active state | 93 // saveLayers return kPushLayer but also track the active state |
67 enum Action { | 94 enum Action { |
68 kNone_Action, | 95 kNone_Action, |
69 kPopLayer_Action, | 96 kPopLayer_Action, |
70 kPushLayer_Action, | 97 kPushLayer_Action, |
71 }; | 98 }; |
72 virtual Action action() const { return kNone_Action; } | 99 virtual Action action() const { return kNone_Action; } |
73 virtual void setActive(bool active) {} | 100 virtual void setActive(bool active) {} |
74 virtual bool active() const { return false; } | 101 virtual bool active() const { return false; } |
75 | 102 |
76 DrawType getType() const { return fDrawType; } | 103 OpType getType() const { return fOpType; } |
77 | 104 |
78 virtual bool render(SkCanvas* canvas) const { return false; } | 105 virtual bool render(SkCanvas* canvas) const { return false; } |
79 | 106 |
80 static const char* GetCommandString(DrawType type); | 107 static const char* GetCommandString(OpType type); |
81 | 108 |
82 protected: | 109 protected: |
83 SkTDArray<SkString*> fInfo; | 110 SkTDArray<SkString*> fInfo; |
84 | 111 |
85 private: | 112 private: |
86 DrawType fDrawType; | 113 OpType fOpType; |
87 size_t fOffset; | 114 size_t fOffset; |
88 bool fVisible; | 115 bool fVisible; |
89 }; | 116 }; |
90 | 117 |
91 class SkRestoreCommand : public SkDrawCommand { | 118 class SkRestoreCommand : public SkDrawCommand { |
92 public: | 119 public: |
93 SkRestoreCommand(); | 120 SkRestoreCommand(); |
94 void execute(SkCanvas* canvas) const SK_OVERRIDE; | 121 void execute(SkCanvas* canvas) const SK_OVERRIDE; |
95 Action action() const SK_OVERRIDE { return kPopLayer_Action; } | 122 Action action() const SK_OVERRIDE { return kPopLayer_Action; } |
96 | 123 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 450 |
424 private: | 451 private: |
425 SkAutoTUnref<const SkTextBlob> fBlob; | 452 SkAutoTUnref<const SkTextBlob> fBlob; |
426 SkScalar fXPos; | 453 SkScalar fXPos; |
427 SkScalar fYPos; | 454 SkScalar fYPos; |
428 SkPaint fPaint; | 455 SkPaint fPaint; |
429 | 456 |
430 typedef SkDrawCommand INHERITED; | 457 typedef SkDrawCommand INHERITED; |
431 }; | 458 }; |
432 | 459 |
| 460 class SkDrawPatchCommand : public SkDrawCommand { |
| 461 public: |
| 462 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4], |
| 463 const SkPoint texCoords[4], SkXfermode* xmode, |
| 464 const SkPaint& paint); |
| 465 void execute(SkCanvas* canvas) const SK_OVERRIDE; |
| 466 |
| 467 private: |
| 468 SkPoint fCubics[12]; |
| 469 SkColor fColors[4]; |
| 470 SkPoint fTexCoords[4]; |
| 471 SkAutoTUnref<SkXfermode> fXfermode; |
| 472 SkPaint fPaint; |
| 473 |
| 474 typedef SkDrawCommand INHERITED; |
| 475 }; |
| 476 |
| 477 |
433 class SkDrawRectCommand : public SkDrawCommand { | 478 class SkDrawRectCommand : public SkDrawCommand { |
434 public: | 479 public: |
435 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); | 480 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); |
436 void execute(SkCanvas* canvas) const SK_OVERRIDE; | 481 void execute(SkCanvas* canvas) const SK_OVERRIDE; |
437 | 482 |
438 const SkRect& rect() const { return fRect; } | 483 const SkRect& rect() const { return fRect; } |
439 const SkPaint& paint() const { return fPaint; } | 484 const SkPaint& paint() const { return fPaint; } |
440 private: | 485 private: |
441 SkRect fRect; | 486 SkRect fRect; |
442 SkPaint fPaint; | 487 SkPaint fPaint; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 SkPoint* fTexs; | 546 SkPoint* fTexs; |
502 SkColor* fColors; | 547 SkColor* fColors; |
503 SkXfermode* fXfermode; | 548 SkXfermode* fXfermode; |
504 uint16_t* fIndices; | 549 uint16_t* fIndices; |
505 int fIndexCount; | 550 int fIndexCount; |
506 SkPaint fPaint; | 551 SkPaint fPaint; |
507 | 552 |
508 typedef SkDrawCommand INHERITED; | 553 typedef SkDrawCommand INHERITED; |
509 }; | 554 }; |
510 | 555 |
511 class SkRotateCommand : public SkDrawCommand { | |
512 public: | |
513 SkRotateCommand(SkScalar degrees); | |
514 void execute(SkCanvas* canvas) const SK_OVERRIDE; | |
515 private: | |
516 SkScalar fDegrees; | |
517 | |
518 typedef SkDrawCommand INHERITED; | |
519 }; | |
520 | |
521 class SkSaveCommand : public SkDrawCommand { | 556 class SkSaveCommand : public SkDrawCommand { |
522 public: | 557 public: |
523 SkSaveCommand(); | 558 SkSaveCommand(); |
524 void execute(SkCanvas* canvas) const SK_OVERRIDE; | 559 void execute(SkCanvas* canvas) const SK_OVERRIDE; |
525 Action action() const SK_OVERRIDE { return kPushLayer_Action; } | 560 Action action() const SK_OVERRIDE { return kPushLayer_Action; } |
526 private: | 561 private: |
527 typedef SkDrawCommand INHERITED; | 562 typedef SkDrawCommand INHERITED; |
528 }; | 563 }; |
529 | 564 |
530 class SkSaveLayerCommand : public SkDrawCommand { | 565 class SkSaveLayerCommand : public SkDrawCommand { |
(...skipping 12 matching lines...) Expand all Loading... |
543 SkRect fBounds; | 578 SkRect fBounds; |
544 SkPaint fPaint; | 579 SkPaint fPaint; |
545 SkPaint* fPaintPtr; | 580 SkPaint* fPaintPtr; |
546 SkCanvas::SaveFlags fFlags; | 581 SkCanvas::SaveFlags fFlags; |
547 | 582 |
548 bool fActive; | 583 bool fActive; |
549 | 584 |
550 typedef SkDrawCommand INHERITED; | 585 typedef SkDrawCommand INHERITED; |
551 }; | 586 }; |
552 | 587 |
553 class SkScaleCommand : public SkDrawCommand { | |
554 public: | |
555 SkScaleCommand(SkScalar sx, SkScalar sy); | |
556 void execute(SkCanvas* canvas) const SK_OVERRIDE; | |
557 | |
558 SkScalar x() const { return fSx; } | |
559 SkScalar y() const { return fSy; } | |
560 | |
561 private: | |
562 SkScalar fSx; | |
563 SkScalar fSy; | |
564 | |
565 typedef SkDrawCommand INHERITED; | |
566 }; | |
567 | |
568 class SkSetMatrixCommand : public SkDrawCommand { | 588 class SkSetMatrixCommand : public SkDrawCommand { |
569 public: | 589 public: |
570 SkSetMatrixCommand(const SkMatrix& matrix); | 590 SkSetMatrixCommand(const SkMatrix& matrix); |
571 void setUserMatrix(const SkMatrix&) SK_OVERRIDE; | 591 void setUserMatrix(const SkMatrix&) SK_OVERRIDE; |
572 void execute(SkCanvas* canvas) const SK_OVERRIDE; | 592 void execute(SkCanvas* canvas) const SK_OVERRIDE; |
573 private: | 593 private: |
574 SkMatrix fUserMatrix; | 594 SkMatrix fUserMatrix; |
575 SkMatrix fMatrix; | 595 SkMatrix fMatrix; |
576 | 596 |
577 typedef SkDrawCommand INHERITED; | 597 typedef SkDrawCommand INHERITED; |
578 }; | 598 }; |
579 | 599 |
580 class SkSkewCommand : public SkDrawCommand { | |
581 public: | |
582 SkSkewCommand(SkScalar sx, SkScalar sy); | |
583 void execute(SkCanvas* canvas) const SK_OVERRIDE; | |
584 private: | |
585 SkScalar fSx; | |
586 SkScalar fSy; | |
587 | |
588 typedef SkDrawCommand INHERITED; | |
589 }; | |
590 | |
591 class SkTranslateCommand : public SkDrawCommand { | |
592 public: | |
593 SkTranslateCommand(SkScalar dx, SkScalar dy); | |
594 void execute(SkCanvas* canvas) const SK_OVERRIDE; | |
595 | |
596 SkScalar x() const { return fDx; } | |
597 SkScalar y() const { return fDy; } | |
598 | |
599 private: | |
600 SkScalar fDx; | |
601 SkScalar fDy; | |
602 | |
603 typedef SkDrawCommand INHERITED; | |
604 }; | |
605 | |
606 #endif | 600 #endif |
OLD | NEW |