OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Scale the path to a large size before hit testing for two reasons: | 140 // Scale the path to a large size before hit testing for two reasons: |
141 // 1) Skia has trouble with coordinates close to the max signed 16-bit value
s, so we scale larger paths down. | 141 // 1) Skia has trouble with coordinates close to the max signed 16-bit value
s, so we scale larger paths down. |
142 // TODO: when Skia is patched to work properly with large values, this wi
ll not be necessary. | 142 // TODO: when Skia is patched to work properly with large values, this wi
ll not be necessary. |
143 // 2) Skia does not support analytic hit testing, so we scale paths up to do
raster hit testing with subpixel accuracy. | 143 // 2) Skia does not support analytic hit testing, so we scale paths up to do
raster hit testing with subpixel accuracy. |
144 SkScalar biggestCoord = std::max(std::max(std::max(bounds.fRight, bounds.fBo
ttom), -bounds.fLeft), -bounds.fTop); | 144 SkScalar biggestCoord = std::max(std::max(std::max(bounds.fRight, bounds.fBo
ttom), -bounds.fLeft), -bounds.fTop); |
145 if (SkScalarNearlyZero(biggestCoord)) | 145 if (SkScalarNearlyZero(biggestCoord)) |
146 return false; | 146 return false; |
147 biggestCoord = std::max(std::max(biggestCoord, fX + 1), fY + 1); | 147 biggestCoord = std::max(std::max(biggestCoord, fX + 1), fY + 1); |
148 | 148 |
149 const SkScalar kMaxCoordinate = SkIntToScalar(1 << 15); | 149 const SkScalar kMaxCoordinate = SkIntToScalar(1 << 15); |
150 SkScalar scale = SkScalarDiv(kMaxCoordinate, biggestCoord); | 150 SkScalar scale = kMaxCoordinate / biggestCoord; |
151 | 151 |
152 SkRegion rgn; | 152 SkRegion rgn; |
153 SkRegion clip; | 153 SkRegion clip; |
154 SkMatrix m; | 154 SkMatrix m; |
155 SkPath scaledPath(originalPath); | 155 SkPath scaledPath(originalPath); |
156 | 156 |
157 scaledPath.setFillType(ft); | 157 scaledPath.setFillType(ft); |
158 m.setScale(scale, scale); | 158 m.setScale(scale, scale); |
159 scaledPath.transform(m, 0); | 159 scaledPath.transform(m, 0); |
160 | 160 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // though - that's why it's not always on. | 307 // though - that's why it's not always on. |
308 SkScalar widthExpansion, heightExpansion; | 308 SkScalar widthExpansion, heightExpansion; |
309 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) | 309 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) |
310 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; | 310 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; |
311 else | 311 else |
312 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; | 312 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; |
313 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; | 313 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; |
314 } | 314 } |
315 | 315 |
316 } // namespace blink | 316 } // namespace blink |
OLD | NEW |