| 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 #include "SkPaint.h" | 8 #include "SkPaint.h" |
| 9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 static SkScalar gPaintGamma = SK_ScalarMin; | 1504 static SkScalar gPaintGamma = SK_ScalarMin; |
| 1505 static SkScalar gDeviceGamma = SK_ScalarMin; | 1505 static SkScalar gDeviceGamma = SK_ScalarMin; |
| 1506 /** | 1506 /** |
| 1507 * The caller must hold the gMaskGammaCacheMutex and continue to hold it until | 1507 * The caller must hold the gMaskGammaCacheMutex and continue to hold it until |
| 1508 * the returned SkMaskGamma pointer is refed or forgotten. | 1508 * the returned SkMaskGamma pointer is refed or forgotten. |
| 1509 */ | 1509 */ |
| 1510 static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma
, SkScalar deviceGamma) { | 1510 static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma
, SkScalar deviceGamma) { |
| 1511 gMaskGammaCacheMutex.assertHeld(); | 1511 gMaskGammaCacheMutex.assertHeld(); |
| 1512 if (0 == contrast && SK_Scalar1 == paintGamma && SK_Scalar1 == deviceGamma)
{ | 1512 if (0 == contrast && SK_Scalar1 == paintGamma && SK_Scalar1 == deviceGamma)
{ |
| 1513 if (NULL == gLinearMaskGamma) { | 1513 if (NULL == gLinearMaskGamma) { |
| 1514 gLinearMaskGamma = SkNEW(SkMaskGamma); | 1514 gLinearMaskGamma = new SkMaskGamma; |
| 1515 } | 1515 } |
| 1516 return *gLinearMaskGamma; | 1516 return *gLinearMaskGamma; |
| 1517 } | 1517 } |
| 1518 if (gContrast != contrast || gPaintGamma != paintGamma || gDeviceGamma != de
viceGamma) { | 1518 if (gContrast != contrast || gPaintGamma != paintGamma || gDeviceGamma != de
viceGamma) { |
| 1519 SkSafeUnref(gMaskGamma); | 1519 SkSafeUnref(gMaskGamma); |
| 1520 gMaskGamma = SkNEW_ARGS(SkMaskGamma, (contrast, paintGamma, deviceGamma)
); | 1520 gMaskGamma = new SkMaskGamma(contrast, paintGamma, deviceGamma); |
| 1521 gContrast = contrast; | 1521 gContrast = contrast; |
| 1522 gPaintGamma = paintGamma; | 1522 gPaintGamma = paintGamma; |
| 1523 gDeviceGamma = deviceGamma; | 1523 gDeviceGamma = deviceGamma; |
| 1524 } | 1524 } |
| 1525 return *gMaskGamma; | 1525 return *gMaskGamma; |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 /*static*/ void SkPaint::Term() { | 1528 /*static*/ void SkPaint::Term() { |
| 1529 SkAutoMutexAcquire ama(gMaskGammaCacheMutex); | 1529 SkAutoMutexAcquire ama(gMaskGammaCacheMutex); |
| 1530 | 1530 |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2427 } | 2427 } |
| 2428 | 2428 |
| 2429 uint32_t SkPaint::getHash() const { | 2429 uint32_t SkPaint::getHash() const { |
| 2430 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2430 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
| 2431 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2431 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
| 2432 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), | 2432 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), |
| 2433 "SkPaint_notPackedTightly"); | 2433 "SkPaint_notPackedTightly"); |
| 2434 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2434 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
| 2435 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2435 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
| 2436 } | 2436 } |
| OLD | NEW |