OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
9 #include "SkNextID.h" | 9 #include "SkNextID.h" |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (!bitmap->setInfo(info)) { | 141 if (!bitmap->setInfo(info)) { |
142 return reset_and_return_false(bitmap); | 142 return reset_and_return_false(bitmap); |
143 } | 143 } |
144 | 144 |
145 SkPMColor ctStorage[256]; | 145 SkPMColor ctStorage[256]; |
146 memset(ctStorage, 0xFF, sizeof(ctStorage)); // init with opaque-white for th
e moment | 146 memset(ctStorage, 0xFF, sizeof(ctStorage)); // init with opaque-white for th
e moment |
147 SkAutoTUnref<SkColorTable> ctable(new SkColorTable(ctStorage, 256)); | 147 SkAutoTUnref<SkColorTable> ctable(new SkColorTable(ctStorage, 256)); |
148 if (!bitmap->tryAllocPixels(allocator, ctable)) { | 148 if (!bitmap->tryAllocPixels(allocator, ctable)) { |
149 // SkResourceCache's custom allcator can'thandle ctables, so it may fail
on | 149 // SkResourceCache's custom allcator can'thandle ctables, so it may fail
on |
150 // kIndex_8_SkColorTable. | 150 // kIndex_8_SkColorTable. |
151 // skbug.com/4355 | 151 // https://bug.skia.org/4355 |
152 #if 1 | 152 #if 1 |
153 // ignroe the allocator, and see if we can succeed without it | 153 // ignroe the allocator, and see if we can succeed without it |
154 if (!bitmap->tryAllocPixels(nullptr, ctable)) { | 154 if (!bitmap->tryAllocPixels(nullptr, ctable)) { |
155 return reset_and_return_false(bitmap); | 155 return reset_and_return_false(bitmap); |
156 } | 156 } |
157 #else | 157 #else |
158 // this is the up-scale technique, not fully debugged, but we keep it he
re at the moment | 158 // this is the up-scale technique, not fully debugged, but we keep it he
re at the moment |
159 // to remind ourselves that this might be better than ignoring the alloc
ator. | 159 // to remind ourselves that this might be better than ignoring the alloc
ator. |
160 | 160 |
161 info = SkImageInfo::MakeN32(info.width(), info.height(), info.alphaType(
)); | 161 info = SkImageInfo::MakeN32(info.width(), info.height(), info.alphaType(
)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if (nullptr == data) { | 214 if (nullptr == data) { |
215 return nullptr; | 215 return nullptr; |
216 } | 216 } |
217 if (gFactory) { | 217 if (gFactory) { |
218 if (SkImageGenerator* generator = gFactory(data)) { | 218 if (SkImageGenerator* generator = gFactory(data)) { |
219 return generator; | 219 return generator; |
220 } | 220 } |
221 } | 221 } |
222 return SkImageGenerator::NewFromEncodedImpl(data); | 222 return SkImageGenerator::NewFromEncodedImpl(data); |
223 } | 223 } |
OLD | NEW |