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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 */ | 912 */ |
913 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst, | 913 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst, |
914 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); | 914 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); |
915 // variant where src is SkIRect | 915 // variant where src is SkIRect |
916 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst, | 916 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst, |
917 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); | 917 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); |
918 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint, | 918 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint, |
919 SrcRectConstraint = kStrict_SrcRectConstraint); | 919 SrcRectConstraint = kStrict_SrcRectConstraint); |
920 | 920 |
921 /** | 921 /** |
922 * Draw the bitmap stretched differentially to fit into dst. | 922 * Draw the bitmap stretched or shrunk differentially to fit into dst. |
923 * center is a rect within the bitmap, and logically divides the bitmap | 923 * center is a rect within the bitmap, and logically divides the bitmap |
924 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 924 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
925 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 925 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
926 * | 926 * |
927 * If the dst is >= the bitmap size, then... | 927 * If the dst is >= the bitmap size, then... |
928 * - The 4 corners are not stretched at all. | 928 * - The 4 corners are not stretched at all. |
929 * - The sides are stretched in only one axis. | 929 * - The sides are stretched in only one axis. |
930 * - The center is stretched in both axes. | 930 * - The center is stretched in both axes. |
931 * Else, for each axis where dst < bitmap, | 931 * Else, for each axis where dst < bitmap, |
932 * - The corners shrink proportionally | 932 * - The corners shrink proportionally |
933 * - The sides (along the shrink axis) and center are not drawn | 933 * - The sides (along the shrink axis) and center are not drawn |
934 */ | 934 */ |
935 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR ect& dst, | 935 void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkR ect& dst, |
936 const SkPaint* paint = NULL); | 936 const SkPaint* paint = NULL); |
937 | 937 |
938 /** | |
939 * Specifies coordinates to divide a bitmap into (xCount*yCount) patches. | |
940 */ | |
941 struct NinePatchDivs { | |
reed1
2016/08/01 16:26:02
drawBitmapLattice
msarett
2016/08/01 23:25:09
Done.
| |
942 // An array of x-coordinates that divide the bitmap vertically. | |
943 // These must be unique, increasing, and in the set [0, width]. | |
944 // Does not have ownership. | |
945 int* fXDivs; | |
reed1
2016/08/01 16:26:02
const
msarett
2016/08/01 23:25:09
Done.
| |
946 | |
947 // The number of fXDivs. | |
948 int fXCount; | |
949 | |
950 // An array of y-coordinates that divide the bitmap horiztonally. | |
951 // These must be unique, increasing, and in the set [0, height]. | |
952 // Does not have ownership. | |
953 int* fYDivs; | |
954 | |
955 // The number of fYDivs. | |
956 int fYCount; | |
957 }; | |
958 | |
959 /** | |
960 * Draw the bitmap stretched or shrunk differentially to fit into dst. | |
961 * | |
962 * Moving horizontally across the bitmap, alternating patches will be "scal able" | |
963 * (in the x-dimension) to fit into dst or must be left "fixed". The first patch | |
964 * is treated as "fixed", but it's possible to specify an empty first patch by | |
965 * making divs.fXDivs[0] = 0. | |
966 * | |
967 * The scale factor for all "scalable" patches will be the same, and may be greater | |
968 * than or less than 1 (meaning we can stretch or shrink). If the number o f | |
969 * "fixed" pixels is greater than the width of the dst, we will collapse al l of | |
970 * the "scalable" regions and appropriately downscale the "fixed" regions. | |
971 * | |
972 * The same interpretation also applies to the y-dimension. | |
973 */ | |
974 void drawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& divs, const SkRect& dst, | |
reed1
2016/07/15 16:27:04
"Nine" is sort of a misnomer here
msarett
2016/08/01 23:25:09
Acknowledged.
| |
975 const SkPaint* paint = nullptr); | |
976 | |
938 /** Draw the text, with origin at (x,y), using the specified paint. | 977 /** Draw the text, with origin at (x,y), using the specified paint. |
939 The origin is interpreted based on the Align setting in the paint. | 978 The origin is interpreted based on the Align setting in the paint. |
940 @param text The text to be drawn | 979 @param text The text to be drawn |
941 @param byteLength The number of bytes to read from the text parameter | 980 @param byteLength The number of bytes to read from the text parameter |
942 @param x The x-coordinate of the origin of the text being drawn | 981 @param x The x-coordinate of the origin of the text being drawn |
943 @param y The y-coordinate of the origin of the text being drawn | 982 @param y The y-coordinate of the origin of the text being drawn |
944 @param paint The paint used for the text (e.g. color, size, style) | 983 @param paint The paint used for the text (e.g. color, size, style) |
945 */ | 984 */ |
946 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, | 985 void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
947 const SkPaint& paint); | 986 const SkPaint& paint); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1369 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c onst SkPaint*, | 1408 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c onst SkPaint*, |
1370 SrcRectConstraint); | 1409 SrcRectConstraint); |
1371 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk Rect& dst, | 1410 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk Rect& dst, |
1372 const SkPaint*); | 1411 const SkPaint*); |
1373 | 1412 |
1374 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S kPaint*); | 1413 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S kPaint*); |
1375 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, | 1414 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, |
1376 SrcRectConstraint); | 1415 SrcRectConstraint); |
1377 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, | 1416 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
1378 const SkPaint*); | 1417 const SkPaint*); |
1418 virtual void onDrawBitmapNine(const SkBitmap&, const NinePatchDivs& divs, co nst SkRect& dst, | |
1419 const SkPaint*); | |
1379 | 1420 |
1380 enum ClipEdgeStyle { | 1421 enum ClipEdgeStyle { |
1381 kHard_ClipEdgeStyle, | 1422 kHard_ClipEdgeStyle, |
1382 kSoft_ClipEdgeStyle | 1423 kSoft_ClipEdgeStyle |
1383 }; | 1424 }; |
1384 | 1425 |
1385 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); | 1426 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); |
1386 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle); | 1427 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle); |
1387 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); | 1428 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); |
1388 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); | 1429 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 | 1646 |
1606 class SkCanvasClipVisitor { | 1647 class SkCanvasClipVisitor { |
1607 public: | 1648 public: |
1608 virtual ~SkCanvasClipVisitor(); | 1649 virtual ~SkCanvasClipVisitor(); |
1609 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1650 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1610 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1651 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1611 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1652 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1612 }; | 1653 }; |
1613 | 1654 |
1614 #endif | 1655 #endif |
OLD | NEW |