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

Side by Side Diff: src/images/SkImageRef_GlobalPool.cpp

Issue 108513003: Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refa… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageRef.cpp ('k') | src/lazy/SkCachingPixelRef.h » ('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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkImageRef_GlobalPool.h" 8 #include "SkImageRef_GlobalPool.h"
9 #include "SkImageRefPool.h" 9 #include "SkImageRefPool.h"
10 #include "SkThread.h" 10 #include "SkThread.h"
11 11
12 SK_DECLARE_STATIC_MUTEX(gGlobalPoolMutex); 12 SK_DECLARE_STATIC_MUTEX(gGlobalPoolMutex);
13 13
14 /* 14 /*
15 * This returns the lazily-allocated global pool. It must be called 15 * This returns the lazily-allocated global pool. It must be called
16 * from inside the guard mutex, so we safely only ever allocate 1. 16 * from inside the guard mutex, so we safely only ever allocate 1.
17 */ 17 */
18 static SkImageRefPool* GetGlobalPool() { 18 static SkImageRefPool* GetGlobalPool() {
19 static SkImageRefPool* gPool; 19 static SkImageRefPool* gPool;
20 if (NULL == gPool) { 20 if (NULL == gPool) {
21 gPool = SkNEW(SkImageRefPool); 21 gPool = SkNEW(SkImageRefPool);
22 // call sk_atexit(...) when we have that, to free the global pool 22 // call sk_atexit(...) when we have that, to free the global pool
23 } 23 }
24 return gPool; 24 return gPool;
25 } 25 }
26 26
27 SkImageRef_GlobalPool::SkImageRef_GlobalPool(const SkImageInfo& info, 27 SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkStreamRewindable* stream,
28 SkStreamRewindable* stream, 28 SkBitmap::Config config,
29 int sampleSize) 29 int sampleSize)
30 : SkImageRef(info, stream, sampleSize, &gGlobalPoolMutex) { 30 : SkImageRef(stream, config, sampleSize, &gGlobalPoolMutex) {
31 SkASSERT(&gGlobalPoolMutex == this->mutex()); 31 SkASSERT(&gGlobalPoolMutex == this->mutex());
32 SkAutoMutexAcquire ac(gGlobalPoolMutex); 32 SkAutoMutexAcquire ac(gGlobalPoolMutex);
33 GetGlobalPool()->addToHead(this); 33 GetGlobalPool()->addToHead(this);
34 } 34 }
35 35
36 SkImageRef_GlobalPool::~SkImageRef_GlobalPool() { 36 SkImageRef_GlobalPool::~SkImageRef_GlobalPool() {
37 SkASSERT(&gGlobalPoolMutex == this->mutex()); 37 SkASSERT(&gGlobalPoolMutex == this->mutex());
38 SkAutoMutexAcquire ac(gGlobalPoolMutex); 38 SkAutoMutexAcquire ac(gGlobalPoolMutex);
39 GetGlobalPool()->detach(this); 39 GetGlobalPool()->detach(this);
40 } 40 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 void SkImageRef_GlobalPool::SetRAMUsed(size_t usage) { 92 void SkImageRef_GlobalPool::SetRAMUsed(size_t usage) {
93 SkAutoMutexAcquire ac(gGlobalPoolMutex); 93 SkAutoMutexAcquire ac(gGlobalPoolMutex);
94 GetGlobalPool()->setRAMUsed(usage); 94 GetGlobalPool()->setRAMUsed(usage);
95 } 95 }
96 96
97 void SkImageRef_GlobalPool::DumpPool() { 97 void SkImageRef_GlobalPool::DumpPool() {
98 SkAutoMutexAcquire ac(gGlobalPoolMutex); 98 SkAutoMutexAcquire ac(gGlobalPoolMutex);
99 GetGlobalPool()->dump(); 99 GetGlobalPool()->dump();
100 } 100 }
OLDNEW
« no previous file with comments | « src/images/SkImageRef.cpp ('k') | src/lazy/SkCachingPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698