| 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 "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
| 9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
| 10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 b += db; | 477 b += db; |
| 478 } while (--count != 0); | 478 } while (--count != 0); |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 static inline int SkFixedToFFFF(SkFixed x) { | 482 static inline int SkFixedToFFFF(SkFixed x) { |
| 483 SkASSERT((unsigned)x <= SK_Fixed1); | 483 SkASSERT((unsigned)x <= SK_Fixed1); |
| 484 return x - (x >> 16); | 484 return x - (x >> 16); |
| 485 } | 485 } |
| 486 | 486 |
| 487 static inline U16CPU bitsTo16(unsigned x, const unsigned bits) { |
| 488 SkASSERT(x < (1U << bits)); |
| 489 if (6 == bits) { |
| 490 return (x << 10) | (x << 4) | (x >> 2); |
| 491 } |
| 492 if (8 == bits) { |
| 493 return (x << 8) | x; |
| 494 } |
| 495 sk_throw(); |
| 496 return 0; |
| 497 } |
| 498 |
| 487 const uint16_t* SkGradientShaderBase::GradientShaderCache::getCache16() { | 499 const uint16_t* SkGradientShaderBase::GradientShaderCache::getCache16() { |
| 488 SkOnce(&fCache16Inited, &fCache16Mutex, SkGradientShaderBase::GradientShader
Cache::initCache16, | 500 SkOnce(&fCache16Inited, &fCache16Mutex, SkGradientShaderBase::GradientShader
Cache::initCache16, |
| 489 this); | 501 this); |
| 490 SkASSERT(fCache16); | 502 SkASSERT(fCache16); |
| 491 return fCache16; | 503 return fCache16; |
| 492 } | 504 } |
| 493 | 505 |
| 494 void SkGradientShaderBase::GradientShaderCache::initCache16(GradientShaderCache*
cache) { | 506 void SkGradientShaderBase::GradientShaderCache::initCache16(GradientShaderCache*
cache) { |
| 495 // double the count for dither entries | 507 // double the count for dither entries |
| 496 const int entryCount = kCache16Count * 2; | 508 const int entryCount = kCache16Count * 2; |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 (*stops)[i] = stop; | 1161 (*stops)[i] = stop; |
| 1150 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1162 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1151 } | 1163 } |
| 1152 } | 1164 } |
| 1153 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1165 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1154 | 1166 |
| 1155 return outColors; | 1167 return outColors; |
| 1156 } | 1168 } |
| 1157 | 1169 |
| 1158 #endif | 1170 #endif |
| OLD | NEW |