aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkMasks.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-02-10 13:40:10 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-10 13:40:10 -0800
commit02b407b744d40f93ecc978bb9f64a5ffb075b82e (patch)
tree8310753a6e3fe458093829c7a45f51dcc8932bb0 /src/codec/SkMasks.cpp
parent402cd91f60bcf1a2f86f769bd02d79ace73770c9 (diff)
Fix bug processing bmp bit masks
Diffstat (limited to 'src/codec/SkMasks.cpp')
-rw-r--r--src/codec/SkMasks.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/codec/SkMasks.cpp b/src/codec/SkMasks.cpp
index 3126672f22..ac97a39d78 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) {
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
- 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
+ for (; tempMask; tempMask >>= 1) {
+ size++;
+ }
}
// Truncate masks greater than 8 bits
if (size > 8) {
shift += size - 8;
size = 8;
+ mask &= 0xFF << shift;
}
}