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

Unified Diff: src/codec/SkSwizzler.h

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: Moved bmp specific code out of the swizzler Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/codec/SkSwizzler.h
diff --git a/src/codec/SkSwizzler.h b/src/codec/SkSwizzler.h
index 1adb14db0e6d409a295964257bc32a0049ad3e20..970a2ea53c68957f0af0f1fe4e0eb468b90087b9 100644
--- a/src/codec/SkSwizzler.h
+++ b/src/codec/SkSwizzler.h
@@ -18,26 +18,51 @@ public:
* Enum describing the config of the source data.
*/
enum SrcConfig {
- kGray, // 1 byte per pixel
- kIndex, // 1 byte per pixel
- kRGB, // 3 bytes per pixel
- kRGBX, // 4 byes per pixel (ignore 4th)
- kRGBA, // 4 bytes per pixel
- kRGB_565 // 2 bytes per pixel
+ kGray,
+ kIndex1,
+ kIndex2,
+ kIndex4,
+ kIndex,
+ kRGB,
+ kBGR,
+ kRGBX,
+ kBGRX,
+ kRGBA,
+ kBGRA,
+ kRGB_565,
};
- static int BytesPerPixel(SrcConfig sc) {
+ /*
+ *
+ * Result code for the alpha components of a row.
+ *
+ */
+ enum ResultAlpha {
+ kOpaque_ResultAlpha, // All pixels in a row have max alpha
+ kTransparent_ResultAlpha, // All pixels in a row have zero alpha
+ kNeither_ResultAlpha // Alpha is not completely maxed or zeroed
+ };
+
+ static int BitsPerPixel(SrcConfig sc) {
switch (sc) {
- case kGray:
- case kIndex:
+ case kIndex1:
return 1;
+ case kIndex2:
+ return 2;
+ case kIndex4:
+ return 4;
+ case kIndex:
+ return 8;
+ case kRGB_565:
+ return 16;
case kRGB:
- return 3;
+ case kBGR:
+ return 24;
case kRGBX:
case kRGBA:
- return 4;
- case kRGB_565:
- return 2;
+ case kBGRX:
+ case kBGRA:
+ return 32;
}
}
@@ -52,15 +77,24 @@ public:
* zero-initialized. The implementation may or may not respect this.
* @return A new SkSwizzler or NULL on failure.
*/
- static SkSwizzler* CreateSwizzler(SrcConfig sc, const SkPMColor* ctable,
- const SkImageInfo& info, void* dst,
- size_t dstRowBytes, bool skipZeroes);
+ static SkSwizzler* CreateSwizzler(
+ SrcConfig sc, const SkPMColor* ctable, const SkImageInfo& info,
+ void* dst, size_t dstRowBytes, bool skipZeroes);
+
/**
* Swizzle the next line. Call height times, once for each row of source.
* @param src The next row of the source data.
* @return Whether the row had non-opaque alpha.
*/
- bool next(const uint8_t* SK_RESTRICT src);
+ ResultAlpha next(const uint8_t* SK_RESTRICT src);
scroggo 2015/03/06 18:56:14 I think the PNG decoder needs to update the way it
+
+ /**
+ *
+ * Alternate version of next that allows the caller to specify the offset
+ * bytes to move to the next row.
+ *
+ */
+ ResultAlpha next(const uint8_t* SK_RESTRICT src, int32_t delta);
scroggo 2015/03/06 18:56:14 This interface is going to be hard for our SkGifCo
private:
/**
* Method for converting raw data to Skia pixels.
@@ -71,22 +105,21 @@ private:
* @param y Line of source.
* @param ctable Colors (used for kIndex source).
*/
- typedef bool (*RowProc)(void* SK_RESTRICT dstRow,
- const uint8_t* SK_RESTRICT src,
- int width, int bpp, int y,
- const SkPMColor ctable[]);
+ typedef ResultAlpha (*RowProc)(void* SK_RESTRICT dstRow,
+ const uint8_t* SK_RESTRICT src,
+ int width, int bitsPerPixel, int y,
+ const SkPMColor ctable[]);
const RowProc fRowProc;
- const SkPMColor* fColorTable; // Unowned pointer
- const int fSrcPixelSize;
+ const SkPMColor* fColorTable; // Unowned pointer
+ const int fSrcBitsPerPixel;
const SkImageInfo fDstInfo;
void* fDstRow;
const size_t fDstRowBytes;
int fCurrY;
- SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcBpp,
+ SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcBPP,
scroggo 2015/03/06 18:56:14 Why did this change?
const SkImageInfo& info, void* dst, size_t rowBytes);
};
#endif // SkSwizzler_DEFINED
-

Powered by Google App Engine
This is Rietveld 408576698