Last tranche of new SkColorTypes
This CL adds:
kAlpha_F16_SkColorType
kRG_F16_SkColorType
kRGBA_16161616_SkColorType,
which should be it for a while.
Bug: skia:9121
Change-Id: I81b9d46a202a76e9b7d7ca86495d72dbdae32576
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241357
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 7729156..c0969b4 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -104,3 +104,8 @@
* Added kAlpha_16_SkColorType and kRG_1616_SkColorType. This is intended to help support HDR YUV
uses case (e.g., P010 and P016). As such, the addition is focused on allowing creation of
SkPixmaps and SkImages and not SkSurfaces (i.e., who wants to render to render to these?)
+
+ * Added kAlpha_F16_SkColorType, kRG_F16_SkColorType and kRGBA_16161616_SkColorType.
+ This is intended to help support HDR YUV uses case (e.g., P010 and P016). As such,
+ the addition is focused on allowing creation of SkPixmaps and SkImages and not
+ SkSurfaces (i.e., who wants to render to render to these?)
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index c1806d3..fac167e 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -43,6 +43,9 @@
case kRG_88_SkColorType: return "RG88";
case kAlpha_16_SkColorType: return "A16";
case kRG_1616_SkColorType: return "RG1616";
+ case kAlpha_F16_SkColorType: return "A_F16";
+ case kRG_F16_SkColorType: return "RG_F16";
+ case kRGBA_16161616_SkColorType:return "16161616";
}
return "";
}
diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp
index 5f22dbc..2d17802 100644
--- a/gm/wacky_yuv_formats.cpp
+++ b/gm/wacky_yuv_formats.cpp
@@ -70,6 +70,10 @@
// TODO: we're cheating a bit w/ P010 and just treating it as unorm 16. This means its
// fully saturated values are 65504 rather than 65535 (that is just .9995 out of 1.0 though).
+ // This is laid out the same as kP016 and kP010 but uses F16 unstead of U16. In this case
+ // the 10 bits/channel vs 16 bits/channel distinction isn't relevant.
+ kP016F_YUVFormat,
+
// 4:4:4 formats, 64 bpp
kY416_YUVFormat, // 16-bit AVYU values all interleaved (1 texture)
@@ -87,11 +91,14 @@
kLast_YUVFormat = kYV12_YUVFormat
};
+#ifdef SK_DEBUG
static bool format_uses_16_bpp(YUVFormat yuvFormat) {
- return kP016_YUVFormat == yuvFormat ||
- kP010_YUVFormat == yuvFormat ||
+ return kP016_YUVFormat == yuvFormat ||
+ kP010_YUVFormat == yuvFormat ||
+ kP016F_YUVFormat == yuvFormat ||
kY416_YUVFormat == yuvFormat;
}
+#endif
static bool format_has_builtin_alpha(YUVFormat yuvFormat) {
return kY416_YUVFormat == yuvFormat ||
@@ -99,10 +106,6 @@
kY410_YUVFormat == yuvFormat;
}
-static bool format_cant_be_represented_with_pixmaps(YUVFormat yuvFormat) {
- return kY416_YUVFormat == yuvFormat; // bc missing SkColorType::kRGBA_16161616
-}
-
// Helper to setup the SkYUVAIndex array correctly
// Skia allows the client to tack an additional alpha plane onto any of the standard opaque
// formats (via the addExtraAlpha) flag. In this case it is assumed to be a stand-alone single-
@@ -110,16 +113,17 @@
static void setup_yuv_indices(YUVFormat yuvFormat, bool addExtraAlpha, SkYUVAIndex yuvaIndices[4]) {
switch (yuvFormat) {
case kP016_YUVFormat: // fall through
- case kP010_YUVFormat:
+ case kP010_YUVFormat: // fall through
+ case kP016F_YUVFormat:
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = SkColorChannel::kA; // bc 16bit is stored in A16 format
+ yuvaIndices[0].fChannel = SkColorChannel::kA; // bc 16bit is stored in A16 or AF16
yuvaIndices[1].fIndex = 1;
yuvaIndices[1].fChannel = SkColorChannel::kR;
yuvaIndices[2].fIndex = 1;
yuvaIndices[2].fChannel = SkColorChannel::kG;
if (addExtraAlpha) {
yuvaIndices[3].fIndex = 2;
- yuvaIndices[3].fChannel = SkColorChannel::kA; // bc 16bit is stored in A16 format
+ yuvaIndices[3].fChannel = SkColorChannel::kA; // bc 16bit is stored in A16 or AF16
} else {
yuvaIndices[3].fIndex = -1; // No alpha channel
}
@@ -129,9 +133,9 @@
yuvaIndices[0].fIndex = 0;
yuvaIndices[0].fChannel = SkColorChannel::kG;
yuvaIndices[1].fIndex = 0;
- yuvaIndices[1].fChannel = SkColorChannel::kB;
+ yuvaIndices[1].fChannel = SkColorChannel::kR;
yuvaIndices[2].fIndex = 0;
- yuvaIndices[2].fChannel = SkColorChannel::kR;
+ yuvaIndices[2].fChannel = SkColorChannel::kB;
yuvaIndices[3].fIndex = 0;
yuvaIndices[3].fChannel = SkColorChannel::kA;
break;
@@ -582,64 +586,29 @@
return result;
}
-// Extract one channel of 'src' into a single channel 16 bit result. Optionally, set
-// the lower 6 bits to 0 for the 10bpp formats (i.e., P010).
-static SkBitmap make_single_channel_16(const SkBitmap& src, int channel, bool tenBitsPP) {
- SkASSERT(0 <= channel && channel <= 3);
+// Create some flavor of a 16bits/channel bitmap from a RGBA_F32 source
+static SkBitmap make_16(const SkBitmap& src, SkColorType dstCT,
+ std::function<void(uint16_t* dstPixel, const float* srcPixel)> convert) {
SkASSERT(src.colorType() == kRGBA_F32_SkColorType);
SkBitmap result;
- result.allocPixels(SkImageInfo::Make(src.width(), src.height(),
- kAlpha_16_SkColorType,
+ result.allocPixels(SkImageInfo::Make(src.width(), src.height(), dstCT,
kUnpremul_SkAlphaType));
- const float* pixels = (const float*) src.getAddr(0, 0);
for (int y = 0; y < src.height(); ++y) {
for (int x = 0; x < src.width(); ++x) {
- uint32_t val16 = SkScalarRoundToInt(pixels[channel] * 65535.0f);
+ const float* srcPixel = (const float*) src.getAddr(x, y);
+ uint16_t* dstPixel = (uint16_t*) result.getAddr(x, y);
- if (tenBitsPP) {
- val16 &= 0xFFC0;
- }
-
- *result.getAddr16(x, y) = val16;
- pixels += 4;
+ convert(dstPixel, srcPixel);
}
}
return result;
}
-// Extract the green and blue channels from src into an 16bit per channel
-// RG texture.
-static SkBitmap make_two_channel_16(const SkBitmap& src, bool tenBitsPP) {
- SkASSERT(src.colorType() == kRGBA_F32_SkColorType);
-
- SkBitmap result;
-
- result.allocPixels(SkImageInfo::Make(src.width(), src.height(),
- kRG_1616_SkColorType,
- kUnpremul_SkAlphaType));
-
- float* pixels = (float*) src.getAddr(0, 0);
- for (int y = 0; y < src.height(); ++y) {
- for (int x = 0; x < src.width(); ++x) {
- uint32_t u16 = SkScalarRoundToInt(pixels[1] * 65535.0f);
- uint32_t v16 = SkScalarRoundToInt(pixels[2] * 65535.0f);
-
- if (tenBitsPP) {
- u16 &= 0xFFC0;
- v16 &= 0xFFC0;
- }
-
- *result.getAddr32(x, y) = (v16 << 16) | u16;
- pixels += 4;
- }
- }
-
- return result;
-}
+static uint16_t flt_2_uint16(float flt) { return SkScalarRoundToInt(flt * 65535.0f); }
// Recombine the separate planes into some YUV format
static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
@@ -648,29 +617,13 @@
switch (yuvFormat) {
case kY416_YUVFormat: {
- // Although this is 16 bpp, store the data in an 8 bpp SkBitmap
- SkBitmap yuvaFull;
-
- yuvaFull.allocPixels(SkImageInfo::Make(planes.fYFull.width(), planes.fYFull.height(),
- kRGBA_8888_SkColorType, kUnpremul_SkAlphaType));
-
- for (int y = 0; y < planes.fYFull.height(); ++y) {
- for (int x = 0; x < planes.fYFull.width(); ++x) {
-
- uint8_t Y = *planes.fYFull.getAddr8(x, y);
- uint8_t U = *planes.fUFull.getAddr8(x, y);
- uint8_t V = *planes.fVFull.getAddr8(x, y);
- uint8_t A = *planes.fAFull.getAddr8(x, y);
-
- // NOT premul!
- // U and V swapped to match RGBA layout
- SkColor c = SkColorSetARGB(A, U, Y, V);
- *yuvaFull.getAddr32(x, y) = c;
- }
- }
-
- resultBMs[nextLayer++] = yuvaFull;
-
+ resultBMs[nextLayer++] = make_16(planes.fFull, kRGBA_16161616_SkColorType,
+ [] (uint16_t* dstPixel, const float* srcPixel) {
+ dstPixel[0] = flt_2_uint16(srcPixel[1]); // U
+ dstPixel[1] = flt_2_uint16(srcPixel[0]); // Y
+ dstPixel[2] = flt_2_uint16(srcPixel[2]); // V
+ dstPixel[3] = flt_2_uint16(srcPixel[3]); // A
+ });
setup_yuv_indices(yuvFormat, false, yuvaIndices);
break;
}
@@ -730,14 +683,48 @@
}
case kP016_YUVFormat: // fall through
case kP010_YUVFormat: {
- resultBMs[nextLayer++] = make_single_channel_16(planes.fFull, 0,
- yuvFormat == kP010_YUVFormat);
- resultBMs[nextLayer++] = make_two_channel_16(planes.fQuarter,
- yuvFormat == kP010_YUVFormat);
-
+ resultBMs[nextLayer++] = make_16(planes.fFull, kAlpha_16_SkColorType,
+ [tenBitsPP = (yuvFormat == kP010_YUVFormat)]
+ (uint16_t* dstPixel, const float* srcPixel) {
+ uint16_t val16 = flt_2_uint16(srcPixel[0]);
+ dstPixel[0] = tenBitsPP ? (val16 & 0xFFC0)
+ : val16;
+ });
+ resultBMs[nextLayer++] = make_16(planes.fQuarter, kRG_1616_SkColorType,
+ [tenBitsPP = (yuvFormat == kP010_YUVFormat)]
+ (uint16_t* dstPixel, const float* srcPixel) {
+ uint16_t u16 = flt_2_uint16(srcPixel[1]);
+ uint16_t v16 = flt_2_uint16(srcPixel[2]);
+ dstPixel[0] = tenBitsPP ? (u16 & 0xFFC0) : u16;
+ dstPixel[1] = tenBitsPP ? (v16 & 0xFFC0) : v16;
+ });
if (!opaque) {
- resultBMs[nextLayer] = make_single_channel_16(planes.fFull, 3,
- yuvFormat == kP010_YUVFormat);
+ resultBMs[nextLayer] = make_16(planes.fFull, kAlpha_16_SkColorType,
+ [tenBitsPP = (yuvFormat == kP010_YUVFormat)]
+ (uint16_t* dstPixel, const float* srcPixel) {
+ uint16_t val16 = flt_2_uint16(srcPixel[3]);
+ dstPixel[0] = tenBitsPP ? (val16 & 0xFFC0)
+ : val16;
+ });
+ }
+ setup_yuv_indices(yuvFormat, !opaque, yuvaIndices);
+ return;
+ }
+ case kP016F_YUVFormat: {
+ resultBMs[nextLayer++] = make_16(planes.fFull, kAlpha_F16_SkColorType,
+ [] (uint16_t* dstPixel, const float* srcPixel) {
+ dstPixel[0] = SkFloatToHalf(srcPixel[0]);
+ });
+ resultBMs[nextLayer++] = make_16(planes.fQuarter, kRG_F16_SkColorType,
+ [] (uint16_t* dstPixel, const float* srcPixel) {
+ dstPixel[0] = SkFloatToHalf(srcPixel[1]);
+ dstPixel[1] = SkFloatToHalf(srcPixel[2]);
+ });
+ if (!opaque) {
+ resultBMs[nextLayer] = make_16(planes.fFull, kAlpha_F16_SkColorType,
+ [] (uint16_t* dstPixel, const float* srcPixel) {
+ dstPixel[0] = SkFloatToHalf(srcPixel[3]);
+ });
}
setup_yuv_indices(yuvFormat, !opaque, yuvaIndices);
return;
@@ -791,13 +778,18 @@
int x = SkScalarFloorToInt(x1 * bm.width());
int y = SkScalarFloorToInt(y1 * bm.height());
- if (kAlpha_8_SkColorType == bm.colorType() || kGray_8_SkColorType == bm.colorType()) {
+ if (kGray_8_SkColorType == bm.colorType()) {
SkASSERT(SkColorChannel::kA == channel || SkColorChannel::kR == channel);
result = *bm.getAddr8(x, y);
- } else if (kAlpha_16_SkColorType == bm.colorType()) {
+ } else if (kAlpha_8_SkColorType == bm.colorType() ||
+ kAlpha_16_SkColorType == bm.colorType() ||
+ kAlpha_F16_SkColorType == bm.colorType()) {
SkASSERT(SkColorChannel::kA == channel);
- result = (*bm.getAddr16(x, y) >> 8);
- } else if (kRG_88_SkColorType == bm.colorType() || kRG_1616_SkColorType == bm.colorType()) {
+ SkColor c = bm.getColor(x, y);
+ result = SkColorGetA(c);
+ } else if (kRG_88_SkColorType == bm.colorType() ||
+ kRG_1616_SkColorType == bm.colorType() ||
+ kRG_F16_SkColorType == bm.colorType()) {
SkASSERT(SkColorChannel::kR == channel || SkColorChannel::kG == channel);
SkColor c = bm.getColor(x, y);
@@ -815,42 +807,27 @@
result = 255;
break;
}
- } else if (kRGBA_8888_SkColorType == bm.colorType()) {
- SkColor c = *bm.getAddr32(x, y);
+ } else {
+ SkASSERT(kRGBA_1010102_SkColorType == bm.colorType() ||
+ kRGBA_8888_SkColorType == bm.colorType() ||
+ kRGBA_16161616_SkColorType == bm.colorType());
+
+ SkColor c = bm.getColor(x, y);
switch (channel) {
case SkColorChannel::kR:
- result = SkColorGetB(c);
+ result = SkColorGetR(c);
break;
case SkColorChannel::kG:
result = SkColorGetG(c);
break;
case SkColorChannel::kB:
- result = SkColorGetR(c);
+ result = SkColorGetB(c);
break;
case SkColorChannel::kA:
result = SkColorGetA(c);
break;
}
- } else {
- SkASSERT(kRGBA_1010102_SkColorType == bm.colorType());
-
- SkColor c = *bm.getAddr32(x, y);
-
- switch (channel) {
- case SkColorChannel::kR:
- result = SkScalarRoundToInt(((c >> 0) & 0x3ff) * (255.0f/1023.0f));
- break;
- case SkColorChannel::kG:
- result = SkScalarRoundToInt(((c >> 10) & 0x3ff) * (255.0f/1023.0f));
- break;
- case SkColorChannel::kB:
- result = SkScalarRoundToInt(((c >> 20) & 0x3ff) * (255.0f/1023.0f));
- break;
- case SkColorChannel::kA:
- result = SkScalarRoundToInt(((c >> 30) & 0x3) * (255.0f/3.0f));
- break;
- }
}
return result;
@@ -1017,7 +994,7 @@
static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) {
static const char* kYUVFormatNames[] = {
- "P016", "P010", "Y416", "AYUV", "Y410", "NV12", "NV21", "I420", "YV12"
+ "P016", "P010", "P016F", "Y416", "AYUV", "Y410", "NV12", "NV21", "I420", "YV12"
};
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVFormatNames) == kLast_YUVFormat+1);
@@ -1035,43 +1012,10 @@
canvas->drawString(rowLabel, 0, y, font, paint);
}
-static void make_RGBA_16(const GrCaps* caps,
- const SkBitmap& bm,
- YUVFormat yuvFormat,
- SkAutoTMalloc<uint8_t>* pixels,
- GrBackendFormat* format,
- size_t* rowBytes) {
- SkASSERT(kY416_YUVFormat == yuvFormat);
- SkASSERT(kRGBA_8888_SkColorType == bm.colorType());
-
- uint16_t y16, u16, v16, a16;
- *rowBytes = 4 * sizeof(uint16_t) * bm.width();
- pixels->reset(*rowBytes * bm.height());
- uint16_t* currPixel = (uint16_t*) pixels->get();
- for (int y = 0; y < bm.height(); ++y) {
- for (int x = 0; x < bm.width(); ++x) {
- SkColor color = bm.getColor(x, y);
-
- y16 = SkScalarRoundToInt((SkColorGetR(color) / 255.0f) * 65535.0f);
- u16 = SkScalarRoundToInt((SkColorGetG(color) / 255.0f) * 65535.0f);
- v16 = SkScalarRoundToInt((SkColorGetB(color) / 255.0f) * 65535.0f);
- a16 = SkScalarRoundToInt((SkColorGetA(color) / 255.0f) * 65535.0f);
-
- currPixel[0] = y16;
- currPixel[1] = u16;
- currPixel[2] = v16;
- currPixel[3] = a16;
- currPixel += 4;
- }
- }
-
- *format = caps->getDefaultBackendFormat(GrColorType::kRGBA_16161616, GrRenderable::kNo);
- return;
-}
-
static GrBackendTexture create_yuva_texture(GrContext* context, const SkBitmap& bm,
SkYUVAIndex yuvaIndices[4], int texIndex,
YUVFormat yuvFormat) {
+#ifdef SK_DEBUG
SkASSERT(texIndex >= 0 && texIndex <= 3);
int channelCount = 0;
for (int i = 0; i < SkYUVAIndex::kIndexCount; ++i) {
@@ -1083,41 +1027,27 @@
if (format_uses_16_bpp(yuvFormat) || 2 == channelCount) {
if (2 == channelCount) {
if (format_uses_16_bpp(yuvFormat)) {
- SkASSERT(kRG_1616_SkColorType == bm.colorType());
-
- return context->priv().createBackendTexture(&bm.pixmap(), 1,
- GrRenderable::kNo, GrProtected::kNo);
+ if (yuvFormat == kP016F_YUVFormat) {
+ SkASSERT(kRG_F16_SkColorType == bm.colorType());
+ } else {
+ SkASSERT(yuvFormat == kP016_YUVFormat || yuvFormat == kP010_YUVFormat);
+ SkASSERT(kRG_1616_SkColorType == bm.colorType());
+ }
} else {
SkASSERT(kRG_88_SkColorType == bm.colorType());
-
- return context->priv().createBackendTexture(&bm.pixmap(), 1,
- GrRenderable::kNo, GrProtected::kNo);
}
} else {
- if (kRGBA_8888_SkColorType == bm.colorType()) {
- // Due to the limitations of SkPixmap these cases need to be handled separately
- const GrCaps* caps = context->priv().caps();
- GrGpu* gpu = context->priv().getGpu();
-
- SkAutoTMalloc<uint8_t> pixels;
- GrBackendFormat format;
- size_t rowBytes;
-
- make_RGBA_16(caps, bm, yuvFormat, &pixels, &format, &rowBytes);
-
- // TODO: SkColorType needs to be expanded to allow RGBA_16 to be done
- // via GrContext::createBackendTexture
- return gpu->createBackendTexture(bm.width(), bm.height(), format,
- GrMipMapped::kNo, GrRenderable::kNo,
- pixels, rowBytes, nullptr, GrProtected::kNo);
+ if (yuvFormat == kY416_YUVFormat) {
+ SkASSERT(kRGBA_16161616_SkColorType == bm.colorType());
+ } else if (yuvFormat == kP016F_YUVFormat) {
+ SkASSERT(kAlpha_F16_SkColorType == bm.colorType());
} else {
+ SkASSERT(yuvFormat == kP016_YUVFormat || yuvFormat == kP010_YUVFormat);
SkASSERT(kAlpha_16_SkColorType == bm.colorType());
-
- return context->priv().createBackendTexture(&bm.pixmap(), 1,
- GrRenderable::kNo, GrProtected::kNo);
}
}
}
+#endif
return context->priv().createBackendTexture(&bm.pixmap(), 1,
GrRenderable::kNo, GrProtected::kNo);
@@ -1144,6 +1074,7 @@
// originals
// P016
// P010
+// P016F
// Y416
// AYUV
// Y410
@@ -1174,8 +1105,8 @@
}
SkISize onISize() override {
- int numCols = 2 * (kLastEnum_SkYUVColorSpace + 1); // opacity x color-space
- int numRows = 1 + (kLast_YUVFormat + 1); // origin + # yuv formats
+ int numCols = 2 * (kLastEnum_SkYUVColorSpace + 1); // opacity x #-color-spaces
+ int numRows = 1 + (kLast_YUVFormat + 1); // original + #-yuv-formats
int wh = SkScalarCeilToInt(kTileWidthHeight * (fUseDomain ? 1.5f : 1.f));
return SkISize::Make(kLabelWidth + numCols * (wh + kPad),
kLabelHeight + numRows * (wh + kPad));
@@ -1242,11 +1173,7 @@
}
int counterMod = counter % 3;
- if (format_cant_be_represented_with_pixmaps((YUVFormat) format) &&
- counterMod == 2) {
- // These formats don't work as pixmaps
- counterMod = 1;
- } else if (fUseDomain && counterMod == 0) {
+ if (fUseDomain && counterMod == 0) {
// Copies flatten to RGB when they copy the YUVA data, which doesn't
// know about the intended domain and the domain padding bleeds in
counterMod = 1;
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 9652a8a..8798413 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -85,10 +85,18 @@
kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha; in 64-bit word
kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
- kRG_88_SkColorType, //<! pixel with 8 bits each for red, green; in 16-bit word
- kAlpha_16_SkColorType, //<! pixel with alpha in 16-bits
- kRG_1616_SkColorType, //<! pixel with 16 bits each for red, green; in 32-bit word
- kLastEnum_SkColorType = kRG_1616_SkColorType, //!< last valid value
+
+ // The following 6 colortypes are just for reading from - not for rendering to
+ kRG_88_SkColorType, //<! pixel with a uint8_t for red and green
+
+ kAlpha_F16_SkColorType, //<! pixel with a half float for alpha
+ kRG_F16_SkColorType, //<! pixel with a half float for red and green
+
+ kAlpha_16_SkColorType, //<! pixel with a little endian uint16_t for alpha
+ kRG_1616_SkColorType, //<! pixel with a little endian uint16_t for red and green
+ kRGBA_16161616_SkColorType,//<! pixel with a little endian uint16_t for red, green, blue, and alpha
+
+ kLastEnum_SkColorType = kRGBA_16161616_SkColorType, //!< last valid value
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
kN32_SkColorType = kBGRA_8888_SkColorType,//!< native ARGB 32-bit encoding
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index fb1fd46..1e6f449 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -250,6 +250,9 @@
if (kRG_88_SkColorType == colorType ||
kRG_1616_SkColorType == colorType ||
kAlpha_16_SkColorType == colorType ||
+ kAlpha_F16_SkColorType == colorType ||
+ kRG_F16_SkColorType == colorType ||
+ kRGBA_16161616_SkColorType == colorType ||
kGray_8_SkColorType == colorType) {
return false;
}
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index cc36958..53174c7 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -1060,8 +1060,8 @@
kRG_1616,
// Experimental (for Y416 and mutant P016/P010)
- kRGBA_16161616, // Not in SkColorType
- kRG_F16, // Not in SkColorType
+ kRGBA_16161616,
+ kRG_F16,
kLast = kRG_F16
};
@@ -1082,7 +1082,7 @@
case GrColorType::kBGRA_8888: return kBGRA_8888_SkColorType;
case GrColorType::kRGBA_1010102: return kRGBA_1010102_SkColorType;
case GrColorType::kGray_8: return kGray_8_SkColorType;
- case GrColorType::kAlpha_F16: return kUnknown_SkColorType;
+ case GrColorType::kAlpha_F16: return kAlpha_F16_SkColorType;
case GrColorType::kRGBA_F16: return kRGBA_F16_SkColorType;
case GrColorType::kRGBA_F16_Clamped: return kRGBA_F16Norm_SkColorType;
case GrColorType::kRGBA_F32: return kRGBA_F32_SkColorType;
@@ -1092,30 +1092,33 @@
case GrColorType::kAlpha_16: return kAlpha_16_SkColorType;
case GrColorType::kRG_1616: return kRG_1616_SkColorType;
// Experimental (for Y416 and mutant P016/P010)
- case GrColorType::kRGBA_16161616: return kUnknown_SkColorType;
- case GrColorType::kRG_F16: return kUnknown_SkColorType;
+ case GrColorType::kRGBA_16161616: return kRGBA_16161616_SkColorType;
+ case GrColorType::kRG_F16: return kRG_F16_SkColorType;
}
SkUNREACHABLE;
}
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct) {
switch (ct) {
- case kUnknown_SkColorType: return GrColorType::kUnknown;
- case kAlpha_8_SkColorType: return GrColorType::kAlpha_8;
- case kRGB_565_SkColorType: return GrColorType::kBGR_565;
- case kARGB_4444_SkColorType: return GrColorType::kABGR_4444;
- case kRGBA_8888_SkColorType: return GrColorType::kRGBA_8888;
- case kRGB_888x_SkColorType: return GrColorType::kRGB_888x;
- case kBGRA_8888_SkColorType: return GrColorType::kBGRA_8888;
- case kGray_8_SkColorType: return GrColorType::kGray_8;
- case kRGBA_F16Norm_SkColorType: return GrColorType::kRGBA_F16_Clamped;
- case kRGBA_F16_SkColorType: return GrColorType::kRGBA_F16;
- case kRGBA_1010102_SkColorType: return GrColorType::kRGBA_1010102;
- case kRGB_101010x_SkColorType: return GrColorType::kUnknown;
- case kRGBA_F32_SkColorType: return GrColorType::kRGBA_F32;
- case kRG_88_SkColorType: return GrColorType::kRG_88;
- case kAlpha_16_SkColorType: return GrColorType::kAlpha_16;
- case kRG_1616_SkColorType: return GrColorType::kRG_1616;
+ case kUnknown_SkColorType: return GrColorType::kUnknown;
+ case kAlpha_8_SkColorType: return GrColorType::kAlpha_8;
+ case kRGB_565_SkColorType: return GrColorType::kBGR_565;
+ case kARGB_4444_SkColorType: return GrColorType::kABGR_4444;
+ case kRGBA_8888_SkColorType: return GrColorType::kRGBA_8888;
+ case kRGB_888x_SkColorType: return GrColorType::kRGB_888x;
+ case kBGRA_8888_SkColorType: return GrColorType::kBGRA_8888;
+ case kGray_8_SkColorType: return GrColorType::kGray_8;
+ case kRGBA_F16Norm_SkColorType: return GrColorType::kRGBA_F16_Clamped;
+ case kRGBA_F16_SkColorType: return GrColorType::kRGBA_F16;
+ case kRGBA_1010102_SkColorType: return GrColorType::kRGBA_1010102;
+ case kRGB_101010x_SkColorType: return GrColorType::kUnknown;
+ case kRGBA_F32_SkColorType: return GrColorType::kRGBA_F32;
+ case kRG_88_SkColorType: return GrColorType::kRG_88;
+ case kAlpha_16_SkColorType: return GrColorType::kAlpha_16;
+ case kRG_1616_SkColorType: return GrColorType::kRG_1616;
+ case kAlpha_F16_SkColorType: return GrColorType::kAlpha_F16;
+ case kRG_F16_SkColorType: return GrColorType::kRG_F16;
+ case kRGBA_16161616_SkColorType: return GrColorType::kRGBA_16161616;
}
SkUNREACHABLE;
}
diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h
index 8362df1..7b378e4 100644
--- a/include/private/SkImageInfoPriv.h
+++ b/include/private/SkImageInfoPriv.h
@@ -43,6 +43,9 @@
case kRG_88_SkColorType: return kRG_SkColorTypeComponentFlags;
case kAlpha_16_SkColorType: return kAlpha_SkColorTypeComponentFlag;
case kRG_1616_SkColorType: return kRG_SkColorTypeComponentFlags;
+ case kAlpha_F16_SkColorType: return kAlpha_SkColorTypeComponentFlag;
+ case kRG_F16_SkColorType: return kRG_SkColorTypeComponentFlags;
+ case kRGBA_16161616_SkColorType: return kRGBA_SkColorTypeComponentFlags;
}
SkUNREACHABLE;
}
@@ -80,6 +83,9 @@
case kRG_88_SkColorType: return 1;
case kAlpha_16_SkColorType: return 1;
case kRG_1616_SkColorType: return 2;
+ case kAlpha_F16_SkColorType: return 1;
+ case kRG_F16_SkColorType: return 2;
+ case kRGBA_16161616_SkColorType: return 3;
}
SkUNREACHABLE;
}
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index df91ac2..5f68116 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -1275,7 +1275,10 @@
.value("RGBA_F32", SkColorType::kRGBA_F32_SkColorType)
.value("RG_88", SkColorType::kRG_88_SkColorType)
.value("Alpha_16", SkColorType::kAlpha_16_SkColorType)
- .value("RG_1616", SkColorType::kRG_1616_SkColorType);
+ .value("RG_1616", SkColorType::kRG_1616_SkColorType)
+ .value("Alpha_F16", SkColorType::kAlpha_F16_SkColorType)
+ .value("RG_F16", SkColorType::kRG_F16_SkColorType)
+ .value("RGBA_16161616", SkColorType::kRGBA_16161616_SkColorType);
enum_<SkPath::FillType>("FillType")
.value("Winding", SkPath::FillType::kWinding_FillType)
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index 0745eb7..1000d61 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -100,6 +100,7 @@
case kRGB_565_SkColorType:
case kRG_88_SkColorType:
case kRG_1616_SkColorType:
+ case kRG_F16_SkColorType:
case kRGB_888x_SkColorType:
case kRGB_101010x_SkColorType: {
for (int y = 0; y < srcInfo.height(); ++y) {
@@ -170,6 +171,30 @@
}
return true;
}
+
+ case kAlpha_F16_SkColorType: {
+ auto srcF16 = (const uint16_t*) src;
+ for (int y = 0; y < srcInfo.height(); y++) {
+ for (int x = 0; x < srcInfo.width(); x++) {
+ dst[x] = (uint8_t) (255.0f * SkHalfToFloat(srcF16[x]));
+ }
+ dst = SkTAddOffset<uint8_t>(dst, dstRB);
+ srcF16 = SkTAddOffset<const uint16_t>(srcF16, srcRB);
+ }
+ return true;
+ }
+
+ case kRGBA_16161616_SkColorType: {
+ auto src64 = (const uint64_t*) src;
+ for (int y = 0; y < srcInfo.height(); y++) {
+ for (int x = 0; x < srcInfo.width(); x++) {
+ dst[x] = (src64[x] >> 48) >> 8;
+ }
+ dst = SkTAddOffset<uint8_t>(dst, dstRB);
+ src64 = SkTAddOffset<const uint64_t>(src64, srcRB);
+ }
+ return true;
+ }
}
return false;
}
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp
index 471b004..9979381 100644
--- a/src/core/SkImageInfo.cpp
+++ b/src/core/SkImageInfo.cpp
@@ -12,22 +12,25 @@
int SkColorTypeBytesPerPixel(SkColorType ct) {
switch (ct) {
- case kUnknown_SkColorType: return 0;
- case kAlpha_8_SkColorType: return 1;
- case kRGB_565_SkColorType: return 2;
- case kARGB_4444_SkColorType: return 2;
- case kRGBA_8888_SkColorType: return 4;
- case kBGRA_8888_SkColorType: return 4;
- case kRGB_888x_SkColorType: return 4;
- case kRGBA_1010102_SkColorType: return 4;
- case kRGB_101010x_SkColorType: return 4;
- case kGray_8_SkColorType: return 1;
- case kRGBA_F16Norm_SkColorType: return 8;
- case kRGBA_F16_SkColorType: return 8;
- case kRGBA_F32_SkColorType: return 16;
- case kRG_88_SkColorType: return 2;
- case kAlpha_16_SkColorType: return 2;
- case kRG_1616_SkColorType: return 4;
+ case kUnknown_SkColorType: return 0;
+ case kAlpha_8_SkColorType: return 1;
+ case kRGB_565_SkColorType: return 2;
+ case kARGB_4444_SkColorType: return 2;
+ case kRGBA_8888_SkColorType: return 4;
+ case kBGRA_8888_SkColorType: return 4;
+ case kRGB_888x_SkColorType: return 4;
+ case kRGBA_1010102_SkColorType: return 4;
+ case kRGB_101010x_SkColorType: return 4;
+ case kGray_8_SkColorType: return 1;
+ case kRGBA_F16Norm_SkColorType: return 8;
+ case kRGBA_F16_SkColorType: return 8;
+ case kRGBA_F32_SkColorType: return 16;
+ case kRG_88_SkColorType: return 2;
+ case kAlpha_16_SkColorType: return 2;
+ case kRG_1616_SkColorType: return 4;
+ case kAlpha_F16_SkColorType: return 2;
+ case kRG_F16_SkColorType: return 4;
+ case kRGBA_16161616_SkColorType: return 8;
}
SkUNREACHABLE;
}
@@ -70,7 +73,8 @@
alphaType = kUnknown_SkAlphaType;
break;
case kAlpha_8_SkColorType: // fall-through
- case kAlpha_16_SkColorType:
+ case kAlpha_16_SkColorType: // fall-through
+ case kAlpha_F16_SkColorType:
if (kUnpremul_SkAlphaType == alphaType) {
alphaType = kPremul_SkAlphaType;
}
@@ -82,6 +86,7 @@
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType:
case kRGBA_F32_SkColorType:
+ case kRGBA_16161616_SkColorType:
if (kUnknown_SkAlphaType == alphaType) {
return false;
}
@@ -89,6 +94,7 @@
case kGray_8_SkColorType:
case kRG_88_SkColorType:
case kRG_1616_SkColorType:
+ case kRG_F16_SkColorType:
case kRGB_565_SkColorType:
case kRGB_888x_SkColorType:
case kRGB_101010x_SkColorType:
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index a678950..d0c85c1 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -14,6 +14,7 @@
#include "include/private/SkImageInfoPriv.h"
#include "include/private/SkNx.h"
#include "include/private/SkTo.h"
+#include "include/private/SkVx.h"
#include "src/core/SkMathPriv.h"
#include <new>
@@ -66,7 +67,20 @@
}
};
-struct ColorTypeFilter_F16 {
+struct ColorTypeFilter_Alpha_F16 {
+ typedef uint16_t Type;
+ static Sk4f Expand(uint16_t x) {
+ return SkHalfToFloat_finite_ftz((uint64_t) x); // expand out to four lanes
+
+ }
+ static uint16_t Compact(const Sk4f& x) {
+ uint64_t r;
+ SkFloatToHalf_finite_ftz(x).store(&r);
+ return r & 0xFFFF; // but ignore the extra 3 here
+ }
+};
+
+struct ColorTypeFilter_RGBA_F16 {
typedef uint64_t Type; // SkHalf x4
static Sk4f Expand(uint64_t x) {
return SkHalfToFloat_finite_ftz(x);
@@ -98,6 +112,30 @@
}
};
+struct ColorTypeFilter_F16F16 {
+ typedef uint32_t Type;
+ static Sk4f Expand(uint32_t x) {
+ return SkHalfToFloat_finite_ftz((uint64_t) x); // expand out to four lanes
+ }
+ static uint32_t Compact(const Sk4f& x) {
+ uint64_t r;
+ SkFloatToHalf_finite_ftz(x).store(&r);
+ return (uint32_t) (r & 0xFFFFFFFF); // but ignore the extra 2 here
+ }
+};
+
+struct ColorTypeFilter_16161616 {
+ typedef uint64_t Type;
+ static skvx::Vec<4, uint32_t> Expand(uint64_t x) {
+ return skvx::cast<uint32_t>(skvx::Vec<4, uint16_t>::Load(&x));
+ }
+ static uint64_t Compact(const skvx::Vec<4, uint32_t>& x) {
+ uint64_t r;
+ skvx::cast<uint16_t>(x).store(&r);
+ return r;
+ }
+};
+
struct ColorTypeFilter_16 {
typedef uint16_t Type;
static uint32_t Expand(uint16_t x) {
@@ -417,14 +455,14 @@
break;
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType:
- proc_1_2 = downsample_1_2<ColorTypeFilter_F16>;
- proc_1_3 = downsample_1_3<ColorTypeFilter_F16>;
- proc_2_1 = downsample_2_1<ColorTypeFilter_F16>;
- proc_2_2 = downsample_2_2<ColorTypeFilter_F16>;
- proc_2_3 = downsample_2_3<ColorTypeFilter_F16>;
- proc_3_1 = downsample_3_1<ColorTypeFilter_F16>;
- proc_3_2 = downsample_3_2<ColorTypeFilter_F16>;
- proc_3_3 = downsample_3_3<ColorTypeFilter_F16>;
+ proc_1_2 = downsample_1_2<ColorTypeFilter_RGBA_F16>;
+ proc_1_3 = downsample_1_3<ColorTypeFilter_RGBA_F16>;
+ proc_2_1 = downsample_2_1<ColorTypeFilter_RGBA_F16>;
+ proc_2_2 = downsample_2_2<ColorTypeFilter_RGBA_F16>;
+ proc_2_3 = downsample_2_3<ColorTypeFilter_RGBA_F16>;
+ proc_3_1 = downsample_3_1<ColorTypeFilter_RGBA_F16>;
+ proc_3_2 = downsample_3_2<ColorTypeFilter_RGBA_F16>;
+ proc_3_3 = downsample_3_3<ColorTypeFilter_RGBA_F16>;
break;
case kRG_88_SkColorType:
proc_1_2 = downsample_1_2<ColorTypeFilter_88>;
@@ -466,6 +504,36 @@
proc_3_2 = downsample_3_2<ColorTypeFilter_1010102>;
proc_3_3 = downsample_3_3<ColorTypeFilter_1010102>;
break;
+ case kAlpha_F16_SkColorType:
+ proc_1_2 = downsample_1_2<ColorTypeFilter_Alpha_F16>;
+ proc_1_3 = downsample_1_3<ColorTypeFilter_Alpha_F16>;
+ proc_2_1 = downsample_2_1<ColorTypeFilter_Alpha_F16>;
+ proc_2_2 = downsample_2_2<ColorTypeFilter_Alpha_F16>;
+ proc_2_3 = downsample_2_3<ColorTypeFilter_Alpha_F16>;
+ proc_3_1 = downsample_3_1<ColorTypeFilter_Alpha_F16>;
+ proc_3_2 = downsample_3_2<ColorTypeFilter_Alpha_F16>;
+ proc_3_3 = downsample_3_3<ColorTypeFilter_Alpha_F16>;
+ break;
+ case kRG_F16_SkColorType:
+ proc_1_2 = downsample_1_2<ColorTypeFilter_F16F16>;
+ proc_1_3 = downsample_1_3<ColorTypeFilter_F16F16>;
+ proc_2_1 = downsample_2_1<ColorTypeFilter_F16F16>;
+ proc_2_2 = downsample_2_2<ColorTypeFilter_F16F16>;
+ proc_2_3 = downsample_2_3<ColorTypeFilter_F16F16>;
+ proc_3_1 = downsample_3_1<ColorTypeFilter_F16F16>;
+ proc_3_2 = downsample_3_2<ColorTypeFilter_F16F16>;
+ proc_3_3 = downsample_3_3<ColorTypeFilter_F16F16>;
+ break;
+ case kRGBA_16161616_SkColorType:
+ proc_1_2 = downsample_1_2<ColorTypeFilter_16161616>;
+ proc_1_3 = downsample_1_3<ColorTypeFilter_16161616>;
+ proc_2_1 = downsample_2_1<ColorTypeFilter_16161616>;
+ proc_2_2 = downsample_2_2<ColorTypeFilter_16161616>;
+ proc_2_3 = downsample_2_3<ColorTypeFilter_16161616>;
+ proc_3_1 = downsample_3_1<ColorTypeFilter_16161616>;
+ proc_3_2 = downsample_3_2<ColorTypeFilter_16161616>;
+ proc_3_3 = downsample_3_3<ColorTypeFilter_16161616>;
+ break;
default:
return nullptr;
}
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index add2d60..876675c 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -102,6 +102,7 @@
case kGray_8_SkColorType:
case kRG_88_SkColorType:
case kRG_1616_SkColorType:
+ case kRG_F16_SkColorType:
case kRGB_565_SkColorType:
case kRGB_888x_SkColorType:
case kRGB_101010x_SkColorType:
@@ -112,10 +113,16 @@
case kAlpha_16_SkColorType:
value = static_cast<const uint16_t*>(srcPtr)[0] * (1.0f/65535);
break;
+ case kAlpha_F16_SkColorType: {
+ SkHalf half = static_cast<const SkHalf*>(srcPtr)[0];
+ value = SkHalfToFloat(half);
+ break;
+ }
case kARGB_4444_SkColorType: {
uint16_t u16 = static_cast<const uint16_t*>(srcPtr)[0];
value = SkGetPackedA4444(u16) * (1.0f/15);
- } break;
+ break;
+ }
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
value = static_cast<const uint8_t*>(srcPtr)[3] * (1.0f/255);
@@ -123,13 +130,20 @@
case kRGBA_1010102_SkColorType: {
uint32_t u32 = static_cast<const uint32_t*>(srcPtr)[0];
value = (u32 >> 30) * (1.0f/3);
- } break;
+ break;
+ }
+ case kRGBA_16161616_SkColorType: {
+ uint64_t u64 = static_cast<const uint64_t*>(srcPtr)[0];
+ value = (u64 >> 48) * (1.0f/65535);
+ break;
+ }
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: {
uint64_t px;
memcpy(&px, srcPtr, sizeof(px));
value = SkHalfToFloat_finite_ftz(px)[3];
- } break;
+ break;
+ }
case kRGBA_F32_SkColorType:
value = static_cast<const float*>(srcPtr)[3];
break;
@@ -267,6 +281,10 @@
uint16_t value = *this->addr16(x, y);
return SkColorSetA(0, value * (255 / 65535.0f));
}
+ case kAlpha_F16_SkColorType: {
+ SkHalf value = *this->addr16(x, y);
+ return SkColorSetA(0, 255 * SkHalfToFloat(value));
+ }
case kRGB_565_SkColorType: {
return SkPixel16ToColor(*this->addr16(x, y));
}
@@ -287,6 +305,12 @@
| (uint32_t)( ((value >> 16) & 0xffff) * (255/65535.0f) ) << 8
| 0xff000000;
}
+ case kRG_F16_SkColorType: {
+ uint32_t value = *this->addr32(x, y);
+ uint32_t r = 255 * SkHalfToFloat((value >> 0) & 0xffff);
+ uint32_t g = 255 * SkHalfToFloat((value >> 16) & 0xffff);
+ return (r << 16) | (g << 8) | 0xff000000;
+ }
case kRGB_888x_SkColorType: {
uint32_t value = *this->addr32(x, y);
return SkSwizzle_RB(value | 0xff000000);
@@ -326,6 +350,23 @@
| (uint32_t)( b * 255.0f ) << 0
| (uint32_t)( a * 255.0f ) << 24;
}
+ case kRGBA_16161616_SkColorType: {
+ uint64_t value = *this->addr64(x, y);
+
+ float r = ((value ) & 0xffff) * (1/65535.0f),
+ g = ((value >> 16) & 0xffff) * (1/65535.0f),
+ b = ((value >> 32) & 0xffff) * (1/65535.0f),
+ a = ((value >> 48) & 0xffff) * (1/65535.0f);
+ if (a != 0 && needsUnpremul) {
+ r *= (1.0f/a);
+ g *= (1.0f/a);
+ b *= (1.0f/a);
+ }
+ return (uint32_t)( r * 255.0f ) << 16
+ | (uint32_t)( g * 255.0f ) << 8
+ | (uint32_t)( b * 255.0f ) << 0
+ | (uint32_t)( a * 255.0f ) << 24;
+ }
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: {
const uint64_t* addr =
@@ -377,7 +418,7 @@
}
}
return true;
- } break;
+ }
case kAlpha_16_SkColorType: {
unsigned a = 0xFFFF;
for (int y = 0; y < height; ++y) {
@@ -390,11 +431,23 @@
}
}
return true;
- } break;
+ }
+ case kAlpha_F16_SkColorType: {
+ for (int y = 0; y < height; ++y) {
+ const SkHalf* row = this->addr16(0, y);
+ for (int x = 0; x < width; ++x) {
+ if (row[x] < SK_Half1) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
case kRGB_565_SkColorType:
case kGray_8_SkColorType:
case kRG_88_SkColorType:
case kRG_1616_SkColorType:
+ case kRG_F16_SkColorType:
case kRGB_888x_SkColorType:
case kRGB_101010x_SkColorType:
return true;
@@ -411,7 +464,7 @@
}
}
return true;
- } break;
+ }
case kBGRA_8888_SkColorType:
case kRGBA_8888_SkColorType: {
SkPMColor c = (SkPMColor)~0;
@@ -464,6 +517,19 @@
}
return true;
}
+ case kRGBA_16161616_SkColorType: {
+ uint16_t acc = 0xFFFF;
+ for (int y = 0; y < height; ++y) {
+ const uint64_t* row = this->addr64(0, y);
+ for (int x = 0; x < width; ++x) {
+ acc &= (row[x] >> 48);
+ }
+ if (0xFFFF != acc) {
+ return false;
+ }
+ }
+ return true;
+ }
case kUnknown_SkColorType:
SkDEBUGFAIL("");
break;
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 2fe3e6f..7fa573f 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -167,12 +167,15 @@
case kAlpha_8_SkColorType: this->append(load_a8, ctx); break;
case kAlpha_16_SkColorType: this->append(load_a16, ctx); break;
+ case kAlpha_F16_SkColorType: this->append(load_af16, ctx); break;
case kRGB_565_SkColorType: this->append(load_565, ctx); break;
case kARGB_4444_SkColorType: this->append(load_4444, ctx); break;
case kRG_88_SkColorType: this->append(load_rg88, ctx); break;
case kRG_1616_SkColorType: this->append(load_rg1616, ctx); break;
+ case kRG_F16_SkColorType: this->append(load_rgf16, ctx); break;
case kRGBA_8888_SkColorType: this->append(load_8888, ctx); break;
case kRGBA_1010102_SkColorType: this->append(load_1010102, ctx); break;
+ case kRGBA_16161616_SkColorType:this->append(load_16161616,ctx); break;
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: this->append(load_f16, ctx); break;
case kRGBA_F32_SkColorType: this->append(load_f32, ctx); break;
@@ -201,12 +204,15 @@
case kAlpha_8_SkColorType: this->append(load_a8_dst, ctx); break;
case kAlpha_16_SkColorType: this->append(load_a16_dst, ctx); break;
+ case kAlpha_F16_SkColorType: this->append(load_af16_dst, ctx); break;
case kRGB_565_SkColorType: this->append(load_565_dst, ctx); break;
case kARGB_4444_SkColorType: this->append(load_4444_dst, ctx); break;
case kRG_88_SkColorType: this->append(load_rg88_dst, ctx); break;
case kRG_1616_SkColorType: this->append(load_rg1616_dst, ctx); break;
+ case kRG_F16_SkColorType: this->append(load_rgf16_dst, ctx); break;
case kRGBA_8888_SkColorType: this->append(load_8888_dst, ctx); break;
case kRGBA_1010102_SkColorType: this->append(load_1010102_dst, ctx); break;
+ case kRGBA_16161616_SkColorType:this->append(load_16161616_dst,ctx); break;
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: this->append(load_f16_dst, ctx); break;
case kRGBA_F32_SkColorType: this->append(load_f32_dst, ctx); break;
@@ -235,12 +241,15 @@
case kAlpha_8_SkColorType: this->append(store_a8, ctx); break;
case kAlpha_16_SkColorType: this->append(store_a16, ctx); break;
+ case kAlpha_F16_SkColorType: this->append(store_af16, ctx); break;
case kRGB_565_SkColorType: this->append(store_565, ctx); break;
case kARGB_4444_SkColorType: this->append(store_4444, ctx); break;
case kRG_88_SkColorType: this->append(store_rg88, ctx); break;
case kRG_1616_SkColorType: this->append(store_rg1616, ctx); break;
+ case kRG_F16_SkColorType: this->append(store_rgf16, ctx); break;
case kRGBA_8888_SkColorType: this->append(store_8888, ctx); break;
case kRGBA_1010102_SkColorType: this->append(store_1010102, ctx); break;
+ case kRGBA_16161616_SkColorType:this->append(store_16161616,ctx); break;
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: this->append(store_f16, ctx); break;
case kRGBA_F32_SkColorType: this->append(store_f32, ctx); break;
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 22f24b0..82fee3e 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -48,15 +48,15 @@
M(load_565) M(load_565_dst) M(store_565) M(gather_565) \
M(load_4444) M(load_4444_dst) M(store_4444) M(gather_4444) \
M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \
- M(load_af16) M(store_af16) \
- M(load_rgf16) M(store_rgf16) \
+ M(load_af16) M(load_af16_dst) M(store_af16) M(gather_af16) \
+ M(load_rgf16) M(load_rgf16_dst) M(store_rgf16) M(gather_rgf16) \
M(load_f32) M(load_f32_dst) M(store_f32) M(gather_f32) \
M(load_rgf32) M(store_rgf32) \
M(load_8888) M(load_8888_dst) M(store_8888) M(gather_8888) \
M(load_rg88) M(load_rg88_dst) M(store_rg88) M(gather_rg88) \
M(load_a16) M(load_a16_dst) M(store_a16) M(gather_a16) \
M(load_rg1616) M(load_rg1616_dst) M(store_rg1616) M(gather_rg1616) \
- M(load_16161616) M(store_16161616) \
+ M(load_16161616) M(load_16161616_dst) M(store_16161616) M(gather_16161616) \
M(load_1010102) M(load_1010102_dst) M(store_1010102) M(gather_1010102) \
M(alpha_to_gray) M(alpha_to_gray_dst) M(bt709_luminance_or_luma_to_alpha) \
M(bilerp_clamp_8888) M(bicubic_clamp_8888) \
diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp
index 51292ad..724437b 100644
--- a/src/gpu/GrDataUtils.cpp
+++ b/src/gpu/GrDataUtils.cpp
@@ -299,7 +299,7 @@
uint32_t rHalf = SkFloatToHalf(colorf.fR);
uint32_t gHalf = SkFloatToHalf(colorf.fG);
- uint32_t rgHalf = (rHalf << 16) | gHalf;
+ uint32_t rgHalf = (gHalf << 16) | rHalf;
sk_memset32((uint32_t *) dest, rgHalf, width * height);
break;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 41257f0..750e554 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -263,9 +263,14 @@
return kRG_1616_GrPixelConfig;
case kAlpha_16_SkColorType:
return kAlpha_16_GrPixelConfig;
+ case kAlpha_F16_SkColorType:
+ return kAlpha_half_GrPixelConfig;
+ case kRG_F16_SkColorType:
+ return kRG_half_GrPixelConfig;
+ case kRGBA_16161616_SkColorType:
+ return kRGBA_16161616_GrPixelConfig;
}
- SkASSERT(0); // shouldn't get here
- return kUnknown_GrPixelConfig;
+ SkUNREACHABLE;
}
GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) {
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index fbadae3..c2bffff 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -970,6 +970,7 @@
case MTLPixelFormatBGRA8Unorm: return GrColorType::kBGRA_8888;
case MTLPixelFormatRGB10A2Unorm: return GrColorType::kRGBA_1010102;
case MTLPixelFormatR16Unorm: return GrColorType::kAlpha_16;
+ case MTLPixelFormatR16Float: return GrColorType::kAlpha_F16;
case MTLPixelFormatRG16Unorm: return GrColorType::kRG_1616;
// Experimental (for Y416 and mutant P016/P010)
case MTLPixelFormatRGBA16Unorm: return GrColorType::kRGBA_16161616;
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 1ec7371..738f461 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -1584,6 +1584,7 @@
case VK_FORMAT_B8G8R8A8_UNORM: return GrColorType::kBGRA_8888;
case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return GrColorType::kRGBA_1010102;
case VK_FORMAT_R16_UNORM: return GrColorType::kAlpha_16;
+ case VK_FORMAT_R16_SFLOAT: return GrColorType::kAlpha_F16;
case VK_FORMAT_R16G16_UNORM: return GrColorType::kRG_1616;
// Experimental (for Y416 and mutant P016/P010)
case VK_FORMAT_R16G16B16A16_UNORM: return GrColorType::kRGBA_16161616;
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 2ba4c5f..c587e82 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -44,7 +44,10 @@
if (info.colorType() == kRG_88_SkColorType ||
info.colorType() == kRG_1616_SkColorType ||
- info.colorType() == kAlpha_16_SkColorType) {
+ info.colorType() == kRG_F16_SkColorType ||
+ info.colorType() == kAlpha_16_SkColorType ||
+ info.colorType() == kAlpha_F16_SkColorType ||
+ info.colorType() == kRGBA_16161616_SkColorType) {
return false;
}
diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp
index 79e9812..20c1a5f 100644
--- a/src/images/SkPngEncoder.cpp
+++ b/src/images/SkPngEncoder.cpp
@@ -317,7 +317,10 @@
return transform_scanline_A8_to_GrayAlpha;
case kRG_88_SkColorType:
case kRG_1616_SkColorType:
+ case kRG_F16_SkColorType:
case kAlpha_16_SkColorType:
+ case kAlpha_F16_SkColorType:
+ case kRGBA_16161616_SkColorType:
return nullptr;
}
SkASSERT(false);
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index f43b556..ee4d00a 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -2031,7 +2031,7 @@
}
STAGE(load_rg1616, const SkRasterPipeline_MemoryCtx* ctx) {
- auto ptr = ptr_at_xy<const uint32_t>(ctx, dx,dy);
+ auto ptr = ptr_at_xy<const uint32_t>(ctx, dx, dy);
b = 0; a = 1;
from_1616(load<U32>(ptr, tail), &r,&g);
}
@@ -2057,9 +2057,18 @@
}
STAGE(load_16161616, const SkRasterPipeline_MemoryCtx* ctx) {
- auto ptr = ptr_at_xy<const uint64_t>(ctx, dx,dy);
+ auto ptr = ptr_at_xy<const uint64_t>(ctx, dx, dy);
from_16161616(load<U64>(ptr, tail), &r,&g, &b, &a);
}
+STAGE(load_16161616_dst, const SkRasterPipeline_MemoryCtx* ctx) {
+ auto ptr = ptr_at_xy<const uint64_t>(ctx, dx, dy);
+ from_16161616(load<U64>(ptr, tail), &dr, &dg, &db, &da);
+}
+STAGE(gather_16161616, const SkRasterPipeline_GatherCtx* ctx) {
+ const uint64_t* ptr;
+ U32 ix = ix_and_ptr(&ptr, ctx, r, g);
+ from_16161616(gather(ptr, ix), &r, &g, &b, &a);
+}
STAGE(store_16161616, const SkRasterPipeline_MemoryCtx* ctx) {
auto ptr = ptr_at_xy<uint16_t>(ctx, 4*dx,4*dy);
@@ -2155,23 +2164,58 @@
b = 0;
a = from_half(A);
}
+STAGE(load_af16_dst, const SkRasterPipeline_MemoryCtx* ctx) {
+ auto ptr = ptr_at_xy<const uint16_t>(ctx, dx, dy);
+
+ U16 A = load<U16>((const uint16_t*)ptr, tail);
+ dr = dg = db = 0.0f;
+ da = from_half(A);
+}
+STAGE(gather_af16, const SkRasterPipeline_GatherCtx* ctx) {
+ const uint16_t* ptr;
+ U32 ix = ix_and_ptr(&ptr, ctx, r, g);
+ r = g = b = 0.0f;
+ a = from_half(gather(ptr, ix));
+}
STAGE(store_af16, const SkRasterPipeline_MemoryCtx* ctx) {
auto ptr = ptr_at_xy<uint16_t>(ctx, dx,dy);
store(ptr, to_half(a), tail);
}
STAGE(load_rgf16, const SkRasterPipeline_MemoryCtx* ctx) {
- auto ptr = ptr_at_xy<const uint32_t>(ctx, dx,dy);
+ auto ptr = ptr_at_xy<const uint32_t>(ctx, dx, dy);
U16 R,G;
- load2((const uint16_t*)ptr,tail, &R,&G);
+ load2((const uint16_t*)ptr, tail, &R, &G);
r = from_half(R);
g = from_half(G);
b = 0;
- a = from_half(0x3C00); // one
+ a = 1;
+}
+STAGE(load_rgf16_dst, const SkRasterPipeline_MemoryCtx* ctx) {
+ auto ptr = ptr_at_xy<const uint32_t>(ctx, dx, dy);
+
+ U16 R,G;
+ load2((const uint16_t*)ptr, tail, &R, &G);
+ dr = from_half(R);
+ dg = from_half(G);
+ db = 0;
+ da = 1;
+}
+STAGE(gather_rgf16, const SkRasterPipeline_GatherCtx* ctx) {
+ const uint32_t* ptr;
+ U32 ix = ix_and_ptr(&ptr, ctx, r, g);
+ auto px = gather(ptr, ix);
+
+ U16 R,G;
+ load2((const uint16_t*)&px, 0, &R, &G);
+ r = from_half(R);
+ g = from_half(G);
+ b = 0;
+ a = 1;
}
STAGE(store_rgf16, const SkRasterPipeline_MemoryCtx* ctx) {
- auto ptr = ptr_at_xy<uint32_t>(ctx, dx,dy);
+ auto ptr = ptr_at_xy<uint32_t>(ctx, dx, dy);
store2((uint16_t*)ptr, tail, to_half(r)
, to_half(g));
}
@@ -4141,7 +4185,9 @@
NOT_IMPLEMENTED(from_srgb)
NOT_IMPLEMENTED(to_srgb)
NOT_IMPLEMENTED(load_16161616)
+ NOT_IMPLEMENTED(load_16161616_dst)
NOT_IMPLEMENTED(store_16161616)
+ NOT_IMPLEMENTED(gather_16161616)
NOT_IMPLEMENTED(load_a16)
NOT_IMPLEMENTED(load_a16_dst)
NOT_IMPLEMENTED(store_a16)
@@ -4155,9 +4201,13 @@
NOT_IMPLEMENTED(store_f16)
NOT_IMPLEMENTED(gather_f16)
NOT_IMPLEMENTED(load_af16)
+ NOT_IMPLEMENTED(load_af16_dst)
NOT_IMPLEMENTED(store_af16)
+ NOT_IMPLEMENTED(gather_af16)
NOT_IMPLEMENTED(load_rgf16)
+ NOT_IMPLEMENTED(load_rgf16_dst)
NOT_IMPLEMENTED(store_rgf16)
+ NOT_IMPLEMENTED(gather_rgf16)
NOT_IMPLEMENTED(load_f32)
NOT_IMPLEMENTED(load_f32_dst)
NOT_IMPLEMENTED(store_f32)
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 0f463a9..5b6d6c8 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -422,12 +422,15 @@
switch (info.colorType()) {
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::gather_a8, ctx); break;
case kAlpha_16_SkColorType: p->append(SkRasterPipeline::gather_a16, ctx); break;
+ case kAlpha_F16_SkColorType: p->append(SkRasterPipeline::gather_af16, ctx); break;
case kRGB_565_SkColorType: p->append(SkRasterPipeline::gather_565, ctx); break;
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::gather_4444, ctx); break;
case kRG_88_SkColorType: p->append(SkRasterPipeline::gather_rg88, ctx); break;
case kRG_1616_SkColorType: p->append(SkRasterPipeline::gather_rg1616, ctx); break;
+ case kRG_F16_SkColorType: p->append(SkRasterPipeline::gather_rgf16, ctx); break;
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::gather_8888, ctx); break;
case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::gather_1010102, ctx); break;
+ case kRGBA_16161616_SkColorType:p->append(SkRasterPipeline::gather_16161616,ctx); break;
case kRGBA_F16Norm_SkColorType:
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::gather_f16, ctx); break;
case kRGBA_F32_SkColorType: p->append(SkRasterPipeline::gather_f32, ctx); break;
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index 31ea611..6280c8d 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -427,6 +427,9 @@
{ kRG_88_SkColorType, { .25f, .75f, 0, 0 } },
{ kRG_1616_SkColorType, SkColors::kGreen },
{ kAlpha_16_SkColorType, kTransCol },
+ { kAlpha_F16_SkColorType, kTransCol },
+ { kRG_F16_SkColorType, { .25f, .75f, 0, 0 } },
+ { kRGBA_16161616_SkColorType,{ .25f, .5f, .75f, 1 } },
};
GR_STATIC_ASSERT(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations));
@@ -780,6 +783,10 @@
SkASSERT(combo.fFormat == VK_FORMAT_R16_UNORM);
swizzle = GrSwizzle("aaaa");
break;
+ case GrColorType::kAlpha_F16:
+ SkASSERT(combo.fFormat == VK_FORMAT_R16_SFLOAT);
+ swizzle = GrSwizzle("aaaa");
+ break;
case GrColorType::kABGR_4444:
if (combo.fFormat == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
swizzle = GrSwizzle("bgra");
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index 912641a..33710f8 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -258,7 +258,7 @@
}
static void check_alphas(skiatest::Reporter* reporter, const SkBitmap& bm,
- bool (*pred)(float expected, float actual)) {
+ bool (*pred)(float expected, float actual), SkColorType ct) {
SkASSERT(bm.width() == 16);
SkASSERT(bm.height() == 16);
@@ -268,7 +268,8 @@
float expected = alpha / 255.0f;
float actual = bm.getAlphaf(x, y);
if (!pred(expected, actual)) {
- ERRORF(reporter, "got %g, want %g\n", actual, expected);
+ ERRORF(reporter, "%s: got %g, want %g\n",
+ ToolUtils::colortype_name(ct), actual, expected);
}
alpha += 1;
}
@@ -329,33 +330,35 @@
SkColorType fColorType;
bool (*fPred)(float, float);
} recs[] = {
- { kRGB_565_SkColorType, opaque },
- { kGray_8_SkColorType, opaque },
- { kRG_88_SkColorType, opaque },
- { kRG_1616_SkColorType, opaque },
- { kRGB_888x_SkColorType, opaque },
- { kRGB_101010x_SkColorType, opaque },
+ { kRGB_565_SkColorType, opaque },
+ { kGray_8_SkColorType, opaque },
+ { kRG_88_SkColorType, opaque },
+ { kRG_1616_SkColorType, opaque },
+ { kRG_F16_SkColorType, opaque },
+ { kRGB_888x_SkColorType, opaque },
+ { kRGB_101010x_SkColorType, opaque },
- { kAlpha_8_SkColorType, nearly },
- { kAlpha_16_SkColorType, nearly },
- { kRGBA_8888_SkColorType, nearly },
- { kBGRA_8888_SkColorType, nearly },
- { kRGBA_F16_SkColorType, nearly_half },
- { kRGBA_F32_SkColorType, nearly },
+ { kAlpha_8_SkColorType, nearly },
+ { kAlpha_16_SkColorType, nearly },
+ { kAlpha_F16_SkColorType, nearly_half },
+ { kRGBA_8888_SkColorType, nearly },
+ { kBGRA_8888_SkColorType, nearly },
+ { kRGBA_16161616_SkColorType, nearly },
+ { kRGBA_F16_SkColorType, nearly_half },
+ { kRGBA_F32_SkColorType, nearly },
- { kRGBA_1010102_SkColorType, nearly2bit },
+ { kRGBA_1010102_SkColorType, nearly2bit },
- { kARGB_4444_SkColorType, nearly4bit },
+ { kARGB_4444_SkColorType, nearly4bit },
};
for (const auto& rec : recs) {
SkBitmap tmp;
tmp.allocPixels(bm.info().makeColorType(rec.fColorType));
if (bm.readPixels(tmp.pixmap())) {
- check_alphas(reporter, tmp, rec.fPred);
+ check_alphas(reporter, tmp, rec.fPred, rec.fColorType);
} else {
SkDebugf("can't readpixels\n");
}
}
}
-
diff --git a/tests/ExtendedSkColorTypeTests.cpp b/tests/ExtendedSkColorTypeTests.cpp
index af425e3..151694d 100644
--- a/tests/ExtendedSkColorTypeTests.cpp
+++ b/tests/ExtendedSkColorTypeTests.cpp
@@ -55,6 +55,7 @@
static const TestCase gTests[] = {
{ kAlpha_8_SkColorType, kPremul_SkAlphaType, kAlpha_SkColorTypeComponentFlag, true },
{ kAlpha_16_SkColorType, kPremul_SkAlphaType, kAlpha_SkColorTypeComponentFlag, false },
+ { kAlpha_F16_SkColorType, kPremul_SkAlphaType, kAlpha_SkColorTypeComponentFlag, false },
{ kRGB_565_SkColorType, kOpaque_SkAlphaType, kRGB_SkColorTypeComponentFlags, true },
{ kARGB_4444_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true },
{ kRGBA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true },
@@ -68,6 +69,8 @@
{ kRGBA_F32_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true },
{ kRG_88_SkColorType, kOpaque_SkAlphaType, kRG_SkColorTypeComponentFlags, false },
{ kRG_1616_SkColorType, kOpaque_SkAlphaType, kRG_SkColorTypeComponentFlags, false },
+ { kRG_F16_SkColorType, kOpaque_SkAlphaType, kRG_SkColorTypeComponentFlags, false },
+ { kRGBA_16161616_SkColorType,kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, false },
};
static void raster_tests(skiatest::Reporter* reporter, const TestCase& test) {
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index aae476f..a7280bd 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -625,10 +625,12 @@
case kUnknown_SkColorType: return 0;
case kAlpha_8_SkColorType: return 8;
case kAlpha_16_SkColorType: return 16;
+ case kAlpha_F16_SkColorType: return 16;
case kRGB_565_SkColorType: return 5;
case kARGB_4444_SkColorType: return 4;
case kRG_88_SkColorType: return 8;
case kRG_1616_SkColorType: return 16;
+ case kRG_F16_SkColorType: return 16;
case kRGBA_8888_SkColorType: return 8;
case kRGB_888x_SkColorType: return 8;
case kBGRA_8888_SkColorType: return 8;
@@ -638,6 +640,7 @@
case kRGBA_F16Norm_SkColorType: return 10; // just counting the mantissa
case kRGBA_F16_SkColorType: return 10; // just counting the mantissa
case kRGBA_F32_SkColorType: return 23; // just counting the mantissa
+ case kRGBA_16161616_SkColorType:return 16;
}
SK_ABORT("Unexpected color type.");
}
diff --git a/tools/HashAndEncode.cpp b/tools/HashAndEncode.cpp
index 90b5944..8acceb9 100644
--- a/tools/HashAndEncode.cpp
+++ b/tools/HashAndEncode.cpp
@@ -41,7 +41,10 @@
srcAlpha = skcms_AlphaFormat_Opaque; break;
case kRG_88_SkColorType: return;
case kRG_1616_SkColorType: return;
+ case kRG_F16_SkColorType: return;
case kAlpha_16_SkColorType: return;
+ case kAlpha_F16_SkColorType: return;
+ case kRGBA_16161616_SkColorType:return;
}
skcms_ICCProfile srcProfile = *skcms_sRGB_profile();
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
index e629972..4fce704 100644
--- a/tools/ToolUtils.cpp
+++ b/tools/ToolUtils.cpp
@@ -51,6 +51,7 @@
case kUnknown_SkColorType: return "Unknown";
case kAlpha_8_SkColorType: return "Alpha_8";
case kAlpha_16_SkColorType: return "Alpha_16";
+ case kAlpha_F16_SkColorType: return "Alpha_F16";
case kRGB_565_SkColorType: return "RGB_565";
case kARGB_4444_SkColorType: return "ARGB_4444";
case kRGBA_8888_SkColorType: return "RGBA_8888";
@@ -64,6 +65,8 @@
case kRGBA_F32_SkColorType: return "RGBA_F32";
case kRG_88_SkColorType: return "RG_88";
case kRG_1616_SkColorType: return "RG_1616";
+ case kRG_F16_SkColorType: return "RG_F16";
+ case kRGBA_16161616_SkColorType:return "RGBA_16161616";
}
SkASSERT(false);
return "unexpected colortype";
@@ -74,6 +77,7 @@
case kUnknown_SkColorType: return "Unknown";
case kAlpha_8_SkColorType: return "A8";
case kAlpha_16_SkColorType: return "A16";
+ case kAlpha_F16_SkColorType: return "AF16";
case kRGB_565_SkColorType: return "565";
case kARGB_4444_SkColorType: return "4444";
case kRGBA_8888_SkColorType: return "8888";
@@ -87,6 +91,8 @@
case kRGBA_F32_SkColorType: return "F32";
case kRG_88_SkColorType: return "88";
case kRG_1616_SkColorType: return "1616";
+ case kRG_F16_SkColorType: return "F16F16";
+ case kRGBA_16161616_SkColorType:return "16161616";
}
SkASSERT(false);
return "unexpected colortype";