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

Unified Diff: src/pdf/SkPDFBitmap.cpp

Issue 1414083005: SkPDF: Deal with missing ColorTable (don't assert) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFBitmap.cpp
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp
index 0a9453df43ed45cbfdfeda7f5220bcbad21c7ed8..159c9e73a38c049670f23de2fdda64c8bd82781b 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 @@ static void emit_image_xobject(SkWStream* stream,
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698