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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // discouraged. Always drawing with AA can negatively impact performance | 353 // discouraged. Always drawing with AA can negatively impact performance |
354 // though - that's why it's not always on. | 354 // though - that's why it's not always on. |
355 SkScalar widthExpansion, heightExpansion; | 355 SkScalar widthExpansion, heightExpansion; |
356 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) | 356 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) |
357 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; | 357 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total
Matrix[SkMatrix::kMSkewX]; |
358 else | 358 else |
359 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; | 359 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota
lMatrix[SkMatrix::kMScaleY]; |
360 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; | 360 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa
bs(heightExpansion) < 1; |
361 } | 361 } |
362 | 362 |
| 363 int clampedAlphaForBlending(float alpha) |
| 364 { |
| 365 if (alpha < 0) |
| 366 return 0; |
| 367 int roundedAlpha = roundf(alpha * 256); |
| 368 if (roundedAlpha > 256) |
| 369 roundedAlpha = 256; |
| 370 return roundedAlpha; |
| 371 } |
| 372 |
| 373 SkColor multiplyAlpha(SkColor color, float alpha) |
| 374 { |
| 375 return multiplyAlpha(color, clampedAlphaForBlending(alpha)); |
| 376 } |
| 377 |
| 378 SkColor multiplyAlpha(SkColor color, int alpha) |
| 379 { |
| 380 int a = (SkColorGetA(color) * alpha) >> 8; |
| 381 return (color & 0x00FFFFFF) | (a << 24); |
| 382 } |
| 383 |
363 } // namespace blink | 384 } // namespace blink |
OLD | NEW |