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

Side by Side Diff: src/codec/SkBmpCodec.cpp

Issue 1689183002: Clarify bmp comment about when we support the alpha mask (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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 SkCodecPrintf("Error: invalid format for bitmap decoding.\n"); 366 SkCodecPrintf("Error: invalid format for bitmap decoding.\n");
367 return false; 367 return false;
368 } 368 }
369 369
370 // Most versions of bmps should be rendered as opaque. Either they do 370 // Most versions of bmps should be rendered as opaque. Either they do
371 // not have an alpha channel, or they expect the alpha channel to be 371 // not have an alpha channel, or they expect the alpha channel to be
372 // ignored. V3+ bmp files introduce an alpha mask and allow the creator 372 // ignored. V3+ bmp files introduce an alpha mask and allow the creator
373 // of the image to use the alpha channels. However, many of these images 373 // of the image to use the alpha channels. However, many of these images
374 // leave the alpha channel blank and expect to be rendered as opaque. This 374 // leave the alpha channel blank and expect to be rendered as opaque. This
375 // is the case for almost all V3 images, so we render these as opaque. For 375 // is the case for almost all V3 images, so we render these as opaque. For
376 // V4+, we will use the alpha channel, and fix the image later if it turns 376 // V4+ images in kMask mode, we will use the alpha mask.
377 // out to be fully transparent. 377 //
378 // As an exception, V3 bmp-in-ico may use an alpha mask. 378 // skbug.com/4116: We should perhaps also apply the alpha mask in kStandard
379 // mode. We just haven't seen any images that expect this
380 // behavior.
381 //
382 // Additionally, V3 bmp-in-ico may use the alpha mask.
379 SkAlphaType alphaType = kOpaque_SkAlphaType; 383 SkAlphaType alphaType = kOpaque_SkAlphaType;
380 if ((kInfoV3_BmpHeaderType == headerType && inIco) || 384 if ((kInfoV3_BmpHeaderType == headerType && inIco) ||
381 kInfoV4_BmpHeaderType == headerType || 385 kInfoV4_BmpHeaderType == headerType ||
382 kInfoV5_BmpHeaderType == headerType) { 386 kInfoV5_BmpHeaderType == headerType) {
383 // Header types are matched based on size. If the header is 387 // Header types are matched based on size. If the header is
384 // 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.
385 SkASSERT(infoBytesRemaining > 52); 389 SkASSERT(infoBytesRemaining > 52);
386 inputMasks.alpha = get_int(iBuffer.get(), 48); 390 inputMasks.alpha = get_int(iBuffer.get(), 48);
387 if (inputMasks.alpha != 0) { 391 if (inputMasks.alpha != 0) {
388 alphaType = kUnpremul_SkAlphaType; 392 alphaType = kUnpremul_SkAlphaType;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount); 562 return prepareToDecode(dstInfo, options, inputColorPtr, inputColorCount);
559 } 563 }
560 564
561 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) { 565 int SkBmpCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
562 // Create a new image info representing the portion of the image to decode 566 // Create a new image info representing the portion of the image to decode
563 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ; 567 SkImageInfo rowInfo = this->dstInfo().makeWH(this->dstInfo().width(), count) ;
564 568
565 // Decode the requested rows 569 // Decode the requested rows
566 return this->decodeRows(rowInfo, dst, rowBytes, this->options()); 570 return this->decodeRows(rowInfo, dst, rowBytes, this->options());
567 } 571 }
OLDNEW
« 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