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 SkScalerContext_DEFINED | 8 #ifndef SkScalerContext_DEFINED |
9 #define SkScalerContext_DEFINED | 9 #define SkScalerContext_DEFINED |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // must be a multiple of 4. SkDescriptor requires that its arguments be | 79 // must be a multiple of 4. SkDescriptor requires that its arguments be |
80 // multiples of four and this structure is put in an SkDescriptor in | 80 // multiples of four and this structure is put in an SkDescriptor in |
81 // SkPaint::MakeRec. | 81 // SkPaint::MakeRec. |
82 | 82 |
83 void getMatrixFrom2x2(SkMatrix*) const; | 83 void getMatrixFrom2x2(SkMatrix*) const; |
84 void getLocalMatrix(SkMatrix*) const; | 84 void getLocalMatrix(SkMatrix*) const; |
85 void getLocalMatrixWithoutTextSize(SkMatrix*) const; | 85 void getLocalMatrixWithoutTextSize(SkMatrix*) const; |
86 void getSingleMatrix(SkMatrix*) const; | 86 void getSingleMatrix(SkMatrix*) const; |
87 void getSingleMatrixWithoutTextSize(SkMatrix*) const; | 87 void getSingleMatrixWithoutTextSize(SkMatrix*) const; |
88 | 88 |
| 89 /** The kind of scale which will be applied by the underlying port (pre-matr
ix). */ |
| 90 enum PreMatrixScale { |
| 91 kFull_PreMatrixScale, // The underlying port can apply both x and y sca
le. |
| 92 kVertical_PreMatrixScale, // The underlying port can only apply a y sca
le. |
| 93 kVerticalInteger_PreMatrixScale // The underlying port can only apply a
n integer y scale. |
| 94 }; |
| 95 /** |
| 96 * Compute useful matrices for use with sizing in underlying libraries. |
| 97 * |
| 98 * There are two kinds of text size, a 'requested/logical size' which is li
ke asking for size |
| 99 * '12' and a 'real' size which is the size after the matrix is applied. Th
e matrices produced |
| 100 * by this method are based on the 'real' size. This method effectively fin
ds the total device |
| 101 * matrix and decomposes it in various ways. |
| 102 * |
| 103 * The most useful decomposition is into 'scale' and 'remaining'. The 'scal
e' is applied first |
| 104 * and then the 'remaining' to fully apply the total matrix. This decomposi
tion is useful when |
| 105 * the text size ('scale') may have meaning apart from the total matrix. Th
is is true when |
| 106 * hinting, and sometimes true for other properties as well. |
| 107 * |
| 108 * The second (optional) decomposition is of 'remaining' into a non-rotatio
nal part |
| 109 * 'remainingWithoutRotation' and a rotational part 'remainingRotation'. Th
e 'scale' is applied |
| 110 * first, then 'remainingWithoutRotation', then 'remainingRotation' to full
y apply the total |
| 111 * matrix. This decomposition is helpful when only horizontal metrics can b
e trusted, so the |
| 112 * 'scale' and 'remainingWithoutRotation' will be handled by the underlying
library, but |
| 113 * the final rotation 'remainingRotation' will be handled manually. |
| 114 * |
| 115 * The 'total' matrix is also (optionally) available. This is useful in cas
es where the |
| 116 * underlying library will not be used, often when working directly with fo
nt data. |
| 117 * |
| 118 * The parameters 'scale' and 'remaining' are required, the other pointers
may be NULL. |
| 119 * |
| 120 * @param preMatrixScale the kind of scale to extract from the total matrix
. |
| 121 * @param scale the scale extracted from the total matrix (both values posi
tive). |
| 122 * @param remaining apply after scale to apply the total matrix. |
| 123 * @param remainingWithoutRotation apply after scale to apply the total mat
rix sans rotation. |
| 124 * @param remainingRotation apply after remainingWithoutRotation to apply t
he total matrix. |
| 125 * @param total the total matrix. |
| 126 */ |
| 127 void computeMatrices(PreMatrixScale preMatrixScale, |
| 128 SkVector* scale, SkMatrix* remaining, |
| 129 SkMatrix* remainingWithoutRotation = NULL, |
| 130 SkMatrix* remainingRotation = NULL, |
| 131 SkMatrix* total = NULL); |
| 132 |
89 inline SkPaint::Hinting getHinting() const; | 133 inline SkPaint::Hinting getHinting() const; |
90 inline void setHinting(SkPaint::Hinting); | 134 inline void setHinting(SkPaint::Hinting); |
91 | 135 |
92 SkMask::Format getFormat() const { | 136 SkMask::Format getFormat() const { |
93 return static_cast<SkMask::Format>(fMaskFormat); | 137 return static_cast<SkMask::Format>(fMaskFormat); |
94 } | 138 } |
95 | 139 |
96 SkColor getLuminanceColor() const { | 140 SkColor getLuminanceColor() const { |
97 return fLumBits; | 141 return fLumBits; |
98 } | 142 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return static_cast<SkPaint::Hinting>(hint); | 359 return static_cast<SkPaint::Hinting>(hint); |
316 } | 360 } |
317 | 361 |
318 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { | 362 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { |
319 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | | 363 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | |
320 (hinting << SkScalerContext::kHinting_Shift); | 364 (hinting << SkScalerContext::kHinting_Shift); |
321 } | 365 } |
322 | 366 |
323 | 367 |
324 #endif | 368 #endif |
OLD | NEW |