| 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 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkDeque.h" | 13 #include "SkDeque.h" |
| 14 #include "SkClipStack.h" | 14 #include "SkClipStack.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 17 #include "SkPath.h" | 17 #include "SkPath.h" |
| 18 #include "SkRegion.h" | 18 #include "SkRegion.h" |
| 19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
| 20 | 20 |
| 21 // if not defined, we always assume ClipToLayer for saveLayer() | 21 // if not defined, we always assume ClipToLayer for saveLayer() |
| 22 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 22 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
| 23 | 23 |
| 24 | 24 |
| 25 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE | 25 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE |
| 26 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP | 26 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP |
| 27 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE | 27 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE |
| 28 | 28 |
| 29 //#define SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL |
| 30 #ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL |
| 31 #define SK_LEGACY_DRAWTEXT_VIRTUAL virtual |
| 32 #else |
| 33 #define SK_LEGACY_DRAWTEXT_VIRTUAL |
| 34 #endif |
| 35 |
| 29 class SkBounder; | 36 class SkBounder; |
| 30 class SkBaseDevice; | 37 class SkBaseDevice; |
| 31 class SkDraw; | 38 class SkDraw; |
| 32 class SkDrawFilter; | 39 class SkDrawFilter; |
| 33 class SkMetaData; | 40 class SkMetaData; |
| 34 class SkPicture; | 41 class SkPicture; |
| 35 class SkRRect; | 42 class SkRRect; |
| 36 class SkSurface; | 43 class SkSurface; |
| 37 class SkSurface_Base; | 44 class SkSurface_Base; |
| 38 class GrContext; | 45 class GrContext; |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 const SkPaint* paint = NULL); | 868 const SkPaint* paint = NULL); |
| 862 | 869 |
| 863 /** Draw the text, with origin at (x,y), using the specified paint. | 870 /** Draw the text, with origin at (x,y), using the specified paint. |
| 864 The origin is interpreted based on the Align setting in the paint. | 871 The origin is interpreted based on the Align setting in the paint. |
| 865 @param text The text to be drawn | 872 @param text The text to be drawn |
| 866 @param byteLength The number of bytes to read from the text parameter | 873 @param byteLength The number of bytes to read from the text parameter |
| 867 @param x The x-coordinate of the origin of the text being drawn | 874 @param x The x-coordinate of the origin of the text being drawn |
| 868 @param y The y-coordinate of the origin of the text being drawn | 875 @param y The y-coordinate of the origin of the text being drawn |
| 869 @param paint The paint used for the text (e.g. color, size, style) | 876 @param paint The paint used for the text (e.g. color, size, style) |
| 870 */ | 877 */ |
| 871 virtual void drawText(const void* text, size_t byteLength, SkScalar x, | 878 SK_LEGACY_DRAWTEXT_VIRTUAL void drawText(const void* text, size_t byteLength
, SkScalar x, |
| 872 SkScalar y, const SkPaint& paint); | 879 SkScalar y, const SkPaint& paint); |
| 873 | 880 |
| 874 /** Draw the text, with each character/glyph origin specified by the pos[] | 881 /** Draw the text, with each character/glyph origin specified by the pos[] |
| 875 array. The origin is interpreted by the Align setting in the paint. | 882 array. The origin is interpreted by the Align setting in the paint. |
| 876 @param text The text to be drawn | 883 @param text The text to be drawn |
| 877 @param byteLength The number of bytes to read from the text parameter | 884 @param byteLength The number of bytes to read from the text parameter |
| 878 @param pos Array of positions, used to position each character | 885 @param pos Array of positions, used to position each character |
| 879 @param paint The paint used for the text (e.g. color, size, style) | 886 @param paint The paint used for the text (e.g. color, size, style) |
| 880 */ | 887 */ |
| 881 virtual void drawPosText(const void* text, size_t byteLength, | 888 SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosText(const void* text, size_t byteLen
gth, |
| 882 const SkPoint pos[], const SkPaint& paint); | 889 const SkPoint pos[], const SkPaint& paint); |
| 883 | 890 |
| 884 /** Draw the text, with each character/glyph origin specified by the x | 891 /** Draw the text, with each character/glyph origin specified by the x |
| 885 coordinate taken from the xpos[] array, and the y from the constY param. | 892 coordinate taken from the xpos[] array, and the y from the constY param. |
| 886 The origin is interpreted by the Align setting in the paint. | 893 The origin is interpreted by the Align setting in the paint. |
| 887 @param text The text to be drawn | 894 @param text The text to be drawn |
| 888 @param byteLength The number of bytes to read from the text parameter | 895 @param byteLength The number of bytes to read from the text parameter |
| 889 @param xpos Array of x-positions, used to position each character | 896 @param xpos Array of x-positions, used to position each character |
| 890 @param constY The shared Y coordinate for all of the positions | 897 @param constY The shared Y coordinate for all of the positions |
| 891 @param paint The paint used for the text (e.g. color, size, style) | 898 @param paint The paint used for the text (e.g. color, size, style) |
| 892 */ | 899 */ |
| 893 virtual void drawPosTextH(const void* text, size_t byteLength, | 900 SK_LEGACY_DRAWTEXT_VIRTUAL void drawPosTextH(const void* text, size_t byteLe
ngth, |
| 894 const SkScalar xpos[], SkScalar constY, | 901 const SkScalar xpos[], SkScalar constY, |
| 895 const SkPaint& paint); | 902 const SkPaint& paint); |
| 896 | 903 |
| 897 /** Draw the text, with origin at (x,y), using the specified paint, along | 904 /** Draw the text, with origin at (x,y), using the specified paint, along |
| 898 the specified path. The paint's Align setting determins where along the | 905 the specified path. The paint's Align setting determins where along the |
| 899 path to start the text. | 906 path to start the text. |
| 900 @param text The text to be drawn | 907 @param text The text to be drawn |
| 901 @param byteLength The number of bytes to read from the text parameter | 908 @param byteLength The number of bytes to read from the text parameter |
| 902 @param path The path the text should follow for its baseline | 909 @param path The path the text should follow for its baseline |
| 903 @param hOffset The distance along the path to add to the text's | 910 @param hOffset The distance along the path to add to the text's |
| 904 starting position | 911 starting position |
| 905 @param vOffset The distance above(-) or below(+) the path to | 912 @param vOffset The distance above(-) or below(+) the path to |
| 906 position the text | 913 position the text |
| 907 @param paint The paint used for the text | 914 @param paint The paint used for the text |
| 908 */ | 915 */ |
| 909 void drawTextOnPathHV(const void* text, size_t byteLength, | 916 void drawTextOnPathHV(const void* text, size_t byteLength, |
| 910 const SkPath& path, SkScalar hOffset, | 917 const SkPath& path, SkScalar hOffset, |
| 911 SkScalar vOffset, const SkPaint& paint); | 918 SkScalar vOffset, const SkPaint& paint); |
| 912 | 919 |
| 913 /** Draw the text, with origin at (x,y), using the specified paint, along | 920 /** Draw the text, with origin at (x,y), using the specified paint, along |
| 914 the specified path. The paint's Align setting determins where along the | 921 the specified path. The paint's Align setting determins where along the |
| 915 path to start the text. | 922 path to start the text. |
| 916 @param text The text to be drawn | 923 @param text The text to be drawn |
| 917 @param byteLength The number of bytes to read from the text parameter | 924 @param byteLength The number of bytes to read from the text parameter |
| 918 @param path The path the text should follow for its baseline | 925 @param path The path the text should follow for its baseline |
| 919 @param matrix (may be null) Applied to the text before it is | 926 @param matrix (may be null) Applied to the text before it is |
| 920 mapped onto the path | 927 mapped onto the path |
| 921 @param paint The paint used for the text | 928 @param paint The paint used for the text |
| 922 */ | 929 */ |
| 923 virtual void drawTextOnPath(const void* text, size_t byteLength, | 930 SK_LEGACY_DRAWTEXT_VIRTUAL void drawTextOnPath(const void* text, size_t byte
Length, |
| 924 const SkPath& path, const SkMatrix* matrix, | 931 const SkPath& path, const SkMatrix* matrix, |
| 925 const SkPaint& paint); | 932 const SkPaint& paint); |
| 926 | 933 |
| 927 /** PRIVATE / EXPERIMENTAL -- do not call | 934 /** PRIVATE / EXPERIMENTAL -- do not call |
| 928 Perform back-end analysis/optimization of a picture. This may attach | 935 Perform back-end analysis/optimization of a picture. This may attach |
| 929 optimization data to the picture which can be used by a later | 936 optimization data to the picture which can be used by a later |
| 930 drawPicture call. | 937 drawPicture call. |
| 931 @param picture The recorded drawing commands to analyze/optimize | 938 @param picture The recorded drawing commands to analyze/optimize |
| 932 */ | 939 */ |
| 933 void EXPERIMENTAL_optimize(SkPicture* picture); | 940 void EXPERIMENTAL_optimize(SkPicture* picture); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 }; | 1186 }; |
| 1180 virtual void willSave(SaveFlags); | 1187 virtual void willSave(SaveFlags); |
| 1181 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags); | 1188 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags); |
| 1182 virtual void willRestore(); | 1189 virtual void willRestore(); |
| 1183 | 1190 |
| 1184 virtual void didConcat(const SkMatrix&); | 1191 virtual void didConcat(const SkMatrix&); |
| 1185 virtual void didSetMatrix(const SkMatrix&); | 1192 virtual void didSetMatrix(const SkMatrix&); |
| 1186 | 1193 |
| 1187 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); | 1194 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); |
| 1188 | 1195 |
| 1196 #ifndef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL |
| 1197 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, |
| 1198 SkScalar y, const SkPaint& paint); |
| 1199 |
| 1200 virtual void onDrawPosText(const void* text, size_t byteLength, |
| 1201 const SkPoint pos[], const SkPaint& paint); |
| 1202 |
| 1203 virtual void onDrawPosTextH(const void* text, size_t byteLength, |
| 1204 const SkScalar xpos[], SkScalar constY, |
| 1205 const SkPaint& paint); |
| 1206 |
| 1207 virtual void onDrawTextOnPath(const void* text, size_t byteLength, |
| 1208 const SkPath& path, const SkMatrix* matrix, |
| 1209 const SkPaint& paint); |
| 1210 #endif |
| 1211 |
| 1189 enum ClipEdgeStyle { | 1212 enum ClipEdgeStyle { |
| 1190 kHard_ClipEdgeStyle, | 1213 kHard_ClipEdgeStyle, |
| 1191 kSoft_ClipEdgeStyle | 1214 kSoft_ClipEdgeStyle |
| 1192 }; | 1215 }; |
| 1193 | 1216 |
| 1194 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); | 1217 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); |
| 1195 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle); | 1218 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e edgeStyle); |
| 1196 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); | 1219 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e
dgeStyle); |
| 1197 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); | 1220 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
| 1198 | 1221 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 bool asROBitmap(SkBitmap*) const; | 1458 bool asROBitmap(SkBitmap*) const; |
| 1436 | 1459 |
| 1437 private: | 1460 private: |
| 1438 SkBitmap fBitmap; // used if peekPixels() fails | 1461 SkBitmap fBitmap; // used if peekPixels() fails |
| 1439 const void* fAddr; // NULL on failure | 1462 const void* fAddr; // NULL on failure |
| 1440 SkImageInfo fInfo; | 1463 SkImageInfo fInfo; |
| 1441 size_t fRowBytes; | 1464 size_t fRowBytes; |
| 1442 }; | 1465 }; |
| 1443 | 1466 |
| 1444 #endif | 1467 #endif |
| OLD | NEW |