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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 */ | 905 */ |
906 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst, | 906 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst, |
907 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); | 907 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); |
908 // variant where src is SkIRect | 908 // variant where src is SkIRect |
909 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst, | 909 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst, |
910 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); | 910 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); |
911 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint, | 911 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint, |
912 SrcRectConstraint = kStrict_SrcRectConstraint); | 912 SrcRectConstraint = kStrict_SrcRectConstraint); |
913 | 913 |
914 /** | 914 /** |
915 * Draw the bitmap stretched differentially to fit into dst. | 915 * Draw the bitmap stretched or shrunk differentially to fit into dst. |
916 * center is a rect within the bitmap, and logically divides the bitmap | 916 * center is a rect within the bitmap, and logically divides the bitmap |
917 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 917 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
918 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 918 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
919 * | 919 * |
920 * If the dst is >= the bitmap size, then... | 920 * If the dst is >= the bitmap size, then... |
921 * - The 4 corners are not stretched at all. | 921 * - The 4 corners are not stretched at all. |
922 * - The sides are stretched in only one axis. | 922 * - The sides are stretched in only one axis. |
923 * - The center is stretched in both axes. | 923 * - The center is stretched in both axes. |
924 * Else, for each axis where dst < bitmap, | 924 * Else, for each axis where dst < bitmap, |
925 * - The corners shrink proportionally | 925 * - The corners shrink proportionally |
926 * - The sides (along the shrink axis) and center are not drawn | 926 * - The sides (along the shrink axis) and center are not drawn |
927 */ | 927 */ |
928 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR ect& dst, | 928 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR ect& dst, |
929 const SkPaint* paint = NULL); | 929 const SkPaint* paint = NULL); |
930 | 930 |
931 /** | |
932 * Specifies coordinates to divide a bitmap into (xCount*yCount) patches. | |
933 */ | |
934 struct NinePatchDivs { | |
935 // An array of x-coordinates that divide the bitmap vertically. | |
936 // These must be unique, increasing, and in the set [0, width]. | |
937 // Does not have ownership. | |
938 uint32_t* fXDivs; | |
reed1
2016/05/19 18:21:01
I would make all of these int instead of uint32_t,
| |
939 | |
940 // The number of fXDivs. | |
941 uint32_t fXCount; | |
942 | |
943 // An array of y-coordinates that divide the bitmap horiztonally. | |
944 // These must be unique, increasing, and in the set [0, height]. | |
945 // Does not have ownership. | |
946 uint32_t* fYDivs; | |
947 | |
948 // The number of fYDivs. | |
949 uint32_t fYCount; | |
950 }; | |
951 | |
952 /** | |
953 * Draw the bitmap stretched or shrunk differentially to fit into dst. | |
954 * | |
955 * Moving horizontally across the bitmap alternating patches will be "scala ble" | |
956 * (in the x-dimension) to fit into dst or must be left "fixed". The first patch | |
f(malita)
2016/05/19 19:24:20
The last patch is also fixed, right?
msarett
2016/05/19 19:30:58
In the Android implementation, it really depends o
f(malita)
2016/05/19 19:36:11
Ah, that makes sense (I didn't parse the "alternat
| |
957 * is treated as "fixed", but it's possible to specify an empty first patch by | |
958 * making divs.fXDivs[0] = 0. | |
959 * | |
960 * The scale factor for all "scalable" patches will be the same, and may be greater | |
961 * than or less than 1 (meaning we can stretch or shrink). If the number o f | |
962 * "fixed" pixels is greater than the width of the dst, we will collapse al l of | |
963 * the "scalable" regions and appropriately downscale the "fixed" regions. | |
964 * | |
965 * The same interpretation also applies the y-dimension. | |
966 */ | |
967 void drawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& divs, const SkRect& dst, | |
968 const SkPaint* paint = nullptr); | |
969 | |
931 /** Draw the text, with origin at (x,y), using the specified paint. | 970 /** Draw the text, with origin at (x,y), using the specified paint. |
932 The origin is interpreted based on the Align setting in the paint. | 971 The origin is interpreted based on the Align setting in the paint. |
933 @param text The text to be drawn | 972 @param text The text to be drawn |
934 @param byteLength The number of bytes to read from the text parameter | 973 @param byteLength The number of bytes to read from the text parameter |
935 @param x The x-coordinate of the origin of the text being drawn | 974 @param x The x-coordinate of the origin of the text being drawn |
936 @param y The y-coordinate of the origin of the text being drawn | 975 @param y The y-coordinate of the origin of the text being drawn |
937 @param paint The paint used for the text (e.g. color, size, style) | 976 @param paint The paint used for the text (e.g. color, size, style) |
938 */ | 977 */ |
939 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, | 978 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
940 const SkPaint& paint); | 979 const SkPaint& paint); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1579 | 1618 |
1580 class SkCanvasClipVisitor { | 1619 class SkCanvasClipVisitor { |
1581 public: | 1620 public: |
1582 virtual ~SkCanvasClipVisitor(); | 1621 virtual ~SkCanvasClipVisitor(); |
1583 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1622 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1584 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1623 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1585 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1624 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1586 }; | 1625 }; |
1587 | 1626 |
1588 #endif | 1627 #endif |
OLD | NEW |