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

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

Issue 521433002: harden requirements on SkBitmapCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/core/SkBitmapProcState.cpp ('k') | no next file » | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.allocPixels(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 SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, f LockedBitmap); 58 SkBitmapCache::Add(this->getGenerationID(), info.fWidth, info.fHeight, f LockedBitmap);
58 } 59 }
59 60
60 // Now bitmap should contain a concrete PixelRef of the decoded image. 61 // Now bitmap should contain a concrete PixelRef of the decoded image.
61 void* pixels = fLockedBitmap.getPixels(); 62 void* pixels = fLockedBitmap.getPixels();
62 SkASSERT(pixels != NULL); 63 SkASSERT(pixels != NULL);
63 rec->fPixels = pixels; 64 rec->fPixels = pixels;
64 rec->fColorTable = NULL; 65 rec->fColorTable = NULL;
65 rec->fRowBytes = fLockedBitmap.rowBytes(); 66 rec->fRowBytes = fLockedBitmap.rowBytes();
66 return true; 67 return true;
67 } 68 }
68 69
69 void SkCachingPixelRef::onUnlockPixels() { 70 void SkCachingPixelRef::onUnlockPixels() {
70 fLockedBitmap.reset(); 71 fLockedBitmap.reset();
71 } 72 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698