| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkCanvas_DEFINED | 10 #ifndef SkCanvas_DEFINED |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 were in a Shader with CLAMP mode. Thus the color outside of the original | 660 were in a Shader with CLAMP mode. Thus the color outside of the original |
| 661 width/height will be the edge color replicated. | 661 width/height will be the edge color replicated. |
| 662 @param bitmap The bitmap to be drawn | 662 @param bitmap The bitmap to be drawn |
| 663 @param left The position of the left side of the bitmap being drawn | 663 @param left The position of the left side of the bitmap being drawn |
| 664 @param top The position of the top side of the bitmap being drawn | 664 @param top The position of the top side of the bitmap being drawn |
| 665 @param paint The paint used to draw the bitmap, or NULL | 665 @param paint The paint used to draw the bitmap, or NULL |
| 666 */ | 666 */ |
| 667 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, | 667 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 668 const SkPaint* paint = NULL); | 668 const SkPaint* paint = NULL); |
| 669 | 669 |
| 670 enum DrawBitmapRectFlags { |
| 671 kNone_DrawBitmapRectflag = 0x0, |
| 672 /** |
| 673 * When filtering is enabled, allow the color samples outside of |
| 674 * the src rect (but still in the src bitmap) to bleed into the |
| 675 * drawn portion |
| 676 */ |
| 677 kBleed_DrawBitmapRectFlag = 0x1, |
| 678 }; |
| 679 |
| 670 /** Draw the specified bitmap, with the specified matrix applied (before the | 680 /** Draw the specified bitmap, with the specified matrix applied (before the |
| 671 canvas' matrix is applied). | 681 canvas' matrix is applied). |
| 672 @param bitmap The bitmap to be drawn | 682 @param bitmap The bitmap to be drawn |
| 673 @param src Optional: specify the subset of the bitmap to be drawn | 683 @param src Optional: specify the subset of the bitmap to be drawn |
| 674 @param dst The destination rectangle where the scaled/translated | 684 @param dst The destination rectangle where the scaled/translated |
| 675 image will be drawn | 685 image will be drawn |
| 676 @param paint The paint used to draw the bitmap, or NULL | 686 @param paint The paint used to draw the bitmap, or NULL |
| 677 */ | 687 */ |
| 678 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, | 688 virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
| 679 const SkRect& dst, | 689 const SkRect& dst, |
| 680 const SkPaint* paint); | 690 const SkPaint* paint = NULL, |
| 691 DrawBitmapRectFlags flags = kNone_DrawBitm
apRectflag); |
| 681 | 692 |
| 682 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, | 693 void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, |
| 683 const SkPaint* paint) { | 694 const SkPaint* paint = NULL) { |
| 684 this->drawBitmapRectToRect(bitmap, NULL, dst, paint); | 695 this->drawBitmapRectToRect(bitmap, NULL, dst, paint, kNone_DrawBitmapRec
tflag); |
| 685 } | 696 } |
| 686 | 697 |
| 687 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc, | 698 void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc, |
| 688 const SkRect& dst, const SkPaint* paint = NULL) { | 699 const SkRect& dst, const SkPaint* paint = NULL, |
| 700 DrawBitmapRectFlags flags = kNone_DrawBitmapRectflag) { |
| 689 SkRect realSrcStorage; | 701 SkRect realSrcStorage; |
| 690 SkRect* realSrcPtr = NULL; | 702 SkRect* realSrcPtr = NULL; |
| 691 if (isrc) { | 703 if (isrc) { |
| 692 realSrcStorage.set(*isrc); | 704 realSrcStorage.set(*isrc); |
| 693 realSrcPtr = &realSrcStorage; | 705 realSrcPtr = &realSrcStorage; |
| 694 } | 706 } |
| 695 this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint); | 707 this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint, flags); |
| 696 } | 708 } |
| 697 | 709 |
| 698 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, | 710 virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
| 699 const SkPaint* paint = NULL); | 711 const SkPaint* paint = NULL); |
| 700 | 712 |
| 701 /** | 713 /** |
| 702 * Draw the bitmap stretched differentially to fit into dst. | 714 * Draw the bitmap stretched differentially to fit into dst. |
| 703 * center is a rect within the bitmap, and logically divides the bitmap | 715 * center is a rect within the bitmap, and logically divides the bitmap |
| 704 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] | 716 * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
| 705 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. | 717 * bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 | 1070 |
| 1059 SkDevice* createLayerDevice(SkBitmap::Config, int width, int height, | 1071 SkDevice* createLayerDevice(SkBitmap::Config, int width, int height, |
| 1060 bool isOpaque); | 1072 bool isOpaque); |
| 1061 | 1073 |
| 1062 SkDevice* init(SkDevice*); | 1074 SkDevice* init(SkDevice*); |
| 1063 | 1075 |
| 1064 // internal methods are not virtual, so they can safely be called by other | 1076 // internal methods are not virtual, so they can safely be called by other |
| 1065 // canvas apis, without confusing subclasses (like SkPictureRecording) | 1077 // canvas apis, without confusing subclasses (like SkPictureRecording) |
| 1066 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p
aint); | 1078 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p
aint); |
| 1067 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, | 1079 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
| 1068 const SkRect& dst, const SkPaint* paint); | 1080 const SkRect& dst, const SkPaint* paint, |
| 1081 DrawBitmapRectFlags flags); |
| 1069 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 1082 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
| 1070 const SkRect& dst, const SkPaint* paint); | 1083 const SkRect& dst, const SkPaint* paint); |
| 1071 void internalDrawPaint(const SkPaint& paint); | 1084 void internalDrawPaint(const SkPaint& paint); |
| 1072 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, | 1085 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, |
| 1073 SaveFlags, bool justForImageFilter); | 1086 SaveFlags, bool justForImageFilter); |
| 1074 void internalDrawDevice(SkDevice*, int x, int y, const SkPaint*); | 1087 void internalDrawDevice(SkDevice*, int x, int y, const SkPaint*); |
| 1075 | 1088 |
| 1076 // shared by save() and saveLayer() | 1089 // shared by save() and saveLayer() |
| 1077 int internalSave(SaveFlags flags); | 1090 int internalSave(SaveFlags flags); |
| 1078 void internalRestore(); | 1091 void internalRestore(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 if (NULL != fCanvas) { | 1183 if (NULL != fCanvas) { |
| 1171 fCanvas->endCommentGroup(); | 1184 fCanvas->endCommentGroup(); |
| 1172 } | 1185 } |
| 1173 } | 1186 } |
| 1174 | 1187 |
| 1175 private: | 1188 private: |
| 1176 SkCanvas* fCanvas; | 1189 SkCanvas* fCanvas; |
| 1177 }; | 1190 }; |
| 1178 | 1191 |
| 1179 #endif | 1192 #endif |
| OLD | NEW |