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 19 matching lines...) Expand all Loading... |
30 class SkMetaData; | 30 class SkMetaData; |
31 class SkPath; | 31 class SkPath; |
32 class SkPicture; | 32 class SkPicture; |
33 class SkPixmap; | 33 class SkPixmap; |
34 class SkRRect; | 34 class SkRRect; |
35 struct SkRSXform; | 35 struct SkRSXform; |
36 class SkSurface; | 36 class SkSurface; |
37 class SkSurface_Base; | 37 class SkSurface_Base; |
38 class SkTextBlob; | 38 class SkTextBlob; |
39 | 39 |
| 40 //#define SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT |
| 41 //#define SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT |
| 42 |
40 /** \class SkCanvas | 43 /** \class SkCanvas |
41 | 44 |
42 A Canvas encapsulates all of the state about drawing into a device (bitmap). | 45 A Canvas encapsulates all of the state about drawing into a device (bitmap). |
43 This includes a reference to the device itself, and a stack of matrix/clip | 46 This includes a reference to the device itself, and a stack of matrix/clip |
44 values. For any given draw call (e.g. drawRect), the geometry of the object | 47 values. For any given draw call (e.g. drawRect), the geometry of the object |
45 being drawn is transformed by the concatenation of all the matrices in the | 48 being drawn is transformed by the concatenation of all the matrices in the |
46 stack. The transformed geometry is clipped by the intersection of all of | 49 stack. The transformed geometry is clipped by the intersection of all of |
47 the clips in the stack. | 50 the clips in the stack. |
48 | 51 |
49 While the Canvas holds the state of the drawing device, the state (style) | 52 While the Canvas holds the state of the drawing device, the state (style) |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 * dst rect. If the src rect is non-null, only that subset of the image is
transformed | 815 * dst rect. If the src rect is non-null, only that subset of the image is
transformed |
813 * and drawn. | 816 * and drawn. |
814 * | 817 * |
815 * @param image The image to be drawn | 818 * @param image The image to be drawn |
816 * @param src Optional: specify the subset of the image to be drawn | 819 * @param src Optional: specify the subset of the image to be drawn |
817 * @param dst The destination rectangle where the scaled/translated | 820 * @param dst The destination rectangle where the scaled/translated |
818 * image will be drawn | 821 * image will be drawn |
819 * @param paint The paint used to draw the image, or NULL | 822 * @param paint The paint used to draw the image, or NULL |
820 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. | 823 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. |
821 */ | 824 */ |
| 825 void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& ds
t, |
| 826 const SkPaint* paint, |
| 827 SrcRectConstraint constraint = kStrict_SrcRectConstraint)
; |
| 828 // variant that takes src SkIRect |
| 829 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect&
dst, |
| 830 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); |
| 831 // variant that assumes src == image-bounds |
| 832 #ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT |
| 833 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p
aint = NULL); |
| 834 #else |
| 835 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p
aint, |
| 836 SrcRectConstraint = kStrict_SrcRectConstraint); |
| 837 #endif |
| 838 |
| 839 #ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT |
822 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, | 840 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t, |
823 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); | 841 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); |
824 | 842 |
825 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t) { | 843 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& ds
t) { |
826 this->drawImageRect(image, src, dst, NULL, kStrict_SrcRectConstraint); | 844 this->drawImageRect(image, src, dst, NULL, kStrict_SrcRectConstraint); |
827 } | 845 } |
828 | 846 #endif |
829 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p
aint = NULL) { | |
830 // With no src-rect, the constraint value is ignored, so we just use the
default. | |
831 this->drawImageRect(image, NULL, dst, paint, kStrict_SrcRectConstraint); | |
832 } | |
833 | |
834 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect&
dst, | |
835 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect
Constraint); | |
836 | 847 |
837 /** | 848 /** |
838 * Draw the image stretched differentially to fit into dst. | 849 * Draw the image stretched differentially to fit into dst. |
839 * center is a rect within the image, and logically divides the image | 850 * center is a rect within the image, and logically divides the image |
840 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 851 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
841 * image is the "center", then the center-rect should be [2, 2, 3, 3]. | 852 * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
842 * | 853 * |
843 * If the dst is >= the image size, then... | 854 * If the dst is >= the image size, then... |
844 * - The 4 corners are not stretched at all. | 855 * - The 4 corners are not stretched at all. |
845 * - The sides are stretched in only one axis. | 856 * - The sides are stretched in only one axis. |
(...skipping 28 matching lines...) Expand all Loading... |
874 * dst rect. If the src rect is non-null, only that subset of the bitmap is
transformed | 885 * dst rect. If the src rect is non-null, only that subset of the bitmap is
transformed |
875 * and drawn. | 886 * and drawn. |
876 * | 887 * |
877 * @param bitmap The bitmap to be drawn | 888 * @param bitmap The bitmap to be drawn |
878 * @param src Optional: specify the subset of the bitmap to be drawn | 889 * @param src Optional: specify the subset of the bitmap to be drawn |
879 * @param dst The destination rectangle where the scaled/translated | 890 * @param dst The destination rectangle where the scaled/translated |
880 * bitmap will be drawn | 891 * bitmap will be drawn |
881 * @param paint The paint used to draw the bitmap, or NULL | 892 * @param paint The paint used to draw the bitmap, or NULL |
882 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. | 893 * @param constraint Control the tradeoff between speed and exactness w.r.t
. the src-rect. |
883 */ | 894 */ |
| 895 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect&
dst, |
| 896 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); |
| 897 // variant where src is SkIRect |
| 898 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec
t& dst, |
| 899 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); |
| 900 #ifdef SK_SUPPORT_LEGACY_SIMPLE_DRAWIMAGERECT |
| 901 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint = NULL); |
| 902 #else |
| 903 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint, |
| 904 SrcRectConstraint = kStrict_SrcRectConstraint); |
| 905 #endif |
| 906 |
| 907 #ifdef SK_SUPPORT_LEGACY_SRCPTR_DRAWIMAGERECT |
884 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect&
dst, | 908 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect&
dst, |
885 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | 909 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); |
886 | 910 #endif |
887 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint = NULL) { | |
888 this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint
); | |
889 } | |
890 | |
891 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec
t& dst, | |
892 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | |
893 | 911 |
894 /** | 912 /** |
895 * Draw the bitmap stretched differentially to fit into dst. | 913 * Draw the bitmap stretched differentially to fit into dst. |
896 * center is a rect within the bitmap, and logically divides the bitmap | 914 * center is a rect within the bitmap, and logically divides the bitmap |
897 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 915 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
898 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 916 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
899 * | 917 * |
900 * If the dst is >= the bitmap size, then... | 918 * If the dst is >= the bitmap size, then... |
901 * - The 4 corners are not stretched at all. | 919 * - The 4 corners are not stretched at all. |
902 * - The sides are stretched in only one axis. | 920 * - The sides are stretched in only one axis. |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1220 |
1203 // don't call | 1221 // don't call |
1204 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); | 1222 GrRenderTarget* internal_private_accessTopLayerRenderTarget(); |
1205 | 1223 |
1206 // don't call | 1224 // don't call |
1207 static void Internal_Private_SetIgnoreSaveLayerBounds(bool); | 1225 static void Internal_Private_SetIgnoreSaveLayerBounds(bool); |
1208 static bool Internal_Private_GetIgnoreSaveLayerBounds(); | 1226 static bool Internal_Private_GetIgnoreSaveLayerBounds(); |
1209 static void Internal_Private_SetTreatSpriteAsBitmap(bool); | 1227 static void Internal_Private_SetTreatSpriteAsBitmap(bool); |
1210 static bool Internal_Private_GetTreatSpriteAsBitmap(); | 1228 static bool Internal_Private_GetTreatSpriteAsBitmap(); |
1211 | 1229 |
| 1230 // TEMP helpers until we switch virtual over to const& for src-rect |
| 1231 void legacy_drawImageRect(const SkImage* image, const SkRect* src, const SkR
ect& dst, |
| 1232 const SkPaint* paint, |
| 1233 SrcRectConstraint constraint = kStrict_SrcRectCons
traint); |
| 1234 void legacy_drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const
SkRect& dst, |
| 1235 const SkPaint* paint, |
| 1236 SrcRectConstraint constraint = kStrict_SrcRectCon
straint); |
| 1237 |
1212 protected: | 1238 protected: |
1213 // default impl defers to getDevice()->newSurface(info) | 1239 // default impl defers to getDevice()->newSurface(info) |
1214 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&); | 1240 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&); |
1215 | 1241 |
1216 // default impl defers to its device | 1242 // default impl defers to its device |
1217 virtual bool onPeekPixels(SkPixmap*); | 1243 virtual bool onPeekPixels(SkPixmap*); |
1218 virtual bool onAccessTopLayerPixels(SkPixmap*); | 1244 virtual bool onAccessTopLayerPixels(SkPixmap*); |
1219 | 1245 |
1220 // Subclass save/restore notifiers. | 1246 // Subclass save/restore notifiers. |
1221 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. | 1247 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 | 1587 |
1562 class SkCanvasClipVisitor { | 1588 class SkCanvasClipVisitor { |
1563 public: | 1589 public: |
1564 virtual ~SkCanvasClipVisitor(); | 1590 virtual ~SkCanvasClipVisitor(); |
1565 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1591 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1566 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1592 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1567 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1593 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1568 }; | 1594 }; |
1569 | 1595 |
1570 #endif | 1596 #endif |
OLD | NEW |