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 17 matching lines...) Expand all Loading... |
28 class SkMetaData; | 28 class SkMetaData; |
29 class SkPicture; | 29 class SkPicture; |
30 class SkRRect; | 30 class SkRRect; |
31 struct SkRSXform; | 31 struct SkRSXform; |
32 class SkSurface; | 32 class SkSurface; |
33 class SkSurface_Base; | 33 class SkSurface_Base; |
34 class SkTextBlob; | 34 class SkTextBlob; |
35 class GrContext; | 35 class GrContext; |
36 class GrRenderTarget; | 36 class GrRenderTarget; |
37 | 37 |
38 //#define SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE | 38 //#define SK_SUPPORT_LEGACY_ONDRAWIMAGERECT |
39 | 39 |
40 class SkCanvasState; | 40 class SkCanvasState; |
41 | 41 |
42 #ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT | 42 #ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT |
43 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::DrawBitmapRectFlags | 43 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::DrawBitmapRectFlags |
44 #define SRC_RECT_CONSTRAINT_PARAM(param) | 44 #define SRC_RECT_CONSTRAINT_PARAM(param) |
45 #define SRC_RECT_CONSTRAINT_ARG(arg) | 45 #define SRC_RECT_CONSTRAINT_ARG(arg) |
46 #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var) SkCanvas::SrcRectConstraint
var = SkCanvas::kStrict_SrcRectConstraint; | 46 #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var) SkCanvas::SrcRectConstraint
var = SkCanvas::kStrict_SrcRectConstraint; |
47 #else | 47 #else |
48 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::SrcRectConstraint | 48 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::SrcRectConstraint |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 * and drawn. | 827 * and drawn. |
828 * | 828 * |
829 * @param image The image to be drawn | 829 * @param image The image to be drawn |
830 * @param src Optional: specify the subset of the image to be drawn | 830 * @param src Optional: specify the subset of the image to be drawn |
831 * @param dst The destination rectangle where the scaled/translated | 831 * @param dst The destination rectangle where the scaled/translated |
832 * image will be drawn | 832 * image will be drawn |
833 * @param paint The paint used to draw the image, or NULL | 833 * @param paint The paint used to draw the image, or NULL |
834 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. | 834 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. |
835 */ | 835 */ |
836 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, | 836 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, |
837 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); | 837 const SkPaint* paint, SrcRectConstraint); |
838 | 838 |
839 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t) { | 839 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, |
840 this->drawImageRect(image, src, dst, NULL, kStrict_SrcRectConstraint); | 840 const SkPaint* paint = NULL) { |
| 841 this->drawImageRect(image, src, dst, paint, kStrict_SrcRectConstraint); |
841 } | 842 } |
842 | 843 |
843 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p
aint = NULL) { | 844 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p
aint = NULL) { |
844 // With no src-rect, the constraint value is ignored, so we just use the
default. | 845 // With no src-rect, the constraint value is ignored, so we just use the
default. |
845 this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint); | 846 this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint); |
846 } | 847 } |
847 | 848 |
848 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect&
dst, | |
849 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); | |
850 | |
851 /** | 849 /** |
852 * Draw the image stretched differentially to fit into dst. | 850 * Draw the image stretched differentially to fit into dst. |
853 * center is a rect within the image, and logically divides the image | 851 * center is a rect within the image, and logically divides the image |
854 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 852 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
855 * image is the "center", then the center-rect should be [2, 2, 3, 3]. | 853 * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
856 * | 854 * |
857 * If the dst is >= the image size, then... | 855 * If the dst is >= the image size, then... |
858 * - The 4 corners are not stretched at all. | 856 * - The 4 corners are not stretched at all. |
859 * - The sides are stretched in only one axis. | 857 * - The sides are stretched in only one axis. |
860 * - The center is stretched in both axes. | 858 * - The center is stretched in both axes. |
(...skipping 27 matching lines...) Expand all Loading... |
888 * dst rect. If the src rect is non-null, only that subset of the bitmap is
transformed | 886 * dst rect. If the src rect is non-null, only that subset of the bitmap is
transformed |
889 * and drawn. | 887 * and drawn. |
890 * | 888 * |
891 * @param bitmap The bitmap to be drawn | 889 * @param bitmap The bitmap to be drawn |
892 * @param src Optional: specify the subset of the bitmap to be drawn | 890 * @param src Optional: specify the subset of the bitmap to be drawn |
893 * @param dst The destination rectangle where the scaled/translated | 891 * @param dst The destination rectangle where the scaled/translated |
894 * bitmap will be drawn | 892 * bitmap will be drawn |
895 * @param paint The paint used to draw the bitmap, or NULL | 893 * @param paint The paint used to draw the bitmap, or NULL |
896 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. | 894 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. |
897 */ | 895 */ |
898 #ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE | |
899 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect&
dst, | 896 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect&
dst, |
900 const SkPaint* paint, SrcRectConstraint); | 897 const SkPaint* paint, SrcRectConstraint); |
901 #else | |
902 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect&
dst, | |
903 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | |
904 #endif | |
905 | 898 |
906 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint = NULL) { | 899 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint = NULL) { |
907 this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint
); | 900 this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint
); |
908 } | 901 } |
909 | 902 |
910 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec
t& dst, | |
911 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | |
912 | |
913 #ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE | |
914 // IMPORTANT that thse be value-equal with SrcRectConstraint (during transit
ion period) | 903 // IMPORTANT that thse be value-equal with SrcRectConstraint (during transit
ion period) |
915 enum DrawBitmapRectFlags { | 904 enum DrawBitmapRectFlags { |
916 kNone_DrawBitmapRectFlag = 0x0, | 905 kNone_DrawBitmapRectFlag = 0x0, |
917 /** | 906 /** |
918 * When filtering is enabled, allow the color samples outside of | 907 * When filtering is enabled, allow the color samples outside of |
919 * the src rect (but still in the src bitmap) to bleed into the | 908 * the src rect (but still in the src bitmap) to bleed into the |
920 * drawn portion | 909 * drawn portion |
921 */ | 910 */ |
922 kBleed_DrawBitmapRectFlag = 0x1, | 911 kBleed_DrawBitmapRectFlag = 0x1, |
923 }; | 912 }; |
(...skipping 14 matching lines...) Expand all Loading... |
938 const SkRect& dst, const SkPaint* paint = NULL, | 927 const SkRect& dst, const SkPaint* paint = NULL, |
939 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) { | 928 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) { |
940 SkRect realSrcStorage; | 929 SkRect realSrcStorage; |
941 SkRect* realSrcPtr = NULL; | 930 SkRect* realSrcPtr = NULL; |
942 if (isrc) { | 931 if (isrc) { |
943 realSrcStorage.set(*isrc); | 932 realSrcStorage.set(*isrc); |
944 realSrcPtr = &realSrcStorage; | 933 realSrcPtr = &realSrcStorage; |
945 } | 934 } |
946 this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags); | 935 this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags); |
947 } | 936 } |
948 #endif | |
949 | 937 |
950 /** | 938 /** |
951 * Draw the bitmap stretched differentially to fit into dst. | 939 * Draw the bitmap stretched differentially to fit into dst. |
952 * center is a rect within the bitmap, and logically divides the bitmap | 940 * center is a rect within the bitmap, and logically divides the bitmap |
953 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 941 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
954 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 942 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
955 * | 943 * |
956 * If the dst is >= the bitmap size, then... | 944 * If the dst is >= the bitmap size, then... |
957 * - The 4 corners are not stretched at all. | 945 * - The 4 corners are not stretched at all. |
958 * - The sides are stretched in only one axis. | 946 * - The sides are stretched in only one axis. |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 | 1585 |
1598 class SkCanvasClipVisitor { | 1586 class SkCanvasClipVisitor { |
1599 public: | 1587 public: |
1600 virtual ~SkCanvasClipVisitor(); | 1588 virtual ~SkCanvasClipVisitor(); |
1601 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1589 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1602 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1590 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1603 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1591 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1604 }; | 1592 }; |
1605 | 1593 |
1606 #endif | 1594 #endif |
OLD | NEW |