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

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

Issue 1777403002: Allow const& for SkImages and SkPictures in draw methods. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 765
766 /** Draw the specified image, with its top/left corner at (x,y), using the 766 /** Draw the specified image, with its top/left corner at (x,y), using the
767 specified paint, transformed by the current matrix. 767 specified paint, transformed by the current matrix.
768 768
769 @param image The image to be drawn 769 @param image The image to be drawn
770 @param left The position of the left side of the image being drawn 770 @param left The position of the left side of the image being drawn
771 @param top The position of the top side of the image being drawn 771 @param top The position of the top side of the image being drawn
772 @param paint The paint used to draw the image, or NULL 772 @param paint The paint used to draw the image, or NULL
773 */ 773 */
774 void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPa int* paint = NULL); 774 void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPa int* paint = NULL);
775 void drawImage(sk_sp<const SkImage> image, SkScalar left, SkScalar top,
bungeman-skia 2016/03/10 22:14:01 Taking the sk_sp by value here means you're taking
bsalomon 2016/03/10 22:22:16 Is there a downside to a const sk_sp<const>& param
bungeman-skia 2016/03/10 23:06:14 We would need two signatures, one for "const sk_sp
776 const SkPaint* paint = NULL) {
777 this->drawImage(image.get(), left, top, paint);
778 }
775 779
776 /** 780 /**
777 * Controls the behavior at the edge of the src-rect, when specified in dra wImageRect, 781 * Controls the behavior at the edge of the src-rect, when specified in dra wImageRect,
778 * trading off speed for exactness. 782 * trading off speed for exactness.
779 * 783 *
780 * When filtering is enabled (in the Paint), skia may need to sample in a n eighborhood around 784 * When filtering is enabled (in the Paint), skia may need to sample in a n eighborhood around
781 * the pixels in the image. If there is a src-rect specified, it is intende d to restrict the 785 * the pixels in the image. If there is a src-rect specified, it is intende d to restrict the
782 * pixels that will be read. However, for performance reasons, some impleme ntations may slow 786 * pixels that will be read. However, for performance reasons, some impleme ntations may slow
783 * down if they cannot read 1-pixel past the src-rect boundary at times. 787 * down if they cannot read 1-pixel past the src-rect boundary at times.
784 * 788 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& ds t, 820 void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& ds t,
817 const SkPaint* paint, 821 const SkPaint* paint,
818 SrcRectConstraint constraint = kStrict_SrcRectConstraint) ; 822 SrcRectConstraint constraint = kStrict_SrcRectConstraint) ;
819 // variant that takes src SkIRect 823 // variant that takes src SkIRect
820 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst, 824 void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
821 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect Constraint); 825 const SkPaint* paint, SrcRectConstraint = kStrict_SrcRect Constraint);
822 // variant that assumes src == image-bounds 826 // variant that assumes src == image-bounds
823 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p aint, 827 void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* p aint,
824 SrcRectConstraint = kStrict_SrcRectConstraint); 828 SrcRectConstraint = kStrict_SrcRectConstraint);
825 829
830 void drawImageRect(sk_sp<const SkImage> image, const SkRect& src, const SkRe ct& dst,
831 const SkPaint* paint,
832 SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
833 this->drawImageRect(image.get(), src, dst, paint, constraint);
834 }
835 void drawImageRect(sk_sp<const SkImage> image, const SkIRect& isrc, const Sk Rect& dst,
836 const SkPaint* paint, SrcRectConstraint cons = kStrict_Sr cRectConstraint) {
837 this->drawImageRect(image.get(), isrc, dst, paint, cons);
838 }
839 void drawImageRect(sk_sp<const SkImage> image, const SkRect& dst, const SkPa int* paint,
840 SrcRectConstraint cons = kStrict_SrcRectConstraint) {
841 this->drawImageRect(image.get(), dst, paint, cons);
842 }
843
826 /** 844 /**
827 * Draw the image stretched differentially to fit into dst. 845 * Draw the image stretched differentially to fit into dst.
828 * center is a rect within the image, and logically divides the image 846 * center is a rect within the image, and logically divides the image
829 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] 847 * into 9 sections (3x3). For example, if the middle pixel of a [5x5]
830 * image is the "center", then the center-rect should be [2, 2, 3, 3]. 848 * image is the "center", then the center-rect should be [2, 2, 3, 3].
831 * 849 *
832 * If the dst is >= the image size, then... 850 * If the dst is >= the image size, then...
833 * - The 4 corners are not stretched at all. 851 * - The 4 corners are not stretched at all.
834 * - The sides are stretched in only one axis. 852 * - The sides are stretched in only one axis.
835 * - The center is stretched in both axes. 853 * - The center is stretched in both axes.
836 * Else, for each axis where dst < image, 854 * Else, for each axis where dst < image,
837 * - The corners shrink proportionally 855 * - The corners shrink proportionally
838 * - The sides (along the shrink axis) and center are not drawn 856 * - The sides (along the shrink axis) and center are not drawn
839 */ 857 */
840 void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, 858 void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
841 const SkPaint* paint = NULL); 859 const SkPaint* paint = nullptr);
860 void drawImageNine(sk_sp<const SkImage> image, const SkIRect& center, const SkRect& dst,
861 const SkPaint* paint = nullptr) {
862 this->drawImageNine(image.get(), center, dst, paint);
863 }
842 864
843 /** Draw the specified bitmap, with its top/left corner at (x,y), using the 865 /** Draw the specified bitmap, with its top/left corner at (x,y), using the
844 specified paint, transformed by the current matrix. Note: if the paint 866 specified paint, transformed by the current matrix. Note: if the paint
845 contains a maskfilter that generates a mask which extends beyond the 867 contains a maskfilter that generates a mask which extends beyond the
846 bitmap's original width/height, then the bitmap will be drawn as if it 868 bitmap's original width/height, then the bitmap will be drawn as if it
847 were in a Shader with CLAMP mode. Thus the color outside of the original 869 were in a Shader with CLAMP mode. Thus the color outside of the original
848 width/height will be the edge color replicated. 870 width/height will be the edge color replicated.
849 871
850 If a shader is present on the paint it will be ignored, except in the 872 If a shader is present on the paint it will be ignored, except in the
851 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i s 873 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i s
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 */ 1080 */
1059 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], 1081 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[],
1060 const SkColor colors[], int count, SkXfermode::Mode, const Sk Rect* cullRect, 1082 const SkColor colors[], int count, SkXfermode::Mode, const Sk Rect* cullRect,
1061 const SkPaint* paint); 1083 const SkPaint* paint);
1062 1084
1063 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], int count, 1085 void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect t ex[], int count,
1064 const SkRect* cullRect, const SkPaint* paint) { 1086 const SkRect* cullRect, const SkPaint* paint) {
1065 this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, c ullRect, paint); 1087 this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, c ullRect, paint);
1066 } 1088 }
1067 1089
1090 void drawAtlas(sk_sp<const SkImage> atlas, const SkRSXform xform[], const Sk Rect tex[],
1091 const SkColor colors[], int count, SkXfermode::Mode mode, con st SkRect* cull,
1092 const SkPaint* paint) {
1093 this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cull, pain t);
1094 }
1095 void drawAtlas(sk_sp<const SkImage> atlas, const SkRSXform xform[], const Sk Rect tex[],
1096 int count, const SkRect* cullRect, const SkPaint* paint) {
1097 this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkXfermode::kDs t_Mode,
1098 cullRect, paint);
1099 }
1100
1068 /** 1101 /**
1069 * Draw the contents of this drawable into the canvas. If the canvas is asy nc 1102 * Draw the contents of this drawable into the canvas. If the canvas is asy nc
1070 * (e.g. it is recording into a picture) then the drawable will be referenc ed instead, 1103 * (e.g. it is recording into a picture) then the drawable will be referenc ed instead,
1071 * to have its draw() method called when the picture is finalized. 1104 * to have its draw() method called when the picture is finalized.
1072 * 1105 *
1073 * If the intent is to force the contents of the drawable into this canvas immediately, 1106 * If the intent is to force the contents of the drawable into this canvas immediately,
1074 * then drawable->draw(canvas) may be called. 1107 * then drawable->draw(canvas) may be called.
1075 */ 1108 */
1076 void drawDrawable(SkDrawable* drawable, const SkMatrix* = NULL); 1109 void drawDrawable(SkDrawable* drawable, const SkMatrix* = NULL);
1077 void drawDrawable(SkDrawable*, SkScalar x, SkScalar y); 1110 void drawDrawable(SkDrawable*, SkScalar x, SkScalar y);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 1545
1513 class SkCanvasClipVisitor { 1546 class SkCanvasClipVisitor {
1514 public: 1547 public:
1515 virtual ~SkCanvasClipVisitor(); 1548 virtual ~SkCanvasClipVisitor();
1516 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1549 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
1517 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 1550 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
1518 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 1551 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
1519 }; 1552 };
1520 1553
1521 #endif 1554 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698