OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 #ifndef SkCanvas_DEFINED | 10 #ifndef SkCanvas_DEFINED |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 @param y1 The y-coordinate of the end point of the line | 568 @param y1 The y-coordinate of the end point of the line |
569 @param paint The paint used to draw the line | 569 @param paint The paint used to draw the line |
570 */ | 570 */ |
571 void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, | 571 void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, |
572 const SkPaint& paint); | 572 const SkPaint& paint); |
573 | 573 |
574 /** Draw the specified rectangle using the specified paint. The rectangle | 574 /** Draw the specified rectangle using the specified paint. The rectangle |
575 will be filled or stroked based on the Style in the paint. | 575 will be filled or stroked based on the Style in the paint. |
576 @param rect The rect to be drawn | 576 @param rect The rect to be drawn |
577 @param paint The paint used to draw the rect | 577 @param paint The paint used to draw the rect |
| 578 |
| 579 Overriding this function is deprecated. It will be made non-virtual |
| 580 soon. Instead override onDrawRect. |
578 */ | 581 */ |
579 virtual void drawRect(const SkRect& rect, const SkPaint& paint); | 582 virtual void drawRect(const SkRect& rect, const SkPaint& paint) { |
| 583 this->onDrawRect(rect, paint); |
| 584 } |
580 | 585 |
581 /** Draw the specified rectangle using the specified paint. The rectangle | 586 /** Draw the specified rectangle using the specified paint. The rectangle |
582 will be filled or framed based on the Style in the paint. | 587 will be filled or framed based on the Style in the paint. |
583 @param rect The rect to be drawn | 588 @param rect The rect to be drawn |
584 @param paint The paint used to draw the rect | 589 @param paint The paint used to draw the rect |
585 */ | 590 */ |
586 void drawIRect(const SkIRect& rect, const SkPaint& paint) | 591 void drawIRect(const SkIRect& rect, const SkPaint& paint) { |
587 { | |
588 SkRect r; | 592 SkRect r; |
589 r.set(rect); // promotes the ints to scalars | 593 r.set(rect); // promotes the ints to scalars |
590 this->drawRect(r, paint); | 594 this->drawRect(r, paint); |
591 } | 595 } |
592 | 596 |
593 /** Draw the specified rectangle using the specified paint. The rectangle | 597 /** Draw the specified rectangle using the specified paint. The rectangle |
594 will be filled or framed based on the Style in the paint. | 598 will be filled or framed based on the Style in the paint. |
595 @param left The left side of the rectangle to be drawn | 599 @param left The left side of the rectangle to be drawn |
596 @param top The top side of the rectangle to be drawn | 600 @param top The top side of the rectangle to be drawn |
597 @param right The right side of the rectangle to be drawn | 601 @param right The right side of the rectangle to be drawn |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 @param ry The y-radius of the oval used to round the corners | 653 @param ry The y-radius of the oval used to round the corners |
650 @param paint The paint used to draw the roundRect | 654 @param paint The paint used to draw the roundRect |
651 */ | 655 */ |
652 void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, | 656 void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, |
653 const SkPaint& paint); | 657 const SkPaint& paint); |
654 | 658 |
655 /** Draw the specified path using the specified paint. The path will be | 659 /** Draw the specified path using the specified paint. The path will be |
656 filled or framed based on the Style in the paint. | 660 filled or framed based on the Style in the paint. |
657 @param path The path to be drawn | 661 @param path The path to be drawn |
658 @param paint The paint used to draw the path | 662 @param paint The paint used to draw the path |
| 663 |
| 664 Overriding this function is deprecated. It will be made non-virtual |
| 665 soon. Instead override onDrawRect. |
659 */ | 666 */ |
660 virtual void drawPath(const SkPath& path, const SkPaint& paint); | 667 virtual void drawPath(const SkPath& path, const SkPaint& paint) { |
| 668 SkRect rect; |
| 669 if (path.isRect(&rect) && !path.isInverseFillType()) { |
| 670 this->onDrawRect(rect, paint); |
| 671 } else { |
| 672 this->onDrawPath(path, paint); |
| 673 } |
| 674 } |
661 | 675 |
662 /** Draw the specified bitmap, with its top/left corner at (x,y), using the | 676 /** Draw the specified bitmap, with its top/left corner at (x,y), using the |
663 specified paint, transformed by the current matrix. Note: if the paint | 677 specified paint, transformed by the current matrix. Note: if the paint |
664 contains a maskfilter that generates a mask which extends beyond the | 678 contains a maskfilter that generates a mask which extends beyond the |
665 bitmap's original width/height, then the bitmap will be drawn as if it | 679 bitmap's original width/height, then the bitmap will be drawn as if it |
666 were in a Shader with CLAMP mode. Thus the color outside of the original | 680 were in a Shader with CLAMP mode. Thus the color outside of the original |
667 width/height will be the edge color replicated. | 681 width/height will be the edge color replicated. |
668 @param bitmap The bitmap to be drawn | 682 @param bitmap The bitmap to be drawn |
669 @param left The position of the left side of the bitmap being drawn | 683 @param left The position of the left side of the bitmap being drawn |
670 @param top The position of the top side of the bitmap being drawn | 684 @param top The position of the top side of the bitmap being drawn |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1041 |
1028 // Called by child classes that override clipPath and clipRRect to only | 1042 // Called by child classes that override clipPath and clipRRect to only |
1029 // track fast conservative clip bounds, rather than exact clips. | 1043 // track fast conservative clip bounds, rather than exact clips. |
1030 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, | 1044 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, |
1031 bool inverseFilled); | 1045 bool inverseFilled); |
1032 | 1046 |
1033 // notify our surface (if we have one) that we are about to draw, so it | 1047 // notify our surface (if we have one) that we are about to draw, so it |
1034 // can perform copy-on-write or invalidate any cached images | 1048 // can perform copy-on-write or invalidate any cached images |
1035 void predrawNotify(); | 1049 void predrawNotify(); |
1036 | 1050 |
| 1051 virtual void onDrawRect(const SkRect& rect, const SkPaint& paint); |
| 1052 |
| 1053 virtual void onDrawPath(const SkPath& path, const SkPaint& paint); |
| 1054 |
1037 /** DEPRECATED -- use constructor(device) | 1055 /** DEPRECATED -- use constructor(device) |
1038 | 1056 |
1039 Marked as 'protected' to avoid new clients using this before we can | 1057 Marked as 'protected' to avoid new clients using this before we can |
1040 completely remove it. | 1058 completely remove it. |
1041 | 1059 |
1042 Specify a device for this canvas to draw into. If it is not null, its | 1060 Specify a device for this canvas to draw into. If it is not null, its |
1043 reference count is incremented. If the canvas was already holding a | 1061 reference count is incremented. If the canvas was already holding a |
1044 device, its reference count is decremented. The new device is returned. | 1062 device, its reference count is decremented. The new device is returned. |
1045 */ | 1063 */ |
1046 virtual SkBaseDevice* setDevice(SkBaseDevice* device); | 1064 virtual SkBaseDevice* setDevice(SkBaseDevice* device); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 if (NULL != fCanvas) { | 1208 if (NULL != fCanvas) { |
1191 fCanvas->endCommentGroup(); | 1209 fCanvas->endCommentGroup(); |
1192 } | 1210 } |
1193 } | 1211 } |
1194 | 1212 |
1195 private: | 1213 private: |
1196 SkCanvas* fCanvas; | 1214 SkCanvas* fCanvas; |
1197 }; | 1215 }; |
1198 | 1216 |
1199 #endif | 1217 #endif |
OLD | NEW |