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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 } | 615 } |
616 | 616 |
617 const SkPMColor* SkGradientShaderBase::GradientShaderCache::getCache32() { | 617 const SkPMColor* SkGradientShaderBase::GradientShaderCache::getCache32() { |
618 SkOnce(&fCache32Inited, &fCache32Mutex, SkGradientShaderBase::GradientShader
Cache::initCache32, | 618 SkOnce(&fCache32Inited, &fCache32Mutex, SkGradientShaderBase::GradientShader
Cache::initCache32, |
619 this); | 619 this); |
620 SkASSERT(fCache32); | 620 SkASSERT(fCache32); |
621 return fCache32; | 621 return fCache32; |
622 } | 622 } |
623 | 623 |
624 void SkGradientShaderBase::GradientShaderCache::initCache32(GradientShaderCache*
cache) { | 624 void SkGradientShaderBase::GradientShaderCache::initCache32(GradientShaderCache*
cache) { |
625 SkImageInfo info; | 625 const int kNumberOfDitherRows = 4; |
626 info.fWidth = kCache32Count; | 626 const SkImageInfo info = SkImageInfo::MakeN32Premul(kCache32Count, kNumberOf
DitherRows); |
627 info.fHeight = 4; // for our 4 dither rows | |
628 info.fAlphaType = kPremul_SkAlphaType; | |
629 info.fColorType = kN32_SkColorType; | |
630 | 627 |
631 SkASSERT(NULL == cache->fCache32PixelRef); | 628 SkASSERT(NULL == cache->fCache32PixelRef); |
632 cache->fCache32PixelRef = SkMallocPixelRef::NewAllocate(info, 0, NULL); | 629 cache->fCache32PixelRef = SkMallocPixelRef::NewAllocate(info, 0, NULL); |
633 cache->fCache32 = (SkPMColor*)cache->fCache32PixelRef->getAddr(); | 630 cache->fCache32 = (SkPMColor*)cache->fCache32PixelRef->getAddr(); |
634 if (cache->fShader.fColorCount == 2) { | 631 if (cache->fShader.fColorCount == 2) { |
635 Build32bitCache(cache->fCache32, cache->fShader.fOrigColors[0], | 632 Build32bitCache(cache->fCache32, cache->fShader.fOrigColors[0], |
636 cache->fShader.fOrigColors[1], kCache32Count, cache->fCa
cheAlpha, | 633 cache->fShader.fOrigColors[1], kCache32Count, cache->fCa
cheAlpha, |
637 cache->fShader.fGradFlags); | 634 cache->fShader.fGradFlags); |
638 } else { | 635 } else { |
639 Rec* rec = cache->fShader.fRecs; | 636 Rec* rec = cache->fShader.fRecs; |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 (*stops)[i] = stop; | 1243 (*stops)[i] = stop; |
1247 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1244 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1248 } | 1245 } |
1249 } | 1246 } |
1250 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1247 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1251 | 1248 |
1252 return outColors; | 1249 return outColors; |
1253 } | 1250 } |
1254 | 1251 |
1255 #endif | 1252 #endif |
OLD | NEW |