| OLD | NEW |
| 1 | |
| 2 | |
| 3 /* | 1 /* |
| 4 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 5 * | 3 * |
| 6 * 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 |
| 7 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 8 */ | 6 */ |
| 9 | 7 |
| 10 | |
| 11 #ifndef SkPaint_DEFINED | 8 #ifndef SkPaint_DEFINED |
| 12 #define SkPaint_DEFINED | 9 #define SkPaint_DEFINED |
| 13 | 10 |
| 14 #include "SkColor.h" | 11 #include "SkColor.h" |
| 15 #include "SkDrawLooper.h" | 12 #include "SkDrawLooper.h" |
| 16 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 17 #include "SkXfermode.h" | 14 #include "SkXfermode.h" |
| 18 | 15 |
| 19 class SkAnnotation; | 16 class SkAnnotation; |
| 20 class SkAutoGlyphCache; | 17 class SkAutoGlyphCache; |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 * be treated has a height instead of a width. | 868 * be treated has a height instead of a width. |
| 872 * | 869 * |
| 873 * @param text Address of the text | 870 * @param text Address of the text |
| 874 * @param length Number of bytes of text to measure | 871 * @param length Number of bytes of text to measure |
| 875 * @return The advance width of the text | 872 * @return The advance width of the text |
| 876 */ | 873 */ |
| 877 SkScalar measureText(const void* text, size_t length) const { | 874 SkScalar measureText(const void* text, size_t length) const { |
| 878 return this->measureText(text, length, NULL); | 875 return this->measureText(text, length, NULL); |
| 879 } | 876 } |
| 880 | 877 |
| 881 /** Specify the direction the text buffer should be processed in breakText() | |
| 882 */ | |
| 883 enum TextBufferDirection { | |
| 884 /** When measuring text for breakText(), begin at the start of the text | |
| 885 buffer and proceed forward through the data. This is the default. | |
| 886 */ | |
| 887 kForward_TextBufferDirection, | |
| 888 /** When measuring text for breakText(), begin at the end of the text | |
| 889 buffer and proceed backwards through the data. | |
| 890 */ | |
| 891 kBackward_TextBufferDirection | |
| 892 }; | |
| 893 | |
| 894 /** Return the number of bytes of text that were measured. If | 878 /** Return the number of bytes of text that were measured. If |
| 895 * isVerticalText() is true, then the vertical advances are used for | 879 * isVerticalText() is true, then the vertical advances are used for |
| 896 * the measurement. | 880 * the measurement. |
| 897 * | 881 * |
| 898 * @param text The text to be measured | 882 * @param text The text to be measured |
| 899 * @param length Number of bytes of text to measure | 883 * @param length Number of bytes of text to measure |
| 900 * @param maxWidth Maximum width. Only the subset of text whose accumulated | 884 * @param maxWidth Maximum width. Only the subset of text whose accumulated |
| 901 * widths are <= maxWidth are measured. | 885 * widths are <= maxWidth are measured. |
| 902 * @param measuredWidth Optional. If non-null, this returns the actual | 886 * @param measuredWidth Optional. If non-null, this returns the actual |
| 903 * width of the measured text. | 887 * width of the measured text. |
| 904 * @param tbd Optional. The direction the text buffer should be | |
| 905 * traversed during measuring. | |
| 906 * @return The number of bytes of text that were measured. Will be | 888 * @return The number of bytes of text that were measured. Will be |
| 907 * <= length. | 889 * <= length. |
| 908 */ | 890 */ |
| 909 size_t breakText(const void* text, size_t length, SkScalar maxWidth, | 891 size_t breakText(const void* text, size_t length, SkScalar maxWidth, |
| 910 SkScalar* measuredWidth = NULL, | 892 SkScalar* measuredWidth = NULL) const; |
| 911 TextBufferDirection tbd = kForward_TextBufferDirection) | |
| 912 const; | |
| 913 | 893 |
| 914 /** Return the advances for the text. These will be vertical advances if | 894 /** Return the advances for the text. These will be vertical advances if |
| 915 * isVerticalText() returns true. | 895 * isVerticalText() returns true. |
| 916 * | 896 * |
| 917 * @param text the text | 897 * @param text the text |
| 918 * @param byteLength number of bytes to of text | 898 * @param byteLength number of bytes to of text |
| 919 * @param widths If not null, returns the array of advances for | 899 * @param widths If not null, returns the array of advances for |
| 920 * the glyphs. If not NULL, must be at least a large | 900 * the glyphs. If not NULL, must be at least a large |
| 921 * as the number of unichars in the specified text. | 901 * as the number of unichars in the specified text. |
| 922 * @param bounds If not null, returns the bounds for each of | 902 * @param bounds If not null, returns the bounds for each of |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 unsigned fStyle : 2; | 1032 unsigned fStyle : 2; |
| 1053 unsigned fTextEncoding : 2; // 3 values | 1033 unsigned fTextEncoding : 2; // 3 values |
| 1054 unsigned fHinting : 2; | 1034 unsigned fHinting : 2; |
| 1055 unsigned fFilterLevel : 2; | 1035 unsigned fFilterLevel : 2; |
| 1056 //unsigned fFreeBits : 2; | 1036 //unsigned fFreeBits : 2; |
| 1057 } fBitfields; | 1037 } fBitfields; |
| 1058 uint32_t fBitfieldsUInt; | 1038 uint32_t fBitfieldsUInt; |
| 1059 }; | 1039 }; |
| 1060 | 1040 |
| 1061 SkDrawCacheProc getDrawCacheProc() const; | 1041 SkDrawCacheProc getDrawCacheProc() const; |
| 1062 SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir, | 1042 SkMeasureCacheProc getMeasureCacheProc(bool needFullMetrics) const; |
| 1063 bool needFullMetrics) const; | |
| 1064 | 1043 |
| 1065 SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, | 1044 SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, |
| 1066 int* count, SkRect* bounds) const; | 1045 int* count, SkRect* bounds) const; |
| 1067 | 1046 |
| 1068 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const
SkMatrix*, | 1047 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const
SkMatrix*, |
| 1069 bool ignoreGamma) const; | 1048 bool ignoreGamma) const; |
| 1070 | 1049 |
| 1071 void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatr
ix* deviceMatrix, | 1050 void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatr
ix* deviceMatrix, |
| 1072 void (*proc)(SkTypeface*, const SkDescriptor*, void*), | 1051 void (*proc)(SkTypeface*, const SkDescriptor*, void*), |
| 1073 void* context, bool ignoreGamma = false) const; | 1052 void* context, bool ignoreGamma = false) const; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 friend class SkCanonicalizePaint; | 1106 friend class SkCanonicalizePaint; |
| 1128 | 1107 |
| 1129 #ifdef SK_BUILD_FOR_ANDROID | 1108 #ifdef SK_BUILD_FOR_ANDROID |
| 1130 // In order for the == operator to work properly this must be the last field | 1109 // In order for the == operator to work properly this must be the last field |
| 1131 // in the struct so that we can do a memcmp to this field's offset. | 1110 // in the struct so that we can do a memcmp to this field's offset. |
| 1132 uint32_t fGenerationID; | 1111 uint32_t fGenerationID; |
| 1133 #endif | 1112 #endif |
| 1134 }; | 1113 }; |
| 1135 | 1114 |
| 1136 #endif | 1115 #endif |
| OLD | NEW |