OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkDeflate.h" | 10 #include "SkDeflate.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // We must check to see if the bitmap has a color table. | 25 // We must check to see if the bitmap has a color table. |
26 SkAutoLockPixels autoLockPixels(*dst); | 26 SkAutoLockPixels autoLockPixels(*dst); |
27 if (!dst->getColorTable()) { | 27 if (!dst->getColorTable()) { |
28 // We can't use an indexed bitmap with no colortable. | 28 // We can't use an indexed bitmap with no colortable. |
29 dst->reset(); | 29 dst->reset(); |
30 } else { | 30 } else { |
31 return; | 31 return; |
32 } | 32 } |
33 } | 33 } |
34 // no pixels or wrong size: fill with zeros. | 34 // no pixels or wrong size: fill with zeros. |
35 SkAlphaType at = image->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTy
pe; | 35 dst->setInfo(SkImageInfo::MakeN32(image->width(), image->height(), image->al
phaType())); |
36 dst->setInfo(SkImageInfo::MakeN32(image->width(), image->height(), at)); | |
37 } | 36 } |
38 | 37 |
39 bool image_compute_is_opaque(const SkImage* image) { | 38 bool image_compute_is_opaque(const SkImage* image) { |
40 if (image->isOpaque()) { | 39 if (image->isOpaque()) { |
41 return true; | 40 return true; |
42 } | 41 } |
43 // keep output PDF small at cost of possible resource use. | 42 // keep output PDF small at cost of possible resource use. |
44 SkBitmap bm; | 43 SkBitmap bm; |
45 image_get_ro_pixels(image, &bm); | 44 image_get_ro_pixels(image, &bm); |
46 return SkBitmap::ComputeIsOpaque(bm); | 45 return SkBitmap::ComputeIsOpaque(bm); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 527 |
529 sk_sp<SkPDFObject> smask; | 528 sk_sp<SkPDFObject> smask; |
530 if (!image_compute_is_opaque(image.get())) { | 529 if (!image_compute_is_opaque(image.get())) { |
531 smask = sk_make_sp<PDFAlphaBitmap>(image); | 530 smask = sk_make_sp<PDFAlphaBitmap>(image); |
532 } | 531 } |
533 #ifdef SK_PDF_IMAGE_STATS | 532 #ifdef SK_PDF_IMAGE_STATS |
534 gRegularImageObjects.fetch_add(1); | 533 gRegularImageObjects.fetch_add(1); |
535 #endif | 534 #endif |
536 return sk_make_sp<PDFDefaultBitmap>(std::move(image), std::move(smask)); | 535 return sk_make_sp<PDFDefaultBitmap>(std::move(image), std::move(smask)); |
537 } | 536 } |
OLD | NEW |