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