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

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

Issue 919693002: Make SkImageGenerator::getPixels() return an enum. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stage the change for chromium Created 5 years, 10 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/SkDecodingImageGenerator.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 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 const SkImageInfo& info = this->info(); 47 const SkImageInfo& info = this->info();
48 if (!SkBitmapCache::Find( 48 if (!SkBitmapCache::Find(
49 this->getGenerationID(), info.bounds(), &fLockedBitmap)) { 49 this->getGenerationID(), info.bounds(), &fLockedBitmap)) {
50 // Cache has been purged, must re-decode. 50 // Cache has been purged, must re-decode.
51 if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) { 51 if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
52 fErrorInDecoding = true; 52 fErrorInDecoding = true;
53 return false; 53 return false;
54 } 54 }
55 if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowByt es)) { 55 const SkImageGenerator::Result result = fImageGenerator->getPixels(info,
56 fErrorInDecoding = true; 56 fLockedBitmap.getPixels(), fRowBytes);
57 return false; 57 switch (result) {
58 case SkImageGenerator::kIncompleteInput:
59 case SkImageGenerator::kSuccess:
60 break;
61 default:
62 fErrorInDecoding = true;
63 return false;
58 } 64 }
59 fLockedBitmap.setImmutable(); 65 fLockedBitmap.setImmutable();
60 SkBitmapCache::Add( 66 SkBitmapCache::Add(
61 this->getGenerationID(), info.bounds(), fLockedBitmap); 67 this->getGenerationID(), info.bounds(), fLockedBitmap);
62 } 68 }
63 69
64 // Now bitmap should contain a concrete PixelRef of the decoded image. 70 // Now bitmap should contain a concrete PixelRef of the decoded image.
65 void* pixels = fLockedBitmap.getPixels(); 71 void* pixels = fLockedBitmap.getPixels();
66 SkASSERT(pixels != NULL); 72 SkASSERT(pixels != NULL);
67 rec->fPixels = pixels; 73 rec->fPixels = pixels;
68 rec->fColorTable = NULL; 74 rec->fColorTable = NULL;
69 rec->fRowBytes = fLockedBitmap.rowBytes(); 75 rec->fRowBytes = fLockedBitmap.rowBytes();
70 return true; 76 return true;
71 } 77 }
72 78
73 void SkCachingPixelRef::onUnlockPixels() { 79 void SkCachingPixelRef::onUnlockPixels() {
74 fLockedBitmap.reset(); 80 fLockedBitmap.reset();
75 } 81 }
OLDNEW
« no previous file with comments | « src/images/SkDecodingImageGenerator.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698