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 #include <vector> | 9 #include <vector> |
10 #ifdef SK_BUILD_FOR_MAC | 10 #ifdef SK_BUILD_FOR_MAC |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (sizeof(CGFloat) == sizeof(float)) { | 266 if (sizeof(CGFloat) == sizeof(float)) { |
267 return SkScalarToFloat(scalar); | 267 return SkScalarToFloat(scalar); |
268 } else { | 268 } else { |
269 SkASSERT(sizeof(CGFloat) == sizeof(double)); | 269 SkASSERT(sizeof(CGFloat) == sizeof(double)); |
270 return (CGFloat) SkScalarToDouble(scalar); | 270 return (CGFloat) SkScalarToDouble(scalar); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 static SkScalar CGToScalar(CGFloat cgFloat) { | 274 static SkScalar CGToScalar(CGFloat cgFloat) { |
275 if (sizeof(CGFloat) == sizeof(float)) { | 275 if (sizeof(CGFloat) == sizeof(float)) { |
276 return SkFloatToScalar(cgFloat); | 276 return cgFloat; |
277 } else { | 277 } else { |
278 SkASSERT(sizeof(CGFloat) == sizeof(double)); | 278 SkASSERT(sizeof(CGFloat) == sizeof(double)); |
279 return SkDoubleToScalar(cgFloat); | 279 return SkDoubleToScalar(cgFloat); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 static CGAffineTransform MatrixToCGAffineTransform(const SkMatrix& matrix, | 283 static CGAffineTransform MatrixToCGAffineTransform(const SkMatrix& matrix, |
284 SkScalar sx = SK_Scalar1, | 284 SkScalar sx = SK_Scalar1, |
285 SkScalar sy = SK_Scalar1) { | 285 SkScalar sy = SK_Scalar1) { |
286 return CGAffineTransformMake( ScalarToCG(matrix[SkMatrix::kMScaleX] * sx), | 286 return CGAffineTransformMake( ScalarToCG(matrix[SkMatrix::kMScaleX] * sx), |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 glyph->fMaskFormat = SkMask::kARGB32_Format; | 1068 glyph->fMaskFormat = SkMask::kARGB32_Format; |
1069 #endif | 1069 #endif |
1070 } | 1070 } |
1071 | 1071 |
1072 #include "SkColorPriv.h" | 1072 #include "SkColorPriv.h" |
1073 | 1073 |
1074 static void build_power_table(uint8_t table[], float ee) { | 1074 static void build_power_table(uint8_t table[], float ee) { |
1075 for (int i = 0; i < 256; i++) { | 1075 for (int i = 0; i < 256; i++) { |
1076 float x = i / 255.f; | 1076 float x = i / 255.f; |
1077 x = sk_float_pow(x, ee); | 1077 x = sk_float_pow(x, ee); |
1078 int xx = SkScalarRoundToInt(SkFloatToScalar(x * 255)); | 1078 int xx = SkScalarRoundToInt(x * 255); |
1079 table[i] = SkToU8(xx); | 1079 table[i] = SkToU8(xx); |
1080 } | 1080 } |
1081 } | 1081 } |
1082 | 1082 |
1083 /** | 1083 /** |
1084 * This will invert the gamma applied by CoreGraphics, so we can get linear | 1084 * This will invert the gamma applied by CoreGraphics, so we can get linear |
1085 * values. | 1085 * values. |
1086 * | 1086 * |
1087 * CoreGraphics obscurely defaults to 2.0 as the smoothing gamma value. | 1087 * CoreGraphics obscurely defaults to 2.0 as the smoothing gamma value. |
1088 * The color space used does not appear to affect this choice. | 1088 * The color space used does not appear to affect this choice. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 * we want to retain hinting in the direction orthogonal to the baseline. | 1318 * we want to retain hinting in the direction orthogonal to the baseline. |
1319 * e.g. for horizontal baseline, we want to retain hinting in Y. | 1319 * e.g. for horizontal baseline, we want to retain hinting in Y. |
1320 * The way we remove hinting is to scale the font by some value (4) in that | 1320 * The way we remove hinting is to scale the font by some value (4) in that |
1321 * direction, ask for the path, and then scale the path back down. | 1321 * direction, ask for the path, and then scale the path back down. |
1322 */ | 1322 */ |
1323 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { | 1323 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { |
1324 SkMatrix m; | 1324 SkMatrix m; |
1325 fRec.getSingleMatrix(&m); | 1325 fRec.getSingleMatrix(&m); |
1326 | 1326 |
1327 // start out by assuming that we want no hining in X and Y | 1327 // start out by assuming that we want no hining in X and Y |
1328 scaleX = scaleY = SkFloatToScalar(kScaleForSubPixelPositionHinting); | 1328 scaleX = scaleY = kScaleForSubPixelPositionHinting; |
1329 // now see if we need to restore hinting for axis-aligned baselines | 1329 // now see if we need to restore hinting for axis-aligned baselines |
1330 switch (SkComputeAxisAlignmentForHText(m)) { | 1330 switch (SkComputeAxisAlignmentForHText(m)) { |
1331 case kX_SkAxisAlignment: | 1331 case kX_SkAxisAlignment: |
1332 scaleY = SK_Scalar1; // want hinting in the Y direction | 1332 scaleY = SK_Scalar1; // want hinting in the Y direction |
1333 break; | 1333 break; |
1334 case kY_SkAxisAlignment: | 1334 case kY_SkAxisAlignment: |
1335 scaleX = SK_Scalar1; // want hinting in the X direction | 1335 scaleX = SK_Scalar1; // want hinting in the X direction |
1336 break; | 1336 break; |
1337 default: | 1337 default: |
1338 break; | 1338 break; |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2307 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
2308 } | 2308 } |
2309 }; | 2309 }; |
2310 | 2310 |
2311 /////////////////////////////////////////////////////////////////////////////// | 2311 /////////////////////////////////////////////////////////////////////////////// |
2312 | 2312 |
2313 SkFontMgr* SkFontMgr::Factory() { | 2313 SkFontMgr* SkFontMgr::Factory() { |
2314 return SkNEW(SkFontMgr_Mac); | 2314 return SkNEW(SkFontMgr_Mac); |
2315 } | 2315 } |
2316 #endif | 2316 #endif |
OLD | NEW |