OLD | NEW |
---|---|
1 | 1 |
2 | 2 |
3 /* | 3 /* |
4 * Copyright 2006 The Android Open Source Project | 4 * Copyright 2006 The Android Open Source Project |
5 * | 5 * |
6 * Use of this source code is governed by a BSD-style license that can be | 6 * Use of this source code is governed by a BSD-style license that can be |
7 * found in the LICENSE file. | 7 * found in the LICENSE file. |
8 */ | 8 */ |
9 | 9 |
10 | 10 |
11 #ifndef SkPaint_DEFINED | 11 #ifndef SkPaint_DEFINED |
12 #define SkPaint_DEFINED | 12 #define SkPaint_DEFINED |
13 | 13 |
14 #include "SkColor.h" | 14 #include "SkColor.h" |
15 #include "SkDrawLooper.h" | 15 #include "SkDrawLooper.h" |
16 #include "SkMatrix.h" | |
16 #include "SkXfermode.h" | 17 #include "SkXfermode.h" |
17 #ifdef SK_BUILD_FOR_ANDROID | 18 #ifdef SK_BUILD_FOR_ANDROID |
18 #include "SkPaintOptionsAndroid.h" | 19 #include "SkPaintOptionsAndroid.h" |
19 #endif | 20 #endif |
20 | 21 |
21 class SkAnnotation; | 22 class SkAnnotation; |
22 class SkAutoGlyphCache; | 23 class SkAutoGlyphCache; |
23 class SkColorFilter; | 24 class SkColorFilter; |
24 class SkDescriptor; | 25 class SkDescriptor; |
25 struct SkDeviceProperties; | 26 struct SkDeviceProperties; |
26 class SkFlattenableReadBuffer; | 27 class SkFlattenableReadBuffer; |
27 class SkFlattenableWriteBuffer; | 28 class SkFlattenableWriteBuffer; |
28 struct SkGlyph; | 29 struct SkGlyph; |
29 struct SkRect; | 30 struct SkRect; |
30 class SkGlyphCache; | 31 class SkGlyphCache; |
31 class SkImageFilter; | 32 class SkImageFilter; |
32 class SkMaskFilter; | 33 class SkMaskFilter; |
33 class SkMatrix; | |
34 class SkPath; | 34 class SkPath; |
35 class SkPathEffect; | 35 class SkPathEffect; |
36 struct SkPoint; | 36 struct SkPoint; |
37 class SkRasterizer; | 37 class SkRasterizer; |
38 class SkShader; | 38 class SkShader; |
39 class SkTypeface; | 39 class SkTypeface; |
40 | 40 |
41 typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, | 41 typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, |
42 SkFixed x, SkFixed y); | 42 SkFixed x, SkFixed y); |
43 | 43 |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 const SkRect& computeFastStrokeBounds(const SkRect& orig, | 928 const SkRect& computeFastStrokeBounds(const SkRect& orig, |
929 SkRect* storage) const { | 929 SkRect* storage) const { |
930 return this->doComputeFastBounds(orig, storage, kStroke_Style); | 930 return this->doComputeFastBounds(orig, storage, kStroke_Style); |
931 } | 931 } |
932 | 932 |
933 // Take the style explicitly, so the caller can force us to be stroked | 933 // Take the style explicitly, so the caller can force us to be stroked |
934 // without having to make a copy of the paint just to change that field. | 934 // without having to make a copy of the paint just to change that field. |
935 const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, | 935 const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, |
936 Style) const; | 936 Style) const; |
937 | 937 |
938 /** | |
939 * Return a matrix that applies the paint's text values: size, scale, skew | |
940 */ | |
941 static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size, | |
942 SkScalar scaleX, SkScalar skewX) { | |
943 matrix->setScale(size * scaleX, size); | |
944 if (skewX) { | |
945 matrix->postSkew(skewX, 0); | |
946 } | |
947 return matrix; | |
948 } | |
949 | |
950 SkMatrix* setTextMatrix(SkMatrix* matrix) const { | |
951 return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); | |
952 } | |
953 | |
938 SkDEVCODE(void toString(SkString*) const;) | 954 SkDEVCODE(void toString(SkString*) const;) |
939 | 955 |
940 private: | 956 private: |
941 SkTypeface* fTypeface; | 957 SkTypeface* fTypeface; |
942 SkScalar fTextSize; | 958 SkScalar fTextSize; |
943 SkScalar fTextScaleX; | 959 SkScalar fTextScaleX; |
944 SkScalar fTextSkewX; | 960 SkScalar fTextSkewX; |
945 #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR | 961 #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR |
946 SkScalar fHintingScaleFactor; | 962 SkScalar fHintingScaleFactor; |
947 #endif | 963 #endif |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 | 998 |
983 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*) const; | 999 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*) const; |
984 | 1000 |
985 void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatr ix* deviceMatrix, | 1001 void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatr ix* deviceMatrix, |
986 void (*proc)(SkTypeface*, const SkDescriptor*, void*), | 1002 void (*proc)(SkTypeface*, const SkDescriptor*, void*), |
987 void* context, bool ignoreGamma = false) const; | 1003 void* context, bool ignoreGamma = false) const; |
988 | 1004 |
989 static void Term(); | 1005 static void Term(); |
990 | 1006 |
991 enum { | 1007 enum { |
992 kCanonicalTextSizeForPaths = 64 | 1008 /* This is the size we use when we ask for a glyph's path. We then |
1009 * post-transform it as we draw to match the request. | |
1010 * This is done to try to re-use cache entries for the path. | |
1011 */ | |
1012 kCanonicalTextSizeForPaths = 64, | |
1013 | |
1014 /* | |
1015 * Above this size (taking into account CTM and textSize), we never use | |
1016 * the cache for bits or metrics (we might overflow), so we just ask | |
1017 * for a caononical size and post-transform that. | |
1018 */ | |
1019 kMaxSizeForGlyphCache = 256, | |
bungeman-skia
2013/06/04 14:27:58
It seems odd that these two numbers would be diffe
reed1
2013/06/04 15:58:22
update comment.
| |
993 }; | 1020 }; |
1021 | |
1022 static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM); | |
1023 | |
1024 bool tooBigToUseCache() const; | |
1025 bool tooBigToUseCache(const SkMatrix& ctm) const; | |
1026 | |
1027 static SkScalar MaxCacheSize2() { | |
1028 static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache); | |
1029 static const SkScalar kMag2Max = kMaxSize * kMaxSize; | |
1030 return kMag2Max; | |
1031 } | |
1032 | |
994 friend class SkAutoGlyphCache; | 1033 friend class SkAutoGlyphCache; |
995 friend class SkCanvas; | 1034 friend class SkCanvas; |
996 friend class SkDraw; | 1035 friend class SkDraw; |
997 friend class SkGraphics; // So Term() can be called. | 1036 friend class SkGraphics; // So Term() can be called. |
998 friend class SkPDFDevice; | 1037 friend class SkPDFDevice; |
999 friend class SkTextToPathIter; | 1038 friend class SkTextToPathIter; |
1000 | 1039 |
1001 #ifdef SK_BUILD_FOR_ANDROID | 1040 #ifdef SK_BUILD_FOR_ANDROID |
1002 SkPaintOptionsAndroid fPaintOptionsAndroid; | 1041 SkPaintOptionsAndroid fPaintOptionsAndroid; |
1003 | 1042 |
1004 // In order for the == operator to work properly this must be the last field | 1043 // In order for the == operator to work properly this must be the last field |
1005 // in the struct so that we can do a memcmp to this field's offset. | 1044 // in the struct so that we can do a memcmp to this field's offset. |
1006 uint32_t fGenerationID; | 1045 uint32_t fGenerationID; |
1007 #endif | 1046 #endif |
1008 }; | 1047 }; |
1009 | 1048 |
1010 #endif | 1049 #endif |
OLD | NEW |