SkPDF: Deal with missing ColorTable (don't assert)
Review URL: https://codereview.chromium.org/1414083005
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp
index 0a9453d..159c9e7 100644
--- a/src/pdf/SkPDFBitmap.cpp
+++ b/src/pdf/SkPDFBitmap.cpp
@@ -18,7 +18,17 @@
void image_get_ro_pixels(const SkImage* image, SkBitmap* dst) {
if(as_IB(image)->getROPixels(dst)
&& dst->dimensions() == image->dimensions()) {
- return;
+ if (dst->colorType() != kIndex_8_SkColorType) {
+ return;
+ }
+ // We must check to see if the bitmap has a color table.
+ SkAutoLockPixels autoLockPixels(*dst);
+ if (!dst->getColorTable()) {
+ // We can't use an indexed bitmap with no colortable.
+ dst->reset();
+ } else {
+ return;
+ }
}
// no pixels or wrong size: fill with zeros.
SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
@@ -326,8 +336,6 @@
SkBitmap bitmap;
image_get_ro_pixels(image, &bitmap); // TODO(halcanary): test
SkAutoLockPixels autoLockPixels(bitmap); // with malformed images.
- SkASSERT(bitmap.colorType() != kIndex_8_SkColorType ||
- bitmap.getColorTable());
// Write to a temporary buffer to get the compressed length.
SkDynamicMemoryWStream buffer;