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