Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: include/core/SkCanvas.h

Issue 2382893002: Add a src rect to drawImageLattice() API (Closed)
Patch Set: Simplify impl Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/lattice.cpp ('k') | include/private/SkRecords.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 /** 957 /**
958 * Specifies coordinates to divide a bitmap into (xCount*yCount) rects. 958 * Specifies coordinates to divide a bitmap into (xCount*yCount) rects.
959 *
960 * If the lattice divs or bounds are invalid, the entire lattice
961 * struct will be ignored on the draw call.
959 */ 962 */
960 struct Lattice { 963 struct Lattice {
961 enum Flags : uint8_t { 964 enum Flags : uint8_t {
962 // If set, indicates that we should not draw corresponding rect. 965 // If set, indicates that we should not draw corresponding rect.
963 kTransparent_Flags = 1 << 0, 966 kTransparent_Flags = 1 << 0,
964 }; 967 };
965 968
966 // An array of x-coordinates that divide the bitmap vertically. 969 // An array of x-coordinates that divide the bitmap vertically.
967 // These must be unique, increasing, and in the set [0, width). 970 // These must be unique, increasing, and in the set [fBounds.fLeft, fBou nds.fRight).
968 // Does not have ownership. 971 // Does not have ownership.
969 const int* fXDivs; 972 const int* fXDivs;
970 973
971 // An array of y-coordinates that divide the bitmap horizontally. 974 // An array of y-coordinates that divide the bitmap horizontally.
972 // These must be unique, increasing, and in the set [0, height). 975 // These must be unique, increasing, and in the set [fBounds.fTop, fBoun ds.fBottom).
973 // Does not have ownership. 976 // Does not have ownership.
974 const int* fYDivs; 977 const int* fYDivs;
975 978
976 // If non-null, the length of this array must be equal to 979 // If non-null, the length of this array must be equal to
977 // (fXCount + 1) * (fYCount + 1). Note that we allow the first rect 980 // (fXCount + 1) * (fYCount + 1). Note that we allow the first rect
978 // in each direction to empty (divs[0] = 0). In this case, the 981 // in each direction to be empty (ex: fXDivs[0] = fBounds.fLeft).
979 // caller still must specify a flag (as a placeholder) for these 982 // In this case, the caller still must specify a flag (as a placeholder)
980 // empty rects. 983 // for these empty rects.
981 // The flags correspond to the rects in the lattice, first moving 984 // The flags correspond to the rects in the lattice, first moving
982 // left to right and then top to bottom. 985 // left to right and then top to bottom.
983 const Flags* fFlags; 986 const Flags* fFlags;
984 987
985 // The number of fXDivs. 988 // The number of fXDivs.
986 int fXCount; 989 int fXCount;
987 990
988 // The number of fYDivs. 991 // The number of fYDivs.
989 int fYCount; 992 int fYCount;
993
994 // The bound to draw from. Must be contained by the src that is being d rawn,
995 // non-empty, and non-inverted.
996 // If nullptr, the bounds are the entire src.
997 const SkIRect* fBounds;
990 }; 998 };
991 999
992 /** 1000 /**
993 * Draw the bitmap stretched or shrunk differentially to fit into dst. 1001 * Draw the bitmap stretched or shrunk differentially to fit into dst.
994 * 1002 *
995 * Moving horizontally across the bitmap, alternating rects will be "scalab le" 1003 * Moving horizontally across the bitmap, alternating rects will be "scalab le"
996 * (in the x-dimension) to fit into dst or must be left "fixed". The first rect 1004 * (in the x-dimension) to fit into dst or must be left "fixed". The first rect
997 * is treated as "fixed", but it's possible to specify an empty first rect by 1005 * is treated as "fixed", but it's possible to specify an empty first rect by
998 * making lattice.fXDivs[0] = 0. 1006 * making lattice.fXDivs[0] = 0.
999 * 1007 *
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 1763
1756 class SkCanvasClipVisitor { 1764 class SkCanvasClipVisitor {
1757 public: 1765 public:
1758 virtual ~SkCanvasClipVisitor(); 1766 virtual ~SkCanvasClipVisitor();
1759 virtual void clipRect(const SkRect&, SkCanvas::ClipOp, bool antialias) = 0; 1767 virtual void clipRect(const SkRect&, SkCanvas::ClipOp, bool antialias) = 0;
1760 virtual void clipRRect(const SkRRect&, SkCanvas::ClipOp, bool antialias) = 0 ; 1768 virtual void clipRRect(const SkRRect&, SkCanvas::ClipOp, bool antialias) = 0 ;
1761 virtual void clipPath(const SkPath&, SkCanvas::ClipOp, bool antialias) = 0; 1769 virtual void clipPath(const SkPath&, SkCanvas::ClipOp, bool antialias) = 0;
1762 }; 1770 };
1763 1771
1764 #endif 1772 #endif
OLDNEW
« no previous file with comments | « gm/lattice.cpp ('k') | include/private/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698