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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 } | 1284 } |
1285 if (paint.getColorFilter()) { | 1285 if (paint.getColorFilter()) { |
1286 c = paint.getColorFilter()->filterColor(c); | 1286 c = paint.getColorFilter()->filterColor(c); |
1287 } | 1287 } |
1288 if (color) { | 1288 if (color) { |
1289 *color = c; | 1289 *color = c; |
1290 } | 1290 } |
1291 return true; | 1291 return true; |
1292 } | 1292 } |
1293 | 1293 |
1294 static SkColor computeLuminanceColor(const SkPaint& paint) { | 1294 SkColor SkPaint::computeLuminanceColor() const { |
1295 SkColor c; | 1295 SkColor c; |
1296 if (!justAColor(paint, &c)) { | 1296 if (!justAColor(*this, &c)) { |
1297 c = SkColorSetRGB(0x7F, 0x80, 0x7F); | 1297 c = SkColorSetRGB(0x7F, 0x80, 0x7F); |
1298 } | 1298 } |
1299 return c; | 1299 return c; |
1300 } | 1300 } |
1301 | 1301 |
1302 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) | 1302 #define assert_byte(x) SkASSERT(0 == ((x) >> 8)) |
1303 | 1303 |
1304 // Beyond this size, LCD doesn't appreciably improve quality, but it always | 1304 // Beyond this size, LCD doesn't appreciably improve quality, but it always |
1305 // cost more RAM and draws slower, so we set a cap. | 1305 // cost more RAM and draws slower, so we set a cap. |
1306 #ifndef SK_MAX_SIZE_FOR_LCDTEXT | 1306 #ifndef SK_MAX_SIZE_FOR_LCDTEXT |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 flags |= SkScalerContext::kVertical_Flag; | 1456 flags |= SkScalerContext::kVertical_Flag; |
1457 } | 1457 } |
1458 if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) { | 1458 if (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) { |
1459 flags |= SkScalerContext::kGenA8FromLCD_Flag; | 1459 flags |= SkScalerContext::kGenA8FromLCD_Flag; |
1460 } | 1460 } |
1461 rec->fFlags = SkToU16(flags); | 1461 rec->fFlags = SkToU16(flags); |
1462 | 1462 |
1463 // these modify fFlags, so do them after assigning fFlags | 1463 // these modify fFlags, so do them after assigning fFlags |
1464 rec->setHinting(computeHinting(paint)); | 1464 rec->setHinting(computeHinting(paint)); |
1465 | 1465 |
1466 rec->setLuminanceColor(computeLuminanceColor(paint)); | 1466 rec->setLuminanceColor(paint.computeLuminanceColor()); |
1467 | 1467 |
1468 if (NULL == deviceProperties) { | 1468 if (NULL == deviceProperties) { |
1469 rec->setDeviceGamma(SK_GAMMA_EXPONENT); | 1469 rec->setDeviceGamma(SK_GAMMA_EXPONENT); |
1470 rec->setPaintGamma(SK_GAMMA_EXPONENT); | 1470 rec->setPaintGamma(SK_GAMMA_EXPONENT); |
1471 } else { | 1471 } else { |
1472 rec->setDeviceGamma(deviceProperties->gamma()); | 1472 rec->setDeviceGamma(deviceProperties->gamma()); |
1473 | 1473 |
1474 //For now always set the paint gamma equal to the device gamma. | 1474 //For now always set the paint gamma equal to the device gamma. |
1475 //The math in SkMaskGamma can handle them being different, | 1475 //The math in SkMaskGamma can handle them being different, |
1476 //but it requires superluminous masks when | 1476 //but it requires superluminous masks when |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 } | 2430 } |
2431 | 2431 |
2432 uint32_t SkPaint::getHash() const { | 2432 uint32_t SkPaint::getHash() const { |
2433 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2433 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2434 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2434 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2435 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2435 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2436 SkPaint_notPackedTightly); | 2436 SkPaint_notPackedTightly); |
2437 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2437 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2438 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2438 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2439 } | 2439 } |
OLD | NEW |