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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 */ | 931 */ |
932 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect&
dst, | 932 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect&
dst, |
933 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | 933 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); |
934 // variant where src is SkIRect | 934 // variant where src is SkIRect |
935 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec
t& dst, | 935 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec
t& dst, |
936 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); | 936 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec
tConstraint); |
937 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint, | 937 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint
* paint, |
938 SrcRectConstraint = kStrict_SrcRectConstraint); | 938 SrcRectConstraint = kStrict_SrcRectConstraint); |
939 | 939 |
940 /** | 940 /** |
941 * Draw the bitmap stretched differentially to fit into dst. | 941 * Draw the bitmap stretched or shrunk differentially to fit into dst. |
942 * center is a rect within the bitmap, and logically divides the bitmap | 942 * center is a rect within the bitmap, and logically divides the bitmap |
943 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 943 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
944 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 944 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
945 * | 945 * |
946 * If the dst is >= the bitmap size, then... | 946 * If the dst is >= the bitmap size, then... |
947 * - The 4 corners are not stretched at all. | 947 * - The 4 corners are not stretched at all. |
948 * - The sides are stretched in only one axis. | 948 * - The sides are stretched in only one axis. |
949 * - The center is stretched in both axes. | 949 * - The center is stretched in both axes. |
950 * Else, for each axis where dst < bitmap, | 950 * Else, for each axis where dst < bitmap, |
951 * - The corners shrink proportionally | 951 * - The corners shrink proportionally |
952 * - The sides (along the shrink axis) and center are not drawn | 952 * - The sides (along the shrink axis) and center are not drawn |
953 */ | 953 */ |
954 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR
ect& dst, | 954 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR
ect& dst, |
955 const SkPaint* paint = NULL); | 955 const SkPaint* paint = NULL); |
956 | 956 |
| 957 /** |
| 958 * Specifies coordinates to divide a bitmap into (xCount*yCount) rects. |
| 959 */ |
| 960 struct Lattice { |
| 961 // An array of x-coordinates that divide the bitmap vertically. |
| 962 // These must be unique, increasing, and in the set [0, width]. |
| 963 // Does not have ownership. |
| 964 const int* fXDivs; |
| 965 |
| 966 // The number of fXDivs. |
| 967 int fXCount; |
| 968 |
| 969 // An array of y-coordinates that divide the bitmap horizontally. |
| 970 // These must be unique, increasing, and in the set [0, height]. |
| 971 // Does not have ownership. |
| 972 const int* fYDivs; |
| 973 |
| 974 // The number of fYDivs. |
| 975 int fYCount; |
| 976 }; |
| 977 |
| 978 /** |
| 979 * Draw the bitmap stretched or shrunk differentially to fit into dst. |
| 980 * |
| 981 * Moving horizontally across the bitmap, alternating rects will be "scalab
le" |
| 982 * (in the x-dimension) to fit into dst or must be left "fixed". The first
rect |
| 983 * is treated as "fixed", but it's possible to specify an empty first rect
by |
| 984 * making lattice.fXDivs[0] = 0. |
| 985 * |
| 986 * The scale factor for all "scalable" rects will be the same, and may be g
reater |
| 987 * than or less than 1 (meaning we can stretch or shrink). If the number o
f |
| 988 * "fixed" pixels is greater than the width of the dst, we will collapse al
l of |
| 989 * the "scalable" regions and appropriately downscale the "fixed" regions. |
| 990 * |
| 991 * The same interpretation also applies to the y-dimension. |
| 992 */ |
| 993 void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const
SkRect& dst, |
| 994 const SkPaint* paint = nullptr); |
| 995 void drawImageLattice(const SkImage* image, const Lattice& lattice, const Sk
Rect& dst, |
| 996 const SkPaint* paint = nullptr); |
| 997 |
957 /** Draw the text, with origin at (x,y), using the specified paint. | 998 /** Draw the text, with origin at (x,y), using the specified paint. |
958 The origin is interpreted based on the Align setting in the paint. | 999 The origin is interpreted based on the Align setting in the paint. |
959 @param text The text to be drawn | 1000 @param text The text to be drawn |
960 @param byteLength The number of bytes to read from the text parameter | 1001 @param byteLength The number of bytes to read from the text parameter |
961 @param x The x-coordinate of the origin of the text being drawn | 1002 @param x The x-coordinate of the origin of the text being drawn |
962 @param y The y-coordinate of the origin of the text being drawn | 1003 @param y The y-coordinate of the origin of the text being drawn |
963 @param paint The paint used for the text (e.g. color, size, style) | 1004 @param paint The paint used for the text (e.g. color, size, style) |
964 */ | 1005 */ |
965 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, | 1006 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
966 const SkPaint& paint); | 1007 const SkPaint& paint); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c
onst SkPaint*, | 1469 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c
onst SkPaint*, |
1429 SrcRectConstraint); | 1470 SrcRectConstraint); |
1430 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk
Rect& dst, | 1471 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk
Rect& dst, |
1431 const SkPaint*); | 1472 const SkPaint*); |
1432 | 1473 |
1433 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S
kPaint*); | 1474 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S
kPaint*); |
1434 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&,
const SkPaint*, | 1475 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&,
const SkPaint*, |
1435 SrcRectConstraint); | 1476 SrcRectConstraint); |
1436 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const
SkRect& dst, | 1477 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const
SkRect& dst, |
1437 const SkPaint*); | 1478 const SkPaint*); |
| 1479 virtual void onDrawImageLattice(const SkImage*, const Lattice& lattice, cons
t SkRect& dst, |
| 1480 const SkPaint*); |
1438 | 1481 |
1439 enum ClipEdgeStyle { | 1482 enum ClipEdgeStyle { |
1440 kHard_ClipEdgeStyle, | 1483 kHard_ClipEdgeStyle, |
1441 kSoft_ClipEdgeStyle | 1484 kSoft_ClipEdgeStyle |
1442 }; | 1485 }; |
1443 | 1486 |
1444 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); | 1487 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); |
1445 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle); | 1488 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle); |
1446 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); | 1489 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); |
1447 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); | 1490 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 | 1717 |
1675 class SkCanvasClipVisitor { | 1718 class SkCanvasClipVisitor { |
1676 public: | 1719 public: |
1677 virtual ~SkCanvasClipVisitor(); | 1720 virtual ~SkCanvasClipVisitor(); |
1678 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1721 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1679 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1722 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1680 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1723 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1681 }; | 1724 }; |
1682 | 1725 |
1683 #endif | 1726 #endif |
OLD | NEW |