Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 474983005: rename gradients private BitmapCache to GradientBitmapCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 if (fColorCount > 2) { 667 if (fColorCount > 2) {
668 for (int i = 1; i < fColorCount; i++) { 668 for (int i = 1; i < fColorCount; i++) {
669 *buffer++ = fRecs[i].fPos; 669 *buffer++ = fRecs[i].fPos;
670 } 670 }
671 } 671 }
672 *buffer++ = fGradFlags; 672 *buffer++ = fGradFlags;
673 SkASSERT(buffer - storage.get() == count); 673 SkASSERT(buffer - storage.get() == count);
674 674
675 /////////////////////////////////// 675 ///////////////////////////////////
676 676
677 static SkBitmapCache* gCache; 677 static SkGradientBitmapCache* gCache;
678 // each cache cost 1K of RAM, since each bitmap will be 1x256 at 32bpp 678 // each cache cost 1K of RAM, since each bitmap will be 1x256 at 32bpp
679 static const int MAX_NUM_CACHED_GRADIENT_BITMAPS = 32; 679 static const int MAX_NUM_CACHED_GRADIENT_BITMAPS = 32;
680 SkAutoMutexAcquire ama(gGradientCacheMutex); 680 SkAutoMutexAcquire ama(gGradientCacheMutex);
681 681
682 if (NULL == gCache) { 682 if (NULL == gCache) {
683 gCache = SkNEW_ARGS(SkBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITMAPS)); 683 gCache = SkNEW_ARGS(SkGradientBitmapCache, (MAX_NUM_CACHED_GRADIENT_BITM APS));
684 } 684 }
685 size_t size = count * sizeof(int32_t); 685 size_t size = count * sizeof(int32_t);
686 686
687 if (!gCache->find(storage.get(), size, bitmap)) { 687 if (!gCache->find(storage.get(), size, bitmap)) {
688 // force our cahce32pixelref to be built 688 // force our cahce32pixelref to be built
689 (void)cache->getCache32(); 689 (void)cache->getCache32();
690 bitmap->setInfo(SkImageInfo::MakeN32Premul(kCache32Count, 1)); 690 bitmap->setInfo(SkImageInfo::MakeN32Premul(kCache32Count, 1));
691 bitmap->setPixelRef(cache->getCache32PixelRef()); 691 bitmap->setPixelRef(cache->getCache32PixelRef());
692 692
693 gCache->add(storage.get(), size, *bitmap); 693 gCache->add(storage.get(), size, *bitmap);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 (*stops)[i] = stop; 1216 (*stops)[i] = stop;
1217 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1217 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1218 } 1218 }
1219 } 1219 }
1220 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1220 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1221 1221
1222 return outColors; 1222 return outColors;
1223 } 1223 }
1224 1224
1225 #endif 1225 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientBitmapCache.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698