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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 SkRect bounds; | 1236 SkRect bounds; |
1237 m.mapRect(&bounds, typeface->getBounds()); | 1237 m.mapRect(&bounds, typeface->getBounds()); |
1238 return bounds; | 1238 return bounds; |
1239 } | 1239 } |
1240 | 1240 |
1241 static void add_flattenable(SkDescriptor* desc, uint32_t tag, | 1241 static void add_flattenable(SkDescriptor* desc, uint32_t tag, |
1242 SkWriteBuffer* buffer) { | 1242 SkWriteBuffer* buffer) { |
1243 buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL)); | 1243 buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL)); |
1244 } | 1244 } |
1245 | 1245 |
1246 static SkMask::Format computeMaskFormat(const SkPaint& paint) { | 1246 static SkMask::Format compute_mask_format(const SkPaint& paint) { |
1247 uint32_t flags = paint.getFlags(); | 1247 uint32_t flags = paint.getFlags(); |
1248 | 1248 |
1249 // Antialiasing being disabled trumps all other settings. | 1249 // Antialiasing being disabled trumps all other settings. |
1250 if (!(flags & SkPaint::kAntiAlias_Flag)) { | 1250 if (!(flags & SkPaint::kAntiAlias_Flag)) { |
1251 return SkMask::kBW_Format; | 1251 return SkMask::kBW_Format; |
1252 } | 1252 } |
1253 | 1253 |
1254 if (flags & SkPaint::kLCDRenderText_Flag) { | 1254 if (flags & SkPaint::kLCDRenderText_Flag) { |
1255 return SkMask::kLCD16_Format; | 1255 return SkMask::kLCD16_Format; |
1256 } | 1256 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 | 1398 |
1399 if (style == SkPaint::kStrokeAndFill_Style) { | 1399 if (style == SkPaint::kStrokeAndFill_Style) { |
1400 flags |= SkScalerContext::kFrameAndFill_Flag; | 1400 flags |= SkScalerContext::kFrameAndFill_Flag; |
1401 } | 1401 } |
1402 } else { | 1402 } else { |
1403 rec->fFrameWidth = 0; | 1403 rec->fFrameWidth = 0; |
1404 rec->fMiterLimit = 0; | 1404 rec->fMiterLimit = 0; |
1405 rec->fStrokeJoin = 0; | 1405 rec->fStrokeJoin = 0; |
1406 } | 1406 } |
1407 | 1407 |
1408 rec->fMaskFormat = SkToU8(computeMaskFormat(paint)); | 1408 rec->fMaskFormat = SkToU8(compute_mask_format(paint)); |
1409 | 1409 |
1410 if (SkMask::kLCD16_Format == rec->fMaskFormat) { | 1410 if (SkMask::kLCD16_Format == rec->fMaskFormat) { |
1411 if (too_big_for_lcd(*rec, checkPost2x2)) { | 1411 if (too_big_for_lcd(*rec, checkPost2x2)) { |
1412 rec->fMaskFormat = SkMask::kA8_Format; | 1412 rec->fMaskFormat = SkMask::kA8_Format; |
1413 flags |= SkScalerContext::kGenA8FromLCD_Flag; | 1413 flags |= SkScalerContext::kGenA8FromLCD_Flag; |
1414 } else { | 1414 } else { |
1415 SkPixelGeometry geometry = surfaceProps | 1415 SkPixelGeometry geometry = surfaceProps |
1416 ? surfaceProps->pixelGeometry() | 1416 ? surfaceProps->pixelGeometry() |
1417 : SkSurfacePropsDefaultPixelGeometry(); | 1417 : SkSurfacePropsDefaultPixelGeometry(); |
1418 switch (geometry) { | 1418 switch (geometry) { |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 } | 2417 } |
2418 | 2418 |
2419 uint32_t SkPaint::getHash() const { | 2419 uint32_t SkPaint::getHash() const { |
2420 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2420 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2421 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2421 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2422 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2422 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2423 SkPaint_notPackedTightly); | 2423 SkPaint_notPackedTightly); |
2424 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2424 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2425 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2425 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2426 } | 2426 } |
OLD | NEW |