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

Unified Diff: src/codec/SkBmpRLECodec.cpp

Issue 1277213002: Support more swizzles to 565 in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update new 565 swizzling functions for scaling Created 5 years, 4 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
Index: src/codec/SkBmpRLECodec.cpp
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index c71a5409d2c2c2ee5d2fa11261594c809f4c66d1..14a5b01c1f374d520856058aeef61ef9978324d3 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -12,35 +12,6 @@
#include "SkStream.h"
/*
- * Checks if the conversion between the input image and the requested output
- * image has been implemented
- */
-static bool conversion_possible(const SkImageInfo& dst,
- const SkImageInfo& src) {
- // Ensure that the profile type is unchanged
- if (dst.profileType() != src.profileType()) {
- return false;
- }
-
- // Ensure the alpha type is valid
- if (!valid_alpha(dst.alphaType(), src.alphaType())) {
- return false;
- }
-
- // Check for supported color types
- switch (dst.colorType()) {
- // Allow output to kN32 from any type of input
- case kN32_SkColorType:
- return true;
- // Allow output to kIndex_8 from compatible inputs
- case kIndex_8_SkColorType:
- return kIndex_8_SkColorType == src.colorType();
- default:
- return false;
- }
-}
-
-/*
* Creates an instance of the decoder
* Called only by NewFromStream
*/
@@ -240,6 +211,11 @@ void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes,
dstRow[x] = fColorTable->operator[](index);
break;
}
+ case kRGB_565_SkColorType: {
+ uint16_t* dstRow = SkTAddOffset<uint16_t>(dst, row * (int) dstRowBytes);
+ dstRow[x] = SkPixel32ToPixel16(fColorTable->operator[](index));
+ break;
+ }
default:
// This case should not be reached. We should catch an invalid
// color type when we check that the conversion is possible.
@@ -272,6 +248,11 @@ void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes,
dstRow[x] = SkPackARGB32NoCheck(0xFF, red, green, blue);
break;
}
+ case kRGB_565_SkColorType: {
+ uint16_t* dstRow = SkTAddOffset<uint16_t>(dst, row * (int) dstRowBytes);
+ dstRow[x] = SkPack888ToRGB16(red, green, blue);
+ break;
+ }
default:
// This case should not be reached. We should catch an invalid
// color type when we check that the conversion is possible.

Powered by Google App Engine
This is Rietveld 408576698