diff options
author | 2016-12-15 18:17:33 -0500 | |
---|---|---|
committer | 2016-12-16 15:10:43 +0000 | |
commit | 334df3a5627809110e7819346dacdb5233269fdc (patch) | |
tree | 1aa920bbffb9c378bd6c2de157f8e52a0915f6f5 | |
parent | 1e86044d42b52fea679b4fd09226214cfbc9d145 (diff) |
Fix gray png BRD tests
Before my recent CL, these were not run at all (because the decode
color type was gray and the bitmap color type was alpha).
https://skia-review.googlesource.com/c/6088/
Now that these are being run, we should mark the bitmap as
gray so they draw correctly.
BUG=skia:
Change-Id: I9bdfe97671a60da2bcbef55377e1c1b2bd326f8f
Reviewed-on: https://skia-review.googlesource.com/6160
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
-rw-r--r-- | dm/DMSrcSink.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 78e9c55b3d..50b916395d 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -106,6 +106,16 @@ static SkBitmapRegionDecoder* create_brd(Path path) { return SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy); } +static inline void alpha8_to_gray8(SkBitmap* bitmap) { + // Android requires kGray8 bitmaps to be tagged as kAlpha8. Here we convert + // them back to kGray8 so our test framework can draw them correctly. + if (kAlpha_8_SkColorType == bitmap->info().colorType()) { + SkImageInfo newInfo = bitmap->info().makeColorType(kGray_8_SkColorType) + .makeAlphaType(kOpaque_SkAlphaType); + *const_cast<SkImageInfo*>(&bitmap->info()) = newInfo; + } +} + Error BRDSrc::draw(SkCanvas* canvas) const { SkColorType colorType = canvas->imageInfo().colorType(); if (kRGB_565_SkColorType == colorType && @@ -148,6 +158,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { fSampleSize, colorType, false)) { return "Cannot decode (full) region."; } + alpha8_to_gray8(&bitmap); canvas->drawBitmap(bitmap, 0, 0); return ""; } @@ -202,6 +213,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { return "Cannot decode region."; } + alpha8_to_gray8(&bitmap); canvas->drawBitmapRect(bitmap, SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder, (SkScalar) (subsetWidth / fSampleSize), |