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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 */ | 578 */ |
579 virtual void drawRect(const SkRect& rect, const SkPaint& paint); | 579 void drawRect(const SkRect& rect, const SkPaint& paint) |
580 { | |
bsalomon
2013/10/15 13:25:51
style nit: brace on prev line.
| |
581 this->onDrawRect(rect, paint); | |
582 } | |
580 | 583 |
581 /** Draw the specified rectangle using the specified paint. The rectangle | 584 /** Draw the specified rectangle using the specified paint. The rectangle |
582 will be filled or framed based on the Style in the paint. | 585 will be filled or framed based on the Style in the paint. |
583 @param rect The rect to be drawn | 586 @param rect The rect to be drawn |
584 @param paint The paint used to draw the rect | 587 @param paint The paint used to draw the rect |
585 */ | 588 */ |
586 void drawIRect(const SkIRect& rect, const SkPaint& paint) | 589 void drawIRect(const SkIRect& rect, const SkPaint& paint) |
587 { | 590 { |
588 SkRect r; | 591 SkRect r; |
589 r.set(rect); // promotes the ints to scalars | 592 r.set(rect); // promotes the ints to scalars |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 @param paint The paint used to draw the roundRect | 653 @param paint The paint used to draw the roundRect |
651 */ | 654 */ |
652 void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, | 655 void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, |
653 const SkPaint& paint); | 656 const SkPaint& paint); |
654 | 657 |
655 /** Draw the specified path using the specified paint. The path will be | 658 /** Draw the specified path using the specified paint. The path will be |
656 filled or framed based on the Style in the paint. | 659 filled or framed based on the Style in the paint. |
657 @param path The path to be drawn | 660 @param path The path to be drawn |
658 @param paint The paint used to draw the path | 661 @param paint The paint used to draw the path |
659 */ | 662 */ |
660 virtual void drawPath(const SkPath& path, const SkPaint& paint); | 663 void drawPath(const SkPath& path, const SkPaint& paint) { |
664 SkRect rect; | |
665 if (path.isRect(&rect)) { | |
666 this->onDrawRect(rect, paint); | |
667 } else { | |
668 this->onDrawPath(path, paint); | |
669 } | |
670 } | |
661 | 671 |
662 /** Draw the specified bitmap, with its top/left corner at (x,y), using the | 672 /** 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 | 673 specified paint, transformed by the current matrix. Note: if the paint |
664 contains a maskfilter that generates a mask which extends beyond the | 674 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 | 675 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 | 676 were in a Shader with CLAMP mode. Thus the color outside of the original |
667 width/height will be the edge color replicated. | 677 width/height will be the edge color replicated. |
668 @param bitmap The bitmap to be drawn | 678 @param bitmap The bitmap to be drawn |
669 @param left The position of the left side of the bitmap being drawn | 679 @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 | 680 @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 | 1037 |
1028 // Called by child classes that override clipPath and clipRRect to only | 1038 // Called by child classes that override clipPath and clipRRect to only |
1029 // track fast conservative clip bounds, rather than exact clips. | 1039 // track fast conservative clip bounds, rather than exact clips. |
1030 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, | 1040 bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, |
1031 bool inverseFilled); | 1041 bool inverseFilled); |
1032 | 1042 |
1033 // notify our surface (if we have one) that we are about to draw, so it | 1043 // 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 | 1044 // can perform copy-on-write or invalidate any cached images |
1035 void predrawNotify(); | 1045 void predrawNotify(); |
1036 | 1046 |
1047 virtual void onDrawRect(const SkRect& rect, const SkPaint& paint); | |
bsalomon
2013/10/15 13:25:51
Since these are protected the subclasses should no
| |
1048 | |
1049 virtual void onDrawPath(const SkPath& path, const SkPaint& paint); | |
1050 | |
1037 /** DEPRECATED -- use constructor(device) | 1051 /** DEPRECATED -- use constructor(device) |
1038 | 1052 |
1039 Marked as 'protected' to avoid new clients using this before we can | 1053 Marked as 'protected' to avoid new clients using this before we can |
1040 completely remove it. | 1054 completely remove it. |
1041 | 1055 |
1042 Specify a device for this canvas to draw into. If it is not null, its | 1056 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 | 1057 reference count is incremented. If the canvas was already holding a |
1044 device, its reference count is decremented. The new device is returned. | 1058 device, its reference count is decremented. The new device is returned. |
1045 */ | 1059 */ |
1046 virtual SkBaseDevice* setDevice(SkBaseDevice* device); | 1060 virtual SkBaseDevice* setDevice(SkBaseDevice* device); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 if (NULL != fCanvas) { | 1203 if (NULL != fCanvas) { |
1190 fCanvas->endCommentGroup(); | 1204 fCanvas->endCommentGroup(); |
1191 } | 1205 } |
1192 } | 1206 } |
1193 | 1207 |
1194 private: | 1208 private: |
1195 SkCanvas* fCanvas; | 1209 SkCanvas* fCanvas; |
1196 }; | 1210 }; |
1197 | 1211 |
1198 #endif | 1212 #endif |
OLD | NEW |