OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkUnitMappers.h" | 8 #include "SkUnitMappers.h" |
9 #include "SkFlattenableBuffers.h" | 9 #include "SkFlattenableBuffers.h" |
10 | 10 |
11 SK_DEFINE_INST_COUNT(SkUnitMapper) | |
12 | |
13 SkDiscreteMapper::SkDiscreteMapper(int segments) { | 11 SkDiscreteMapper::SkDiscreteMapper(int segments) { |
14 if (segments < 2) { | 12 if (segments < 2) { |
15 fSegments = 0; | 13 fSegments = 0; |
16 fScale = 0; | 14 fScale = 0; |
17 } else { | 15 } else { |
18 if (segments > 0xFFFF) { | 16 if (segments > 0xFFFF) { |
19 segments = 0xFFFF; | 17 segments = 0xFFFF; |
20 } | 18 } |
21 fSegments = segments; | 19 fSegments = segments; |
22 fScale = SK_Fract1 / (segments - 1); | 20 fScale = SK_Fract1 / (segments - 1); |
(...skipping 29 matching lines...) Expand all Loading... |
52 16bits and pi/2 is 17bits, so we shift down our pi const before we mul | 50 16bits and pi/2 is 17bits, so we shift down our pi const before we mul |
53 */ | 51 */ |
54 SkFixed rads = (unsigned)(input * (SK_FixedPI >> 2)) >> 15; | 52 SkFixed rads = (unsigned)(input * (SK_FixedPI >> 2)) >> 15; |
55 SkFixed x = SkFixedCos(rads); | 53 SkFixed x = SkFixedCos(rads); |
56 x += x << 15 >> 31; // map 0x10000 to 0xFFFF | 54 x += x << 15 >> 31; // map 0x10000 to 0xFFFF |
57 return SkToU16(x); | 55 return SkToU16(x); |
58 } | 56 } |
59 | 57 |
60 SkCosineMapper::SkCosineMapper(SkFlattenableReadBuffer& rb) | 58 SkCosineMapper::SkCosineMapper(SkFlattenableReadBuffer& rb) |
61 : SkUnitMapper(rb) {} | 59 : SkUnitMapper(rb) {} |
OLD | NEW |