OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
10 | 10 |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 | 765 |
766 /** Draw the specified image, with its top/left corner at (x,y), using the | 766 /** Draw the specified image, with its top/left corner at (x,y), using the |
767 specified paint, transformed by the current matrix. | 767 specified paint, transformed by the current matrix. |
768 | 768 |
769 @param image The image to be drawn | 769 @param image The image to be drawn |
770 @param left The position of the left side of the image being drawn | 770 @param left The position of the left side of the image being drawn |
771 @param top The position of the top side of the image being drawn | 771 @param top The position of the top side of the image being drawn |
772 @param paint The paint used to draw the image, or NULL | 772 @param paint The paint used to draw the image, or NULL |
773 */ | 773 */ |
774 void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPa int* paint = NULL); | 774 void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPa int* paint = NULL); |
775 void drawImage(sk_sp<const SkImage>& image, SkScalar left, SkScalar top, | |
bungeman-skia
2016/03/17 14:46:22
These all need to be const references 'const sk_sp
| |
776 const SkPaint* paint = NULL) { | |
777 this->drawImage(image.get(), left, top, paint); | |
778 } | |
775 | 779 |
776 /** | 780 /** |
777 * Controls the behavior at the edge of the src-rect, when specified in dra wImageRect, | 781 * Controls the behavior at the edge of the src-rect, when specified in dra wImageRect, |
778 * trading off speed for exactness. | 782 * trading off speed for exactness. |
779 * | 783 * |
780 * When filtering is enabled (in the Paint), skia may need to sample in a n eighborhood around | 784 * When filtering is enabled (in the Paint), skia may need to sample in a n eighborhood around |
781 * the pixels in the image. If there is a src-rect specified, it is intende d to restrict the | 785 * the pixels in the image. If there is a src-rect specified, it is intende d to restrict the |
782 * pixels that will be read. However, for performance reasons, some impleme ntations may slow | 786 * pixels that will be read. However, for performance reasons, some impleme ntations may slow |
783 * down if they cannot read 1-pixel past the src-rect boundary at times. | 787 * down if they cannot read 1-pixel past the src-rect boundary at times. |
784 * | 788 * |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& ds t, | 820 void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& ds t, |
817 const SkPaint* paint, | 821 const SkPaint* paint, |
818 SrcRectConstraint constraint = kStrict_SrcRectConstraint) ; | 822 SrcRectConstraint constraint = kStrict_SrcRectConstraint) ; |
819 // variant that takes src SkIRect | 823 // variant that takes src SkIRect |
820 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst, | 824 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst, |
821 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect Constraint); | 825 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect Constraint); |
822 // variant that assumes src == image-bounds | 826 // variant that assumes src == image-bounds |
823 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p aint, | 827 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p aint, |
824 SrcRectConstraint = kStrict_SrcRectConstraint); | 828 SrcRectConstraint = kStrict_SrcRectConstraint); |
825 | 829 |
830 void drawImageRect(sk_sp<const SkImage>& image, const SkRect& src, const SkR ect& dst, | |
831 const SkPaint* paint, | |
832 SrcRectConstraint constraint = kStrict_SrcRectConstraint) { | |
833 this->drawImageRect(image.get(), src, dst, paint, constraint); | |
834 } | |
835 void drawImageRect(sk_sp<const SkImage>& image, const SkIRect& isrc, const S kRect& dst, | |
836 const SkPaint* paint, SrcRectConstraint cons = kStrict_Sr cRectConstraint) { | |
837 this->drawImageRect(image.get(), isrc, dst, paint, cons); | |
838 } | |
839 void drawImageRect(sk_sp<const SkImage>& image, const SkRect& dst, const SkP aint* paint, | |
840 SrcRectConstraint cons = kStrict_SrcRectConstraint) { | |
841 this->drawImageRect(image.get(), dst, paint, cons); | |
842 } | |
843 | |
826 /** | 844 /** |
827 * Draw the image stretched differentially to fit into dst. | 845 * Draw the image stretched differentially to fit into dst. |
828 * center is a rect within the image, and logically divides the image | 846 * center is a rect within the image, and logically divides the image |
829 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 847 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
830 * image is the "center", then the center-rect should be [2, 2, 3, 3]. | 848 * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
831 * | 849 * |
832 * If the dst is >= the image size, then... | 850 * If the dst is >= the image size, then... |
833 * - The 4 corners are not stretched at all. | 851 * - The 4 corners are not stretched at all. |
834 * - The sides are stretched in only one axis. | 852 * - The sides are stretched in only one axis. |
835 * - The center is stretched in both axes. | 853 * - The center is stretched in both axes. |
836 * Else, for each axis where dst < image, | 854 * Else, for each axis where dst < image, |
837 * - The corners shrink proportionally | 855 * - The corners shrink proportionally |
838 * - The sides (along the shrink axis) and center are not drawn | 856 * - The sides (along the shrink axis) and center are not drawn |
839 */ | 857 */ |
840 void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, | 858 void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, |
841 const SkPaint* paint = NULL); | 859 const SkPaint* paint = nullptr); |
860 void drawImageNine(sk_sp<const SkImage>& image, const SkIRect& center, const SkRect& dst, | |
861 const SkPaint* paint = nullptr) { | |
862 this->drawImageNine(image.get(), center, dst, paint); | |
863 } | |
842 | 864 |
843 /** Draw the specified bitmap, with its top/left corner at (x,y), using the | 865 /** Draw the specified bitmap, with its top/left corner at (x,y), using the |
844 specified paint, transformed by the current matrix. Note: if the paint | 866 specified paint, transformed by the current matrix. Note: if the paint |
845 contains a maskfilter that generates a mask which extends beyond the | 867 contains a maskfilter that generates a mask which extends beyond the |
846 bitmap's original width/height, then the bitmap will be drawn as if it | 868 bitmap's original width/height, then the bitmap will be drawn as if it |
847 were in a Shader with CLAMP mode. Thus the color outside of the original | 869 were in a Shader with CLAMP mode. Thus the color outside of the original |
848 width/height will be the edge color replicated. | 870 width/height will be the edge color replicated. |
849 | 871 |
850 If a shader is present on the paint it will be ignored, except in the | 872 If a shader is present on the paint it will be ignored, except in the |
851 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i s | 873 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i s |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
966 | 988 |
967 /** Draw the picture into this canvas. This method effective brackets the | 989 /** Draw the picture into this canvas. This method effective brackets the |
968 playback of the picture's draw calls with save/restore, so the state | 990 playback of the picture's draw calls with save/restore, so the state |
969 of this canvas will be unchanged after this call. | 991 of this canvas will be unchanged after this call. |
970 @param picture The recorded drawing commands to playback into this | 992 @param picture The recorded drawing commands to playback into this |
971 canvas. | 993 canvas. |
972 */ | 994 */ |
973 void drawPicture(const SkPicture* picture) { | 995 void drawPicture(const SkPicture* picture) { |
974 this->drawPicture(picture, NULL, NULL); | 996 this->drawPicture(picture, NULL, NULL); |
975 } | 997 } |
998 void drawPicture(sk_sp<SkPicture>& picture) { | |
999 this->drawPicture(picture.get()); | |
1000 } | |
976 | 1001 |
977 /** | 1002 /** |
978 * Draw the picture into this canvas. | 1003 * Draw the picture into this canvas. |
979 * | 1004 * |
980 * If matrix is non-null, apply that matrix to the CTM when drawing this pi cture. This is | 1005 * If matrix is non-null, apply that matrix to the CTM when drawing this pi cture. This is |
981 * logically equivalent to | 1006 * logically equivalent to |
982 * save/concat/drawPicture/restore | 1007 * save/concat/drawPicture/restore |
983 * | 1008 * |
984 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's | 1009 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's |
985 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. | 1010 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. |
986 * This is logically equivalent to | 1011 * This is logically equivalent to |
987 * saveLayer(paint)/drawPicture/restore | 1012 * saveLayer(paint)/drawPicture/restore |
988 */ | 1013 */ |
989 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); | 1014 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); |
1015 void drawPicture(sk_sp<SkPicture>& picture, const SkMatrix* matrix, const Sk Paint* paint) { | |
1016 this->drawPicture(picture.get(), matrix, paint); | |
1017 } | |
990 | 1018 |
991 enum VertexMode { | 1019 enum VertexMode { |
992 kTriangles_VertexMode, | 1020 kTriangles_VertexMode, |
993 kTriangleStrip_VertexMode, | 1021 kTriangleStrip_VertexMode, |
994 kTriangleFan_VertexMode | 1022 kTriangleFan_VertexMode |
995 }; | 1023 }; |
996 | 1024 |
997 /** Draw the array of vertices, interpreted as triangles (based on mode). | 1025 /** Draw the array of vertices, interpreted as triangles (based on mode). |
998 | 1026 |
999 If both textures and vertex-colors are NULL, it strokes hairlines with | 1027 If both textures and vertex-colors are NULL, it strokes hairlines with |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1058 */ | 1086 */ |
1059 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], | 1087 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], |
1060 const SkColor colors[], int count, SkXfermode::Mode, const Sk Rect* cullRect, | 1088 const SkColor colors[], int count, SkXfermode::Mode, const Sk Rect* cullRect, |
1061 const SkPaint* paint); | 1089 const SkPaint* paint); |
1062 | 1090 |
1063 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], int count, | 1091 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], int count, |
1064 const SkRect* cullRect, const SkPaint* paint) { | 1092 const SkRect* cullRect, const SkPaint* paint) { |
1065 this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, c ullRect, paint); | 1093 this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, c ullRect, paint); |
1066 } | 1094 } |
1067 | 1095 |
1096 void drawAtlas(sk_sp<const SkImage>& atlas, const SkRSXform xform[], const S kRect tex[], | |
1097 const SkColor colors[], int count, SkXfermode::Mode mode, con st SkRect* cull, | |
1098 const SkPaint* paint) { | |
1099 this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cull, pain t); | |
1100 } | |
1101 void drawAtlas(sk_sp<const SkImage>& atlas, const SkRSXform xform[], const S kRect tex[], | |
1102 int count, const SkRect* cullRect, const SkPaint* paint) { | |
1103 this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkXfermode::kDs t_Mode, | |
1104 cullRect, paint); | |
1105 } | |
1106 | |
1068 /** | 1107 /** |
1069 * Draw the contents of this drawable into the canvas. If the canvas is asy nc | 1108 * Draw the contents of this drawable into the canvas. If the canvas is asy nc |
1070 * (e.g. it is recording into a picture) then the drawable will be referenc ed instead, | 1109 * (e.g. it is recording into a picture) then the drawable will be referenc ed instead, |
1071 * to have its draw() method called when the picture is finalized. | 1110 * to have its draw() method called when the picture is finalized. |
1072 * | 1111 * |
1073 * If the intent is to force the contents of the drawable into this canvas immediately, | 1112 * If the intent is to force the contents of the drawable into this canvas immediately, |
1074 * then drawable->draw(canvas) may be called. | 1113 * then drawable->draw(canvas) may be called. |
1075 */ | 1114 */ |
1076 void drawDrawable(SkDrawable* drawable, const SkMatrix* = NULL); | 1115 void drawDrawable(SkDrawable* drawable, const SkMatrix* = NULL); |
1077 void drawDrawable(SkDrawable*, SkScalar x, SkScalar y); | 1116 void drawDrawable(SkDrawable*, SkScalar x, SkScalar y); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 | 1551 |
1513 class SkCanvasClipVisitor { | 1552 class SkCanvasClipVisitor { |
1514 public: | 1553 public: |
1515 virtual ~SkCanvasClipVisitor(); | 1554 virtual ~SkCanvasClipVisitor(); |
1516 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1555 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1517 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1556 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1518 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1557 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1519 }; | 1558 }; |
1520 | 1559 |
1521 #endif | 1560 #endif |
OLD | NEW |