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

Side by Side Diff: src/lazy/SkLazyPixelRef.cpp

Issue 12398021: If Ashmem cache fails pinCache, do not reallocate. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rebase Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « include/lazy/SkImageCache.h ('k') | src/lazy/SkLruImageCache.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 2012 Google Inc. 2 * Copyright 2012 Google Inc.
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 "Sk64.h" 8 #include "Sk64.h"
9 #include "SkLazyPixelRef.h" 9 #include "SkLazyPixelRef.h"
10 #include "SkColorTable.h" 10 #include "SkColorTable.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #if LAZY_CACHE_STATS 81 #if LAZY_CACHE_STATS
82 sk_atomic_inc(&gCacheMisses); 82 sk_atomic_inc(&gCacheMisses);
83 #endif 83 #endif
84 } 84 }
85 SkASSERT(NULL == target.fAddr); 85 SkASSERT(NULL == target.fAddr);
86 SkImage::Info info; 86 SkImage::Info info;
87 SkASSERT(fData != NULL && fData->size() > 0); 87 SkASSERT(fData != NULL && fData->size() > 0);
88 // FIXME: As an optimization, only do this part once. 88 // FIXME: As an optimization, only do this part once.
89 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL); 89 fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL);
90 if (fErrorInDecoding) { 90 if (fErrorInDecoding) {
91 // In case a previous call to allocAndPinCache succeeded.
92 fImageCache->throwAwayCache(fCacheId);
91 fCacheId = SkImageCache::UNINITIALIZED_ID; 93 fCacheId = SkImageCache::UNINITIALIZED_ID;
92 return NULL; 94 return NULL;
93 } 95 }
94 // Allocate the memory. 96 // Allocate the memory.
95 size_t bytes = ComputeMinRowBytesAndSize(info, &target.fRowBytes); 97 size_t bytes = ComputeMinRowBytesAndSize(info, &target.fRowBytes);
96 98
97 target.fAddr = fImageCache->allocAndPinCache(bytes, &fCacheId); 99 target.fAddr = fImageCache->allocAndPinCache(bytes, &fCacheId);
98 if (NULL == target.fAddr) { 100 if (NULL == target.fAddr) {
99 // Space could not be allocated. 101 // Space could not be allocated.
100 fCacheId = SkImageCache::UNINITIALIZED_ID; 102 fCacheId = SkImageCache::UNINITIALIZED_ID;
(...skipping 15 matching lines...) Expand all
116 } 118 }
117 if (fCacheId != SkImageCache::UNINITIALIZED_ID) { 119 if (fCacheId != SkImageCache::UNINITIALIZED_ID) {
118 fImageCache->releaseCache(fCacheId); 120 fImageCache->releaseCache(fCacheId);
119 } 121 }
120 } 122 }
121 123
122 SkData* SkLazyPixelRef::onRefEncodedData() { 124 SkData* SkLazyPixelRef::onRefEncodedData() {
123 fData->ref(); 125 fData->ref();
124 return fData; 126 return fData;
125 } 127 }
OLDNEW
« no previous file with comments | « include/lazy/SkImageCache.h ('k') | src/lazy/SkLruImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698