| 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 "SkGlyphCache.h" | 8 #include "SkGlyphCache.h" |
| 9 #include "SkGlyphCache_Globals.h" | 9 #include "SkGlyphCache_Globals.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| 11 #include "SkLazyPtr.h" | 11 #include "SkLazyPtr.h" |
| 12 #include "SkMutex.h" |
| 12 #include "SkPaint.h" | 13 #include "SkPaint.h" |
| 13 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkTLS.h" |
| 14 #include "SkTemplates.h" | 16 #include "SkTemplates.h" |
| 15 #include "SkTLS.h" | |
| 16 #include "SkTypeface.h" | 17 #include "SkTypeface.h" |
| 17 | 18 |
| 18 //#define SPEW_PURGE_STATUS | 19 //#define SPEW_PURGE_STATUS |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 SkGlyphCache_Globals* create_globals() { | 23 SkGlyphCache_Globals* create_globals() { |
| 23 return SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseMutex
)); | 24 return SkNEW_ARGS(SkGlyphCache_Globals, (SkGlyphCache_Globals::kYes_UseMutex
)); |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 rec->fProc(rec->fData); | 411 rec->fProc(rec->fData); |
| 411 AuxProcRec* next = rec->fNext; | 412 AuxProcRec* next = rec->fNext; |
| 412 SkDELETE(rec); | 413 SkDELETE(rec); |
| 413 rec = next; | 414 rec = next; |
| 414 } | 415 } |
| 415 } | 416 } |
| 416 | 417 |
| 417 /////////////////////////////////////////////////////////////////////////////// | 418 /////////////////////////////////////////////////////////////////////////////// |
| 418 /////////////////////////////////////////////////////////////////////////////// | 419 /////////////////////////////////////////////////////////////////////////////// |
| 419 | 420 |
| 420 #include "SkThread.h" | |
| 421 | |
| 422 size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { | 421 size_t SkGlyphCache_Globals::setCacheSizeLimit(size_t newLimit) { |
| 423 static const size_t minLimit = 256 * 1024; | 422 static const size_t minLimit = 256 * 1024; |
| 424 if (newLimit < minLimit) { | 423 if (newLimit < minLimit) { |
| 425 newLimit = minLimit; | 424 newLimit = minLimit; |
| 426 } | 425 } |
| 427 | 426 |
| 428 SkAutoMutexAcquire ac(fMutex); | 427 SkAutoMutexAcquire ac(fMutex); |
| 429 | 428 |
| 430 size_t prevLimit = fCacheSizeLimit; | 429 size_t prevLimit = fCacheSizeLimit; |
| 431 fCacheSizeLimit = newLimit; | 430 fCacheSizeLimit = newLimit; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 return tls ? tls->getCacheSizeLimit() : 0; | 726 return tls ? tls->getCacheSizeLimit() : 0; |
| 728 } | 727 } |
| 729 | 728 |
| 730 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { | 729 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { |
| 731 if (0 == bytes) { | 730 if (0 == bytes) { |
| 732 SkGlyphCache_Globals::DeleteTLS(); | 731 SkGlyphCache_Globals::DeleteTLS(); |
| 733 } else { | 732 } else { |
| 734 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); | 733 SkGlyphCache_Globals::GetTLS().setCacheSizeLimit(bytes); |
| 735 } | 734 } |
| 736 } | 735 } |
| OLD | NEW |