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

Unified Diff: src/codec/SkCodecPriv.h

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 2769cec1cd4025f15611d4c9e5d53e65cb2eb47b..bce3fe22f973cf6d77463ddcc64c23d110de4462 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -8,6 +8,7 @@
#ifndef SkCodecPriv_DEFINED
#define SkCodecPriv_DEFINED
+#include "SkColorPriv.h"
#include "SkColorTable.h"
#include "SkImageInfo.h"
#include "SkSwizzler.h"
@@ -139,6 +140,25 @@ static const SkPMColor* get_color_ptr(SkColorTable* colorTable) {
}
/*
+ * Given that the encoded image uses a color table, return the fill value
+ */
+static uint32_t get_color_table_fill_value(SkColorType colorType, const SkPMColor* colorPtr,
scroggo 2015/09/22 18:02:48 inline, not static
msarett 2015/09/23 13:22:40 Yes! I'll go ahead and fix all of these.
+ uint8_t fillIndex) {
+ SkASSERT(nullptr != colorPtr);
+ switch (colorType) {
+ case kN32_SkColorType:
+ return colorPtr[fillIndex];
+ case kRGB_565_SkColorType:
+ return SkPixel32ToPixel16(colorPtr[fillIndex]);
+ case kIndex_8_SkColorType:
+ return fillIndex;
+ default:
+ SkASSERT(false);
+ return 0;
+ }
+}
+
+/*
*
* Copy the codec color table back to the client when kIndex8 color type is requested
*/
@@ -182,23 +202,6 @@ static inline size_t compute_row_bytes(int width, uint32_t bitsPerPixel) {
}
/*
- * On incomplete images, get the color to fill with
- */
-static inline SkPMColor get_fill_color_or_index(SkAlphaType alphaType) {
- // This condition works properly for all supported output color types.
- // kIndex8: The low 8-bits of both possible return values is 0, which is
- // our desired default index.
- // kGray8: The low 8-bits of both possible return values is 0, which is
- // black, our desired fill value.
- // kRGB565: The low 16-bits of both possible return values is 0, which is
- // black, our desired fill value.
- // kN32: Return black for opaque images and transparent for non-opaque
- // images.
- return kOpaque_SkAlphaType == alphaType ?
- SK_ColorBLACK : SK_ColorTRANSPARENT;
-}
-
-/*
* Get a byte from a buffer
* This method is unsafe, the caller is responsible for performing a check
*/

Powered by Google App Engine
This is Rietveld 408576698