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

Side by Side Diff: src/lazy/SkDiscardablePixelRef.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/lazy/SkCachingPixelRef.cpp ('k') | src/ports/SkImageGenerator_skia.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 "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 if (NULL == fDiscardableMemory) { 58 if (NULL == fDiscardableMemory) {
59 return false; // Memory allocation failed. 59 return false; // Memory allocation failed.
60 } 60 }
61 61
62 void* pixels = fDiscardableMemory->data(); 62 void* pixels = fDiscardableMemory->data();
63 const SkImageInfo& info = this->info(); 63 const SkImageInfo& info = this->info();
64 SkPMColor colors[256]; 64 SkPMColor colors[256];
65 int colorCount = 0; 65 int colorCount = 0;
66 66
67 if (!fGenerator->getPixels(info, pixels, fRowBytes, colors, &colorCount)) { 67 const SkImageGenerator::Result result = fGenerator->getPixels(info, pixels, fRowBytes,
68 fDiscardableMemory->unlock(); 68 colors, &color Count);
69 SkDELETE(fDiscardableMemory); 69 switch (result) {
70 fDiscardableMemory = NULL; 70 case SkImageGenerator::kSuccess:
71 return false; 71 case SkImageGenerator::kIncompleteInput:
72 break;
73 default:
74 fDiscardableMemory->unlock();
75 SkDELETE(fDiscardableMemory);
76 fDiscardableMemory = NULL;
77 return false;
72 } 78 }
73 79
74 // Note: our ctable is not purgeable, as it is not stored in the discardable memory block. 80 // Note: our ctable is not purgeable, as it is not stored in the discardable memory block.
75 // This is because SkColorTable is refcntable, and therefore our caller coul d hold onto it 81 // This is because SkColorTable is refcntable, and therefore our caller coul d hold onto it
76 // beyond the scope of a lock/unlock. If we change the API/lifecycle for SkC olorTable, we 82 // beyond the scope of a lock/unlock. If we change the API/lifecycle for SkC olorTable, we
77 // could move it into the block, but then again perhaps it is small enough t hat this doesn't 83 // could move it into the block, but then again perhaps it is small enough t hat this doesn't
78 // really matter. 84 // really matter.
79 if (colorCount > 0) { 85 if (colorCount > 0) {
80 fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount))); 86 fCTable.reset(SkNEW_ARGS(SkColorTable, (colors, colorCount)));
81 } else { 87 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // These are the public API 125 // These are the public API
120 126
121 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { 127 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) {
122 return SkInstallDiscardablePixelRef(generator, dst, NULL); 128 return SkInstallDiscardablePixelRef(generator, dst, NULL);
123 } 129 }
124 130
125 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { 131 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
126 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded); 132 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded);
127 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals e; 133 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals e;
128 } 134 }
OLDNEW
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | src/ports/SkImageGenerator_skia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698