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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 SkTLazy<SkPaint> fLazy; | 797 SkTLazy<SkPaint> fLazy; |
798 }; | 798 }; |
799 | 799 |
800 static void set_bounds(const SkGlyph& g, SkRect* bounds) { | 800 static void set_bounds(const SkGlyph& g, SkRect* bounds) { |
801 bounds->set(SkIntToScalar(g.fLeft), | 801 bounds->set(SkIntToScalar(g.fLeft), |
802 SkIntToScalar(g.fTop), | 802 SkIntToScalar(g.fTop), |
803 SkIntToScalar(g.fLeft + g.fWidth), | 803 SkIntToScalar(g.fLeft + g.fWidth), |
804 SkIntToScalar(g.fTop + g.fHeight)); | 804 SkIntToScalar(g.fTop + g.fHeight)); |
805 } | 805 } |
806 | 806 |
807 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so | |
808 // we don't overflow along the way | |
809 typedef int64_t Sk48Dot16; | |
810 | |
811 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { | |
812 return (float) (x * 1.5258789e-5); // x * (1 / 65536.0f) | |
813 } | |
814 | |
815 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) { | 807 static void join_bounds_x(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dx) { |
816 SkScalar sx = Sk48Dot16ToScalar(dx); | 808 SkScalar sx = Sk48Dot16ToScalar(dx); |
817 bounds->join(SkIntToScalar(g.fLeft) + sx, | 809 bounds->join(SkIntToScalar(g.fLeft) + sx, |
818 SkIntToScalar(g.fTop), | 810 SkIntToScalar(g.fTop), |
819 SkIntToScalar(g.fLeft + g.fWidth) + sx, | 811 SkIntToScalar(g.fLeft + g.fWidth) + sx, |
820 SkIntToScalar(g.fTop + g.fHeight)); | 812 SkIntToScalar(g.fTop + g.fHeight)); |
821 } | 813 } |
822 | 814 |
823 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) { | 815 static void join_bounds_y(const SkGlyph& g, SkRect* bounds, Sk48Dot16 dy) { |
824 SkScalar sy = Sk48Dot16ToScalar(dy); | 816 SkScalar sy = Sk48Dot16ToScalar(dy); |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 } | 2376 } |
2385 | 2377 |
2386 uint32_t SkPaint::getHash() const { | 2378 uint32_t SkPaint::getHash() const { |
2387 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2379 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2388 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2380 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2389 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2381 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2390 SkPaint_notPackedTightly); | 2382 SkPaint_notPackedTightly); |
2391 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2383 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2392 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2384 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2393 } | 2385 } |
OLD | NEW |