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

Unified Diff: src/codec/SkMasks.cpp

Issue 1688003002: Fix bug processing bmp bit masks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 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/codec/SkMasks.cpp
diff --git a/src/codec/SkMasks.cpp b/src/codec/SkMasks.cpp
index 3126672f22c8c1e958ca1882be45421ccdfbd9e3..ac97a39d783d67b09494e1afe81ad48160f40161 100644
--- a/src/codec/SkMasks.cpp
+++ b/src/codec/SkMasks.cpp
@@ -47,7 +47,7 @@ const static uint8_t n_bit_to_8_bit_lookup_table[] = {
* Convert an n bit component to an 8-bit component
*
*/
-static uint8_t convert_to_8(uint32_t component, uint32_t n) {
+static uint8_t convert_to_8(uint8_t component, uint32_t n) {
msarett 2016/02/10 20:59:28 No reason for "component" to ever be larger than 8
if (0 == n) {
return 0;
} else if (8 > n) {
@@ -87,11 +87,6 @@ uint8_t SkMasks::getAlpha(uint32_t pixel) const {
*
*/
const SkMasks::MaskInfo process_mask(uint32_t mask, uint32_t bpp) {
- // Trim the masks to the allowed number of bits
msarett 2016/02/10 20:59:28 Unrelated to the bug fix. We do this is CreateMas
- if (bpp < 32) {
- mask &= (1 << bpp) - 1;
- }
-
// Determine properties of the mask
uint32_t tempMask = mask;
uint32_t shift = 0;
@@ -105,14 +100,19 @@ const SkMasks::MaskInfo process_mask(uint32_t mask, uint32_t bpp) {
for (; tempMask & 1; tempMask >>= 1) {
size++;
}
- // Check that the mask is continuous
- if (tempMask != 0) {
- SkCodecPrintf("Warning: Bit masks is not continuous.\n");
+ // Verify that the mask is continuous
+ if (tempMask) {
+ SkCodecPrintf("Warning: Bit mask is not continuous.\n");
+ // Finish processing the mask
msarett 2016/02/10 20:59:28 Even if the mask is not continuous, let's count al
+ for (; tempMask; tempMask >>= 1) {
+ size++;
+ }
}
// Truncate masks greater than 8 bits
if (size > 8) {
shift += size - 8;
size = 8;
+ mask &= 0xFF << shift;
msarett 2016/02/10 20:59:28 Make sure that the final mask is no larger than 8-
}
}
« 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