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

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

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 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/images/SkMovie_gif.cpp ('k') | src/lazy/SkDiscardablePixelRef.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 2013 Google Inc. 2 * Copyright 2013 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 "SkCachingPixelRef.h" 8 #include "SkCachingPixelRef.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 10
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { 41 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
42 if (fErrorInDecoding) { 42 if (fErrorInDecoding) {
43 return false; // don't try again. 43 return false; // don't try again.
44 } 44 }
45 45
46 const SkImageInfo& info = this->info(); 46 const SkImageInfo& info = this->info();
47 if (!SkBitmapCache::Find(this->getGenerationID(), info.fWidth, info.fHeight, &fLockedBitmap)) { 47 if (!SkBitmapCache::Find(this->getGenerationID(), info.fWidth, info.fHeight, &fLockedBitmap)) {
48 // Cache has been purged, must re-decode. 48 // Cache has been purged, must re-decode.
49 if (!fLockedBitmap.allocPixels(info, fRowBytes)) { 49 if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
50 fErrorInDecoding = true; 50 fErrorInDecoding = true;
51 return false; 51 return false;
52 } 52 }
53 if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowByt es)) { 53 if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowByt es)) {
54 fErrorInDecoding = true; 54 fErrorInDecoding = true;
55 return false; 55 return false;
56 } 56 }
57 fLockedBitmap.setImmutable(); 57 fLockedBitmap.setImmutable();
58 SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, f LockedBitmap); 58 SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, f LockedBitmap);
59 } 59 }
60 60
61 // Now bitmap should contain a concrete PixelRef of the decoded image. 61 // Now bitmap should contain a concrete PixelRef of the decoded image.
62 void* pixels = fLockedBitmap.getPixels(); 62 void* pixels = fLockedBitmap.getPixels();
63 SkASSERT(pixels != NULL); 63 SkASSERT(pixels != NULL);
64 rec->fPixels = pixels; 64 rec->fPixels = pixels;
65 rec->fColorTable = NULL; 65 rec->fColorTable = NULL;
66 rec->fRowBytes = fLockedBitmap.rowBytes(); 66 rec->fRowBytes = fLockedBitmap.rowBytes();
67 return true; 67 return true;
68 } 68 }
69 69
70 void SkCachingPixelRef::onUnlockPixels() { 70 void SkCachingPixelRef::onUnlockPixels() {
71 fLockedBitmap.reset(); 71 fLockedBitmap.reset();
72 } 72 }
OLDNEW
« no previous file with comments | « src/images/SkMovie_gif.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698