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

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

Issue 345263005: add rowbytes option to allocPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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/SkBitmap.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 "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 const SkImageInfo& info = this->info(); 48 const SkImageInfo& info = this->info();
49 SkBitmap bitmap; 49 SkBitmap bitmap;
50 SkASSERT(NULL == fScaledCacheId); 50 SkASSERT(NULL == fScaledCacheId);
51 fScaledCacheId = SkScaledImageCache::FindAndLock(this->getGenerationID(), 51 fScaledCacheId = SkScaledImageCache::FindAndLock(this->getGenerationID(),
52 info.fWidth, 52 info.fWidth,
53 info.fHeight, 53 info.fHeight,
54 &bitmap); 54 &bitmap);
55 if (NULL == fScaledCacheId) { 55 if (NULL == fScaledCacheId) {
56 // Cache has been purged, must re-decode. 56 // Cache has been purged, must re-decode.
57 if ((!bitmap.setInfo(info, fRowBytes)) || !bitmap.allocPixels()) { 57 if (!bitmap.allocPixels(info, fRowBytes)) {
58 fErrorInDecoding = true; 58 fErrorInDecoding = true;
59 return false; 59 return false;
60 } 60 }
61 SkAutoLockPixels autoLockPixels(bitmap); 61 SkAutoLockPixels autoLockPixels(bitmap);
62 if (!fImageGenerator->getPixels(info, bitmap.getPixels(), fRowBytes)) { 62 if (!fImageGenerator->getPixels(info, bitmap.getPixels(), fRowBytes)) {
63 fErrorInDecoding = true; 63 fErrorInDecoding = true;
64 return false; 64 return false;
65 } 65 }
66 fScaledCacheId = SkScaledImageCache::AddAndLock(this->getGenerationID(), 66 fScaledCacheId = SkScaledImageCache::AddAndLock(this->getGenerationID(),
67 info.fWidth, 67 info.fWidth,
(...skipping 20 matching lines...) Expand all
88 rec->fColorTable = NULL; 88 rec->fColorTable = NULL;
89 rec->fRowBytes = bitmap.rowBytes(); 89 rec->fRowBytes = bitmap.rowBytes();
90 return true; 90 return true;
91 } 91 }
92 92
93 void SkCachingPixelRef::onUnlockPixels() { 93 void SkCachingPixelRef::onUnlockPixels() {
94 SkASSERT(fScaledCacheId != NULL); 94 SkASSERT(fScaledCacheId != NULL);
95 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach eId)); 95 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach eId));
96 fScaledCacheId = NULL; 96 fScaledCacheId = NULL;
97 } 97 }
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698