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

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

Issue 1239193002: remove all guards for changes to drawBitmapRect / drawImageRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 4 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 | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.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 17 matching lines...) Expand all
28 class SkMetaData; 28 class SkMetaData;
29 class SkPicture; 29 class SkPicture;
30 class SkRRect; 30 class SkRRect;
31 struct SkRSXform; 31 struct SkRSXform;
32 class SkSurface; 32 class SkSurface;
33 class SkSurface_Base; 33 class SkSurface_Base;
34 class SkTextBlob; 34 class SkTextBlob;
35 class GrContext; 35 class GrContext;
36 class GrRenderTarget; 36 class GrRenderTarget;
37 37
38 //#define SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
39
40 class SkCanvasState; 38 class SkCanvasState;
41 39
42 #ifdef SK_SUPPORT_LEGACY_ONDRAWIMAGERECT
43 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::DrawBitmapRectFlags
44 #define SRC_RECT_CONSTRAINT_PARAM(param)
45 #define SRC_RECT_CONSTRAINT_ARG(arg)
46 #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var) SkCanvas::SrcRectConstraint var = SkCanvas::kStrict_SrcRectConstraint;
47 #else
48 #define SK_VIRTUAL_CONSTRAINT_TYPE SkCanvas::SrcRectConstraint
49 #define SRC_RECT_CONSTRAINT_PARAM(param) , SrcRectConstraint param
50 #define SRC_RECT_CONSTRAINT_ARG(arg) , arg
51 #define SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(var)
52 #endif
53
54 /** \class SkCanvas 40 /** \class SkCanvas
55 41
56 A Canvas encapsulates all of the state about drawing into a device (bitmap). 42 A Canvas encapsulates all of the state about drawing into a device (bitmap).
57 This includes a reference to the device itself, and a stack of matrix/clip 43 This includes a reference to the device itself, and a stack of matrix/clip
58 values. For any given draw call (e.g. drawRect), the geometry of the object 44 values. For any given draw call (e.g. drawRect), the geometry of the object
59 being drawn is transformed by the concatenation of all the matrices in the 45 being drawn is transformed by the concatenation of all the matrices in the
60 stack. The transformed geometry is clipped by the intersection of all of 46 stack. The transformed geometry is clipped by the intersection of all of
61 the clips in the stack. 47 the clips in the stack.
62 48
63 While the Canvas holds the state of the drawing device, the state (style) 49 While the Canvas holds the state of the drawing device, the state (style)
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 * dst rect. If the src rect is non-null, only that subset of the bitmap is transformed 874 * dst rect. If the src rect is non-null, only that subset of the bitmap is transformed
889 * and drawn. 875 * and drawn.
890 * 876 *
891 * @param bitmap The bitmap to be drawn 877 * @param bitmap The bitmap to be drawn
892 * @param src Optional: specify the subset of the bitmap to be drawn 878 * @param src Optional: specify the subset of the bitmap to be drawn
893 * @param dst The destination rectangle where the scaled/translated 879 * @param dst The destination rectangle where the scaled/translated
894 * bitmap will be drawn 880 * bitmap will be drawn
895 * @param paint The paint used to draw the bitmap, or NULL 881 * @param paint The paint used to draw the bitmap, or NULL
896 * @param constraint Control the tradeoff between speed and exactness w.r.t . the src-rect. 882 * @param constraint Control the tradeoff between speed and exactness w.r.t . the src-rect.
897 */ 883 */
898 #ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
899 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
900 const SkPaint* paint, SrcRectConstraint);
901 #else
902 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, 884 void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
903 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); 885 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint);
904 #endif
905 886
906 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint = NULL) { 887 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint * paint = NULL) {
907 this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint ); 888 this->drawBitmapRect(bitmap, NULL, dst, paint, kStrict_SrcRectConstraint );
908 } 889 }
909 890
910 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst, 891 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRec t& dst,
911 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint); 892 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRec tConstraint);
912 893
913 #ifdef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
914 // IMPORTANT that thse be value-equal with SrcRectConstraint (during transit ion period)
915 enum DrawBitmapRectFlags {
916 kNone_DrawBitmapRectFlag = 0x0,
917 /**
918 * When filtering is enabled, allow the color samples outside of
919 * the src rect (but still in the src bitmap) to bleed into the
920 * drawn portion
921 */
922 kBleed_DrawBitmapRectFlag = 0x1,
923 };
924
925 /** Draw the specified bitmap, with the specified matrix applied (before the
926 canvas' matrix is applied).
927 @param bitmap The bitmap to be drawn
928 @param src Optional: specify the subset of the bitmap to be drawn
929 @param dst The destination rectangle where the scaled/translated
930 image will be drawn
931 @param paint The paint used to draw the bitmap, or NULL
932 */
933 void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, const S kRect& dst,
934 const SkPaint* paint = NULL,
935 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFl ag);
936
937 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
938 const SkRect& dst, const SkPaint* paint = NULL,
939 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) {
940 SkRect realSrcStorage;
941 SkRect* realSrcPtr = NULL;
942 if (isrc) {
943 realSrcStorage.set(*isrc);
944 realSrcPtr = &realSrcStorage;
945 }
946 this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags);
947 }
948 #endif
949
950 /** 894 /**
951 * Draw the bitmap stretched differentially to fit into dst. 895 * Draw the bitmap stretched differentially to fit into dst.
952 * center is a rect within the bitmap, and logically divides the bitmap 896 * center is a rect within the bitmap, and logically divides the bitmap
953 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] 897 * into 9 sections (3x3). For example, if the middle pixel of a [5x5]
954 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. 898 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3].
955 * 899 *
956 * If the dst is >= the bitmap size, then... 900 * If the dst is >= the bitmap size, then...
957 * - The 4 corners are not stretched at all. 901 * - The 4 corners are not stretched at all.
958 * - The sides are stretched in only one axis. 902 * - The sides are stretched in only one axis.
959 * - The center is stretched in both axes. 903 * - The center is stretched in both axes.
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 virtual void onDrawRRect(const SkRRect&, const SkPaint&); 1264 virtual void onDrawRRect(const SkRRect&, const SkPaint&);
1321 virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], cons t SkPaint&); 1265 virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], cons t SkPaint&);
1322 virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint verti ces[], 1266 virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint verti ces[],
1323 const SkPoint texs[], const SkColor colors[], Sk Xfermode*, 1267 const SkPoint texs[], const SkColor colors[], Sk Xfermode*,
1324 const uint16_t indices[], int indexCount, const SkPaint&); 1268 const uint16_t indices[], int indexCount, const SkPaint&);
1325 1269
1326 virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], 1270 virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
1327 int count, SkXfermode::Mode, const SkRect* cull, co nst SkPaint*); 1271 int count, SkXfermode::Mode, const SkRect* cull, co nst SkPaint*);
1328 virtual void onDrawPath(const SkPath&, const SkPaint&); 1272 virtual void onDrawPath(const SkPath&, const SkPaint&);
1329 virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkP aint*); 1273 virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkP aint*);
1330 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c onst SkPaint* 1274 virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, c onst SkPaint*,
1331 SRC_RECT_CONSTRAINT_PARAM(constraint)); 1275 SrcRectConstraint);
1332 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk Rect& dst, 1276 virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const Sk Rect& dst,
1333 const SkPaint*); 1277 const SkPaint*);
1334 1278
1335 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S kPaint*); 1279 virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const S kPaint*);
1336 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, 1280 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
1337 SK_VIRTUAL_CONSTRAINT_TYPE); 1281 SrcRectConstraint);
1338 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, 1282 virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
1339 const SkPaint*); 1283 const SkPaint*);
1340 virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint* ); 1284 virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint* );
1341 1285
1342 enum ClipEdgeStyle { 1286 enum ClipEdgeStyle {
1343 kHard_ClipEdgeStyle, 1287 kHard_ClipEdgeStyle,
1344 kSoft_ClipEdgeStyle 1288 kSoft_ClipEdgeStyle
1345 }; 1289 };
1346 1290
1347 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); 1291 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 1561
1618 class SkCanvasClipVisitor { 1562 class SkCanvasClipVisitor {
1619 public: 1563 public:
1620 virtual ~SkCanvasClipVisitor(); 1564 virtual ~SkCanvasClipVisitor();
1621 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1565 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
1622 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 1566 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
1623 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 1567 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
1624 }; 1568 };
1625 1569
1626 #endif 1570 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698