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

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

Issue 1945353003: Revert of SK_DECLARE_STATIC_MUTEX -> static SkMutex (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/core/SkTypefaceCache.cpp ('k') | src/fonts/SkTestScalerContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 if (!fCache || fCache->getAlpha() != alpha || fCache->getDither() != dither) { 618 if (!fCache || fCache->getAlpha() != alpha || fCache->getDither() != dither) {
619 fCache.reset(new GradientShaderCache(alpha, dither, *this)); 619 fCache.reset(new GradientShaderCache(alpha, dither, *this));
620 } 620 }
621 // Increment the ref counter inside the mutex to ensure the returned pointer is still valid. 621 // Increment the ref counter inside the mutex to ensure the returned pointer is still valid.
622 // Otherwise, the pointer may have been overwritten on a different thread be fore the object's 622 // Otherwise, the pointer may have been overwritten on a different thread be fore the object's
623 // ref count was incremented. 623 // ref count was incremented.
624 fCache.get()->ref(); 624 fCache.get()->ref();
625 return fCache; 625 return fCache;
626 } 626 }
627 627
628 static SkMutex gGradientCacheMutex; 628 SK_DECLARE_STATIC_MUTEX(gGradientCacheMutex);
629 /* 629 /*
630 * Because our caller might rebuild the same (logically the same) gradient 630 * Because our caller might rebuild the same (logically the same) gradient
631 * over and over, we'd like to return exactly the same "bitmap" if possible, 631 * over and over, we'd like to return exactly the same "bitmap" if possible,
632 * allowing the client to utilize a cache of our bitmap (e.g. with a GPU). 632 * allowing the client to utilize a cache of our bitmap (e.g. with a GPU).
633 * To do that, we maintain a private cache of built-bitmaps, based on our 633 * To do that, we maintain a private cache of built-bitmaps, based on our
634 * colors and positions. Note: we don't try to flatten the fMapper, so if one 634 * colors and positions. Note: we don't try to flatten the fMapper, so if one
635 * is present, we skip the cache for now. 635 * is present, we skip the cache for now.
636 */ 636 */
637 void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const { 637 void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
638 // our caller assumes no external alpha, so we ensure that our cache is 638 // our caller assumes no external alpha, so we ensure that our cache is
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 (*stops)[i] = stop; 1203 (*stops)[i] = stop;
1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1205 } 1205 }
1206 } 1206 }
1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1208 1208
1209 return outColors; 1209 return outColors;
1210 } 1210 }
1211 1211
1212 #endif 1212 #endif
OLDNEW
« no previous file with comments | « src/core/SkTypefaceCache.cpp ('k') | src/fonts/SkTestScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698