| OLD | NEW | 
|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3  * Copyright 2012 Google Inc. | 3  * Copyright 2012 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 | 8 | 
| 9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" | 
| 10 | 10 | 
| 11 static inline int repeat_bits(int x, const int bits) { | 11 static inline int repeat_bits(int x, const int bits) { | 
| 12     return x & ((1 << bits) - 1); | 12     return x & ((1 << bits) - 1); | 
| 13 } | 13 } | 
| 14 | 14 | 
| 15 static inline int repeat_8bits(int x) { | 15 static inline int repeat_8bits(int x) { | 
| 16     return x & 0xFF; | 16     return x & 0xFF; | 
| 17 } | 17 } | 
| 18 | 18 | 
| 19 // Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly. | 19 // Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly. | 
| 20 // See http://code.google.com/p/skia/issues/detail?id=472 | 20 // See http://code.google.com/p/skia/issues/detail?id=472 | 
| 21 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | 21 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | 
| 22 #pragma optimize("", off) | 22 #pragma optimize("", off) | 
| 23 #endif | 23 #endif | 
| 24 | 24 | 
| 25 static inline int mirror_bits(int x, const int bits) { | 25 static inline int mirror_bits(int x, const int bits) { | 
| 26 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | 26     if (x & (1 << bits)) { | 
| 27     if (x & (1 << bits)) |  | 
| 28         x = ~x; | 27         x = ~x; | 
|  | 28     } | 
| 29     return x & ((1 << bits) - 1); | 29     return x & ((1 << bits) - 1); | 
| 30 #else |  | 
| 31     int s = x << (31 - bits) >> 31; |  | 
| 32     return (x ^ s) & ((1 << bits) - 1); |  | 
| 33 #endif |  | 
| 34 } | 30 } | 
| 35 | 31 | 
| 36 static inline int mirror_8bits(int x) { | 32 static inline int mirror_8bits(int x) { | 
| 37 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR |  | 
| 38     if (x & 256) { | 33     if (x & 256) { | 
| 39         x = ~x; | 34         x = ~x; | 
| 40     } | 35     } | 
| 41     return x & 255; | 36     return x & 255; | 
| 42 #else |  | 
| 43     int s = x << 23 >> 31; |  | 
| 44     return (x ^ s) & 0xFF; |  | 
| 45 #endif |  | 
| 46 } | 37 } | 
| 47 | 38 | 
| 48 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | 39 #if defined(_MSC_VER) && (_MSC_VER >= 1600) | 
| 49 #pragma optimize("", on) | 40 #pragma optimize("", on) | 
| 50 #endif | 41 #endif | 
| 51 | 42 | 
| 52 static void pts_to_unit_matrix(const SkPoint pts[2], SkMatrix* matrix) { | 43 static void pts_to_unit_matrix(const SkPoint pts[2], SkMatrix* matrix) { | 
| 53     SkVector    vec = pts[1] - pts[0]; | 44     SkVector    vec = pts[1] - pts[0]; | 
| 54     SkScalar    mag = vec.length(); | 45     SkScalar    mag = vec.length(); | 
| 55     SkScalar    inv = mag ? SkScalarInvert(mag) : 0; | 46     SkScalar    inv = mag ? SkScalarInvert(mag) : 0; | 
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 568     str->append("SkLinearGradient ("); | 559     str->append("SkLinearGradient ("); | 
| 569 | 560 | 
| 570     str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 561     str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 
| 571     str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 562     str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 
| 572 | 563 | 
| 573     this->INHERITED::toString(str); | 564     this->INHERITED::toString(str); | 
| 574 | 565 | 
| 575     str->append(")"); | 566     str->append(")"); | 
| 576 } | 567 } | 
| 577 #endif | 568 #endif | 
| OLD | NEW | 
|---|