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 "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
9 #include "SkBmpMaskCodec.h" | 9 #include "SkBmpMaskCodec.h" |
10 #include "SkBmpRLECodec.h" | 10 #include "SkBmpRLECodec.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 kInfoV4_BmpHeaderType == headerType || | 385 kInfoV4_BmpHeaderType == headerType || |
386 kInfoV5_BmpHeaderType == headerType) { | 386 kInfoV5_BmpHeaderType == headerType) { |
387 // Header types are matched based on size. If the header is | 387 // Header types are matched based on size. If the header is |
388 // V3+, we are guaranteed to be able to read at least this size. | 388 // V3+, we are guaranteed to be able to read at least this size. |
389 SkASSERT(infoBytesRemaining > 52); | 389 SkASSERT(infoBytesRemaining > 52); |
390 inputMasks.alpha = get_int(iBuffer.get(), 48); | 390 inputMasks.alpha = get_int(iBuffer.get(), 48); |
391 if (inputMasks.alpha != 0) { | 391 if (inputMasks.alpha != 0) { |
392 alphaType = kUnpremul_SkAlphaType; | 392 alphaType = kUnpremul_SkAlphaType; |
393 } | 393 } |
394 } | 394 } |
395 iBuffer.free(); | 395 iBuffer.reset(); |
396 | 396 |
397 // Additionally, 32 bit bmp-in-icos use the alpha channel. | 397 // Additionally, 32 bit bmp-in-icos use the alpha channel. |
398 // FIXME (msarett): Don't all bmp-in-icos use the alpha channel? | 398 // FIXME (msarett): Don't all bmp-in-icos use the alpha channel? |
399 // And, RLE inputs may skip pixels, leaving them as transparent. This | 399 // And, RLE inputs may skip pixels, leaving them as transparent. This |
400 // is uncommon, but we cannot be certain that an RLE bmp will be opaque. | 400 // is uncommon, but we cannot be certain that an RLE bmp will be opaque. |
401 if ((inIco && 32 == bitsPerPixel) || (kRLE_BmpInputFormat == inputFormat)) { | 401 if ((inIco && 32 == bitsPerPixel) || (kRLE_BmpInputFormat == inputFormat)) { |
402 alphaType = kUnpremul_SkAlphaType; | 402 alphaType = kUnpremul_SkAlphaType; |
403 } | 403 } |
404 | 404 |
405 // Check for valid bits per pixel. | 405 // Check for valid bits per pixel. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 | 587 |
588 bool SkBmpCodec::skipRows(int count) { | 588 bool SkBmpCodec::skipRows(int count) { |
589 const size_t bytesToSkip = count * fSrcRowBytes; | 589 const size_t bytesToSkip = count * fSrcRowBytes; |
590 return this->stream()->skip(bytesToSkip) == bytesToSkip; | 590 return this->stream()->skip(bytesToSkip) == bytesToSkip; |
591 } | 591 } |
592 | 592 |
593 bool SkBmpCodec::onSkipScanlines(int count) { | 593 bool SkBmpCodec::onSkipScanlines(int count) { |
594 return this->skipRows(count); | 594 return this->skipRows(count); |
595 } | 595 } |
OLD | NEW |