diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 53950e9fab..5528e08af8 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -90,3 +90,7 @@ Milestone 78 * Changed GrContextOptions' fDisallowGLSLBinaryCaching to fShaderCacheStrategy, and allow caching SkSL. https://review.skia.org/238856 + + * Added kRG_88_SkColorType. This is intended to help support YUV uses case (e.g., NV12). + As such, it the addition is focused on allowing creation of SkPixmaps and SkImages and not + SkSurfaces (i.e., who wants to render to RG?) diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp index f75a6e78fa..be6ab85c24 100644 --- a/gm/bitmapcopy.cpp +++ b/gm/bitmapcopy.cpp @@ -40,6 +40,7 @@ static const char* color_type_name(SkColorType colorType) { case kRGBA_F16Norm_SkColorType: return "F16Norm"; case kRGBA_F16_SkColorType: return "F16"; case kRGBA_F32_SkColorType: return "F32"; + case kRG_88_SkColorType: return "RG88"; } return ""; } diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp index 4249561fc9..d2f1983a56 100644 --- a/gm/wacky_yuv_formats.cpp +++ b/gm/wacky_yuv_formats.cpp @@ -523,7 +523,7 @@ static void extract_planes(const SkBitmap& bm, SkYUVColorSpace yuvColorSpace, Pl } } -// Create a 2x2 downsampled SkBitmap. It is stored in an RGBA texture. It can optionally be +// Create a 2x2 downsampled SkBitmap. It is stored in an RG texture. It can optionally be // uv (i.e., for P016, P010 and NV12) or vu (i.e., NV21). static SkBitmap make_quarter_2_channel(const SkBitmap& fullY, const SkBitmap& quarterU, @@ -531,10 +531,9 @@ static SkBitmap make_quarter_2_channel(const SkBitmap& fullY, bool uv) { SkBitmap result; - // There isn't a RG color type. Approx w/ RGBA. result.allocPixels(SkImageInfo::Make(fullY.width()/2, fullY.height()/2, - kRGBA_8888_SkColorType, + kRG_88_SkColorType, kUnpremul_SkAlphaType)); for (int y = 0; y < fullY.height()/2; ++y) { @@ -543,13 +542,9 @@ static SkBitmap make_quarter_2_channel(const SkBitmap& fullY, uint8_t v8 = *quarterV.getAddr8(x, y); if (uv) { - // NOT premul! - // U and 0 swapped to match RGBA layout - *result.getAddr32(x, y) = SkColorSetARGB(0xFF, 0, v8, u8); + *result.getAddr16(x, y) = (v8 << 8) | u8; } else { - // NOT premul! - // V and 0 swapped to match RGBA layout - *result.getAddr32(x, y) = SkColorSetARGB(0xFF, 0, u8, v8); + *result.getAddr16(x, y) = (u8 << 8) | v8; } } } @@ -698,6 +693,24 @@ static uint8_t look_up(float x1, float y1, const SkBitmap& bm, SkColorChannel ch if (kAlpha_8_SkColorType == bm.colorType() || kGray_8_SkColorType == bm.colorType()) { SkASSERT(SkColorChannel::kA == channel || SkColorChannel::kR == channel); result = *bm.getAddr8(x, y); + } else if (kRG_88_SkColorType == bm.colorType()) { + SkASSERT(SkColorChannel::kR == channel || SkColorChannel::kG == channel); + SkColor c = bm.getColor(x, y); + + switch (channel) { + case SkColorChannel::kR: + result = SkColorGetR(c); + break; + case SkColorChannel::kG: + result = SkColorGetG(c); + break; + case SkColorChannel::kB: + result = 0; + break; + case SkColorChannel::kA: + result = 255; + break; + } } else if (kRGBA_8888_SkColorType == bm.colorType()) { SkColor c = *bm.getAddr32(x, y); @@ -918,36 +931,12 @@ static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) { canvas->drawString(rowLabel, 0, y, font, paint); } -static void make_RG_88(const GrCaps* caps, - const SkBitmap& bm, YUVFormat yuvFormat, - SkAutoTMalloc* pixels, - GrBackendFormat* format, size_t* rowBytes) { - SkASSERT(kNV12_YUVFormat == yuvFormat || kNV21_YUVFormat == yuvFormat); - SkASSERT(kRGBA_8888_SkColorType == bm.colorType()); // uv stored in rg - - *rowBytes = bm.width() * 2 * sizeof(uint8_t); - pixels->reset(*rowBytes * bm.height()); - uint8_t* currPixel = pixels->get(); - for (int y = 0; y < bm.height(); ++y) { - for (int x = 0; x < bm.width(); ++x) { - SkColor color = bm.getColor(x, y); - uint8_t u8 = SkColorGetR(color); - uint8_t v8 = SkColorGetG(color); - - currPixel[0] = u8; - currPixel[1] = v8; - currPixel += 2; - } - } - *format = caps->getDefaultBackendFormat(GrColorType::kRG_88, GrRenderable::kNo); -} - static void make_RG_1616(const GrCaps* caps, const SkBitmap& bm, YUVFormat yuvFormat, SkAutoTMalloc* pixels, GrBackendFormat* format, size_t* rowBytes) { SkASSERT(kP016_YUVFormat == yuvFormat || kP010_YUVFormat == yuvFormat); - SkASSERT(kRGBA_8888_SkColorType == bm.colorType()); // uv stored in rg + SkASSERT(kRG_88_SkColorType == bm.colorType()); // uv stored in rg uint16_t u16, v16; *rowBytes = bm.width() * 2 * sizeof(uint16_t); @@ -1053,8 +1042,6 @@ static GrBackendTexture create_yuva_texture(GrContext* context, const SkBitmap& } } - GrBackendTexture tex; - if (format_uses_16_bpp(yuvFormat) || 2 == channelCount) { // Due to the limitations of SkPixmap these cases need to be handled separately const GrCaps* caps = context->priv().caps(); @@ -1068,7 +1055,10 @@ static GrBackendTexture create_yuva_texture(GrContext* context, const SkBitmap& if (format_uses_16_bpp(yuvFormat)) { make_RG_1616(caps, bm, yuvFormat, &pixels, &format, &rowBytes); } else { - make_RG_88(caps, bm, yuvFormat, &pixels, &format, &rowBytes); + SkASSERT(kRG_88_SkColorType == bm.colorType()); + + return context->priv().createBackendTexture(&bm.pixmap(), 1, + GrRenderable::kNo, GrProtected::kNo); } } else { if (kRGBA_8888_SkColorType == bm.colorType()) { @@ -1078,17 +1068,15 @@ static GrBackendTexture create_yuva_texture(GrContext* context, const SkBitmap& } } - // TODO: SkColorType needs to be expanded to allow this to be done via the - // GrContext::createBackendTexture API - tex = gpu->createBackendTexture(bm.width(), bm.height(), format, - GrMipMapped::kNo, GrRenderable::kNo, - pixels, rowBytes, nullptr, GrProtected::kNo); - } else { - tex = context->priv().createBackendTexture(&bm.pixmap(), 1, - GrRenderable::kNo, GrProtected::kNo); + // TODO: SkColorType needs to be expanded to allow RG_1616, RGBA_16 and R_16 to be done + // via GrContext::createBackendTexture + return gpu->createBackendTexture(bm.width(), bm.height(), format, + GrMipMapped::kNo, GrRenderable::kNo, + pixels, rowBytes, nullptr, GrProtected::kNo); } - return tex; + return context->priv().createBackendTexture(&bm.pixmap(), 1, + GrRenderable::kNo, GrProtected::kNo); } static sk_sp yuv_to_rgb_colorfilter() { diff --git a/gn/tests.gni b/gn/tests.gni index 951a04e417..9846a3c2e3 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -70,6 +70,7 @@ tests_sources = [ "$_tests/EncodeTest.cpp", "$_tests/EncodedInfoTest.cpp", "$_tests/ExifTest.cpp", + "$_tests/ExtendedSkColorTypeTests.cpp", "$_tests/F16StagesTest.cpp", "$_tests/FakeStreams.h", "$_tests/FillPathTest.cpp", diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index e52390aea0..b7e33538ac 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -85,7 +85,8 @@ enum SkColorType { 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 - kLastEnum_SkColorType = kRGBA_F32_SkColorType,//!< last valid value + kRG_88_SkColorType, //maxSurfaceSampleCountForColorType(colorType) > 0; } diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index 92c49faa13..ee0b61070a 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -1075,10 +1075,10 @@ static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct) { case GrColorType::kBGR_565: return kRGB_565_SkColorType; case GrColorType::kABGR_4444: return kARGB_4444_SkColorType; case GrColorType::kRGBA_8888: return kRGBA_8888_SkColorType; - // Once we a kRGBA_8888_SRGB_SkColorType we should return that here. + // Once we add kRGBA_8888_SRGB_SkColorType we should return that here. case GrColorType::kRGBA_8888_SRGB: return kRGBA_8888_SkColorType; case GrColorType::kRGB_888x: return kRGB_888x_SkColorType; - case GrColorType::kRG_88: return kUnknown_SkColorType; + case GrColorType::kRG_88: return kRG_88_SkColorType; case GrColorType::kBGRA_8888: return kBGRA_8888_SkColorType; case GrColorType::kRGBA_1010102: return kRGBA_1010102_SkColorType; case GrColorType::kGray_8: return kGray_8_SkColorType; @@ -1113,6 +1113,7 @@ static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct) { 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; } SkUNREACHABLE; } diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h index 9053f41696..5c9e52e238 100644 --- a/include/private/SkImageInfoPriv.h +++ b/include/private/SkImageInfoPriv.h @@ -16,6 +16,8 @@ enum SkColorTypeComponentFlag { kBlue_SkColorTypeComponentFlag = 0x4, kAlpha_SkColorTypeComponentFlag = 0x8, kGray_SkColorTypeComponentFlag = 0x10, + kRG_SkColorTypeComponentFlags = kRed_SkColorTypeComponentFlag | + kGreen_SkColorTypeComponentFlag, kRGB_SkColorTypeComponentFlags = kRed_SkColorTypeComponentFlag | kGreen_SkColorTypeComponentFlag | kBlue_SkColorTypeComponentFlag, @@ -38,8 +40,9 @@ static inline uint32_t SkColorTypeComponentFlags(SkColorType ct) { case kRGBA_F16Norm_SkColorType: return kRGBA_SkColorTypeComponentFlags; case kRGBA_F16_SkColorType: return kRGBA_SkColorTypeComponentFlags; case kRGBA_F32_SkColorType: return kRGBA_SkColorTypeComponentFlags; + case kRG_88_SkColorType: return kRG_SkColorTypeComponentFlags; } - return 0; + SkUNREACHABLE; } static inline bool SkColorTypeIsAlphaOnly(SkColorType ct) { @@ -72,8 +75,9 @@ static int SkColorTypeShiftPerPixel(SkColorType ct) { case kRGBA_F16Norm_SkColorType: return 3; case kRGBA_F16_SkColorType: return 3; case kRGBA_F32_SkColorType: return 4; + case kRG_88_SkColorType: return 1; } - return 0; + SkUNREACHABLE; } static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp index 4705200ece..f610fc6a23 100644 --- a/modules/canvaskit/canvaskit_bindings.cpp +++ b/modules/canvaskit/canvaskit_bindings.cpp @@ -1234,7 +1234,8 @@ EMSCRIPTEN_BINDINGS(Skia) { .value("RGB_101010x", SkColorType::kRGB_101010x_SkColorType) .value("Gray_8", SkColorType::kGray_8_SkColorType) .value("RGBA_F16", SkColorType::kRGBA_F16_SkColorType) - .value("RGBA_F32", SkColorType::kRGBA_F32_SkColorType); + .value("RGBA_F32", SkColorType::kRGBA_F32_SkColorType) + .value("RG_88", SkColorType::kRG_88_SkColorType); enum_("FillType") .value("Winding", SkPath::FillType::kWinding_FillType) diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp index a13202fe49..4a9a851691 100644 --- a/src/core/SkConvertPixels.cpp +++ b/src/core/SkConvertPixels.cpp @@ -86,6 +86,7 @@ static bool convert_to_alpha8(const SkImageInfo& dstInfo, void* vdst, size case kGray_8_SkColorType: case kRGB_565_SkColorType: + case kRG_88_SkColorType: case kRGB_888x_SkColorType: case kRGB_101010x_SkColorType: { for (int y = 0; y < srcInfo.height(); ++y) { diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index d9afbc935d..9287f9dc99 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -25,8 +25,9 @@ int SkColorTypeBytesPerPixel(SkColorType ct) { case kRGBA_F16Norm_SkColorType: return 8; case kRGBA_F16_SkColorType: return 8; case kRGBA_F32_SkColorType: return 16; + case kRG_88_SkColorType: return 2; } - return 0; + SkUNREACHABLE; } bool SkColorTypeIsAlwaysOpaque(SkColorType ct) { @@ -83,6 +84,7 @@ bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, } break; case kGray_8_SkColorType: + case kRG_88_SkColorType: case kRGB_565_SkColorType: case kRGB_888x_SkColorType: case kRGB_101010x_SkColorType: diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp index 82188d1ea7..f4693c3c15 100644 --- a/src/core/SkPixmap.cpp +++ b/src/core/SkPixmap.cpp @@ -100,6 +100,7 @@ float SkPixmap::getAlphaf(int x, int y) const { case kUnknown_SkColorType: return 0; case kGray_8_SkColorType: + case kRG_88_SkColorType: case kRGB_565_SkColorType: case kRGB_888x_SkColorType: case kRGB_101010x_SkColorType: @@ -266,6 +267,12 @@ SkColor SkPixmap::getColor(int x, int y) const { SkPMColor c = SkPixel4444ToPixel32(value); return toColor(c); } + case kRG_88_SkColorType: { + uint16_t value = *this->addr16(x, y); + return (uint32_t)( ((value >> 0) & 0xff) ) << 16 + | (uint32_t)( ((value >> 8) & 0xff) ) << 8 + | 0xff000000; + } case kRGB_888x_SkColorType: { uint32_t value = *this->addr32(x, y); return SkSwizzle_RB(value | 0xff000000); @@ -359,6 +366,7 @@ bool SkPixmap::computeIsOpaque() const { } break; case kRGB_565_SkColorType: case kGray_8_SkColorType: + case kRG_88_SkColorType: case kRGB_888x_SkColorType: case kRGB_101010x_SkColorType: return true; diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp index 4c01e60cb8..e316f88fea 100644 --- a/src/core/SkRasterPipeline.cpp +++ b/src/core/SkRasterPipeline.cpp @@ -168,6 +168,7 @@ void SkRasterPipeline::append_load(SkColorType ct, const SkRasterPipeline_Memory case kAlpha_8_SkColorType: this->append(load_a8, 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 kRGBA_8888_SkColorType: this->append(load_8888, ctx); break; case kRGBA_1010102_SkColorType: this->append(load_1010102, ctx); break; case kRGBA_F16Norm_SkColorType: @@ -199,6 +200,7 @@ void SkRasterPipeline::append_load_dst(SkColorType ct, const SkRasterPipeline_Me case kAlpha_8_SkColorType: this->append(load_a8_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 kRGBA_8888_SkColorType: this->append(load_8888_dst, ctx); break; case kRGBA_1010102_SkColorType: this->append(load_1010102_dst, ctx); break; case kRGBA_F16Norm_SkColorType: @@ -230,6 +232,7 @@ void SkRasterPipeline::append_store(SkColorType ct, const SkRasterPipeline_Memor case kAlpha_8_SkColorType: this->append(store_a8, 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 kRGBA_8888_SkColorType: this->append(store_8888, ctx); break; case kRGBA_1010102_SkColorType: this->append(store_1010102, ctx); break; case kRGBA_F16Norm_SkColorType: diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h index 8a3e0ccea8..8e7dc6d867 100644 --- a/src/core/SkRasterPipeline.h +++ b/src/core/SkRasterPipeline.h @@ -53,7 +53,7 @@ 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(store_rg88) \ + M(load_rg88) M(load_rg88_dst) M(store_rg88) M(gather_rg88) \ M(load_a16) M(store_a16) \ M(load_rg1616) M(store_rg1616) \ M(load_16161616) M(store_16161616) \ diff --git a/src/gpu/GrDataUtils.cpp b/src/gpu/GrDataUtils.cpp index c772f73bcc..91956e31ae 100644 --- a/src/gpu/GrDataUtils.cpp +++ b/src/gpu/GrDataUtils.cpp @@ -203,7 +203,7 @@ static bool fill_buffer_with_color(GrPixelConfig config, int width, int height, break; } case kRG_88_GrPixelConfig: { - uint16_t rg88 = (r << 8) | g; + uint16_t rg88 = (g << 8) | r; sk_memset16((uint16_t*) dest, rg88, width * height); break; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index f65f184e2f..b77fe5b5c5 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -86,8 +86,12 @@ sk_sp SkGpuDevice::Make(GrContext* context, if (!renderTargetContext || context->priv().abandoned()) { return nullptr; } + + SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorSpaceInfo().colorType()); + unsigned flags; - if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { + if (!context->colorTypeSupportedAsSurface(ct) || + !CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { return nullptr; } return sk_sp(new SkGpuDevice(context, std::move(renderTargetContext), flags)); @@ -98,7 +102,8 @@ sk_sp SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted, GrSurfaceOrigin origin, const SkSurfaceProps* props, GrMipMapped mipMapped, InitContents init) { unsigned flags; - if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { + if (!context->colorTypeSupportedAsSurface(info.colorType()) || + !CheckAlphaTypeAndGetFlags(&info, init, &flags)) { return nullptr; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index fd63056420..af99ad8446 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -257,6 +257,8 @@ GrPixelConfig SkColorType2GrPixelConfig(const SkColorType type) { return kRGBA_half_GrPixelConfig; case kRGBA_F32_SkColorType: return kRGBA_float_GrPixelConfig; + case kRG_88_SkColorType: + return kRG_88_GrPixelConfig; } SkASSERT(0); // shouldn't get here return kUnknown_GrPixelConfig; diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 2301f0d7ed..f848c8185d 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -42,6 +42,10 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) { return false; } + if (info.colorType() == kRG_88_SkColorType) { + return false; + } + if (kIgnoreRowBytesValue == rowBytes) { return true; } diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp index 884eb03f11..c902a730ea 100644 --- a/src/images/SkPngEncoder.cpp +++ b/src/images/SkPngEncoder.cpp @@ -315,6 +315,8 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info) { return transform_scanline_101010x; case kAlpha_8_SkColorType: return transform_scanline_A8_to_GrayAlpha; + case kRG_88_SkColorType: + return nullptr; } SkASSERT(false); return nullptr; diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 5dc6da9429..087e3e71ee 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -1983,16 +1983,27 @@ STAGE(store_8888, const SkRasterPipeline_MemoryCtx* ctx) { } STAGE(load_rg88, const SkRasterPipeline_MemoryCtx* ctx) { - auto ptr = ptr_at_xy(ctx, dx,dy); + auto ptr = ptr_at_xy(ctx, dx, dy); + from_88(load(ptr, tail), &r, &g); + b = 0; + a = 1; +} +STAGE(load_rg88_dst, const SkRasterPipeline_MemoryCtx* ctx) { + auto ptr = ptr_at_xy(ctx, dx, dy); + from_88(load(ptr, tail), &dr, &dg); + db = 0; + da = 1; +} +STAGE(gather_rg88, const SkRasterPipeline_GatherCtx* ctx) { + const uint16_t* ptr; + U32 ix = ix_and_ptr(&ptr, ctx, r, g); + from_88(gather(ptr, ix), &r, &g); b = 0; a = 1; - from_88(load(ptr, tail), &r,&g); } STAGE(store_rg88, const SkRasterPipeline_MemoryCtx* ctx) { - auto ptr = ptr_at_xy(ctx, dx,dy); - - U16 px = pack( to_unorm(r, 255) - | to_unorm(g, 255) << 8); + auto ptr = ptr_at_xy(ctx, dx, dy); + U16 px = pack( to_unorm(r, 255) | to_unorm(g, 255) << 8 ); store(ptr, px, tail); } @@ -3604,13 +3615,25 @@ SI void store_88_(uint16_t* ptr, size_t tail, U16 r, U16 g) { } STAGE_PP(load_rg88, const SkRasterPipeline_MemoryCtx* ctx) { + load_88_(ptr_at_xy(ctx, dx, dy), tail, &r, &g); b = 0; a = 255; - load_88_(ptr_at_xy(ctx, dx,dy), tail, &r,&g); +} +STAGE_PP(load_rg88_dst, const SkRasterPipeline_MemoryCtx* ctx) { + load_88_(ptr_at_xy(ctx, dx, dy), tail, &dr, &dg); + db = 0; + da = 255; } STAGE_PP(store_rg88, const SkRasterPipeline_MemoryCtx* ctx) { store_88_(ptr_at_xy(ctx, dx, dy), tail, r, g); } +STAGE_GP(gather_rg88, const SkRasterPipeline_GatherCtx* ctx) { + const uint16_t* ptr; + U32 ix = ix_and_ptr(&ptr, ctx, x, y); + from_88(gather(ptr, ix), &r, &g); + b = 0; + a = 255; +} // ~~~~~~ 8-bit memory loads and stores ~~~~~~ // diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index 57523c7c6a..8e39147666 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -423,6 +423,7 @@ bool SkImageShader::doStages(const SkStageRec& rec, SkImageStageUpdater* updater case kAlpha_8_SkColorType: p->append(SkRasterPipeline::gather_a8, 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 kRGBA_8888_SkColorType: p->append(SkRasterPipeline::gather_8888, ctx); break; case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::gather_1010102, ctx); break; case kRGBA_F16Norm_SkColorType: diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp index 70a1c6b6b2..8632dadd4d 100644 --- a/tests/BackendAllocationTest.cpp +++ b/tests/BackendAllocationTest.cpp @@ -47,7 +47,7 @@ void test_wrapping(GrContext* context, skiatest::Reporter* reporter, return; } - if (GrRenderable::kYes == renderable) { + if (GrRenderable::kYes == renderable && context->colorTypeSupportedAsSurface(skColorType)) { sk_sp surf = SkSurface::MakeFromBackendTexture(context, backendTex, kTopLeft_GrSurfaceOrigin, @@ -176,7 +176,7 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter, SkAssertResult(actual.tryAlloc(ii)); actual.erase(SkColors::kTransparent); - if (GrRenderable::kYes == renderable) { + if (GrRenderable::kYes == renderable && context->colorTypeSupportedAsSurface(skColorType)) { sk_sp surf = SkSurface::MakeFromBackendTexture(context, backendTex, kTopLeft_GrSurfaceOrigin, @@ -426,6 +426,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ColorTypeBackendAllocationTest, reporter, ctx { kRGBA_F16Norm_SkColorType, kRGBA_half_Clamped_GrPixelConfig, SkColors::kLtGray }, { kRGBA_F16_SkColorType, kRGBA_half_GrPixelConfig, SkColors::kYellow }, { kRGBA_F32_SkColorType, kRGBA_float_GrPixelConfig, SkColors::kGray }, + { kRG_88_SkColorType, kRG_88_GrPixelConfig, SkColors::kRed }, }; GR_STATIC_ASSERT(kLastEnum_SkColorType == SK_ARRAY_COUNT(combinations)); @@ -571,7 +572,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLBackendAllocationTest, reporter, ctxInfo) { { GrColorType::kRGBA_F16_Clamped, GR_GL_RGBA16F, SkColors::kLtGray }, { GrColorType::kRGBA_F16, GR_GL_RGBA16F, SkColors::kYellow }, - { GrColorType::kRG_88, GR_GL_RG8, { 0.5f, 0.5f, 0, 0 } }, + { GrColorType::kRG_88, GR_GL_RG8, { 1, 0.5f, 0, 1 } }, { GrColorType::kAlpha_F16, GR_GL_R16F, { 1.0f, 0, 0, 0.5f } }, { GrColorType::kAlpha_F16, GR_GL_LUMINANCE16F, kGrayCol }, @@ -707,7 +708,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest, reporter, ctxInfo) { { GrColorType::kRGBA_F16, VK_FORMAT_R16G16B16A16_SFLOAT, SkColors::kYellow }, // These backend formats don't have SkColorType equivalents - { GrColorType::kRG_88, VK_FORMAT_R8G8_UNORM, { 0.5f, 0.5f, 0, 0 }}, + { GrColorType::kRG_88, VK_FORMAT_R8G8_UNORM, { 1, 0.5f, 0, 1 } }, { GrColorType::kAlpha_F16, VK_FORMAT_R16_SFLOAT, { 1.0f, 0, 0, 0.5f }}, { GrColorType::kR_16, VK_FORMAT_R16_UNORM, SkColors::kRed }, diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index dbc51500fa..259ab085cf 100644 --- a/tests/BitmapTest.cpp +++ b/tests/BitmapTest.cpp @@ -178,20 +178,9 @@ DEF_TEST(Bitmap_eraseColor_Premul, r) { // Test that SkBitmap::ComputeOpaque() is correct for various colortypes. DEF_TEST(Bitmap_compute_is_opaque, r) { - SkColorType colorTypes[] = { - kAlpha_8_SkColorType, - kRGB_565_SkColorType, - kARGB_4444_SkColorType, - kRGBA_8888_SkColorType, - kRGB_888x_SkColorType, - kBGRA_8888_SkColorType, - kRGBA_1010102_SkColorType, - kRGB_101010x_SkColorType, - kGray_8_SkColorType, - kRGBA_F16_SkColorType, - kRGBA_F32_SkColorType, - }; - for (auto ct : colorTypes) { + + for (int i = 1; i <= kLastEnum_SkColorType; ++i) { + SkColorType ct = (SkColorType) i; SkBitmap bm; SkAlphaType at = SkColorTypeIsAlwaysOpaque(ct) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; bm.allocPixels(SkImageInfo::Make(13, 17, ct, at)); @@ -342,6 +331,7 @@ DEF_TEST(getalphaf, reporter) { } recs[] = { { kRGB_565_SkColorType, opaque }, { kGray_8_SkColorType, opaque }, + { kRG_88_SkColorType, opaque }, { kRGB_888x_SkColorType, opaque }, { kRGB_101010x_SkColorType, opaque }, diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp index 03b12e1cd9..7328dd0238 100644 --- a/tests/DeferredDisplayListTest.cpp +++ b/tests/DeferredDisplayListTest.cpp @@ -144,6 +144,10 @@ public: SkSurfaceCharacterization createCharacterization(GrContext* context) const { size_t maxResourceBytes = context->getResourceCacheLimit(); + if (!context->colorTypeSupportedAsSurface(fColorType)) { + return SkSurfaceCharacterization(); + } + // Note that Ganesh doesn't make use of the SkImageInfo's alphaType SkImageInfo ii = SkImageInfo::Make(fWidth, fHeight, fColorType, kPremul_SkAlphaType, fColorSpace); diff --git a/tests/ExtendedSkColorTypeTests.cpp b/tests/ExtendedSkColorTypeTests.cpp new file mode 100644 index 0000000000..db8fb65f6d --- /dev/null +++ b/tests/ExtendedSkColorTypeTests.cpp @@ -0,0 +1,294 @@ +/* + * Copyright 2019 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "include/core/SkImage.h" +#include "include/core/SkSurface.h" +#include "src/core/SkAutoPixmapStorage.h" +#include "src/gpu/GrContextPriv.h" + +#include "tests/Test.h" +#include "tests/TestUtils.h" + +static constexpr int kSize = 32; + +static SkColor4f get_trans_black_expected_color(SkColorTypeComponentFlag components) { + float a = 0; + if (!(components & kAlpha_SkColorTypeComponentFlag)) { + a = 1; + } + + return { 0, 0, 0, a }; +} + +static SkColor4f get_opaque_white_expected_color(SkColorTypeComponentFlag components) { + + if (components & kGray_SkColorTypeComponentFlag) { + return { 1, 1, 1, 1 }; + } + + float r = 1, g = 1, b = 1; + if (!(components & kRed_SkColorTypeComponentFlag)) { + r = 0; + } + if (!(components & kGreen_SkColorTypeComponentFlag)) { + g = 0; + } + if (!(components & kBlue_SkColorTypeComponentFlag)) { + b = 0; + } + + return { r, g, b, 1.0f }; +} + +struct TestCase { + SkColorType fColorType; + SkAlphaType fAlphaType; + SkColorTypeComponentFlag fComponents; + bool fCanMakeSurfaces; +}; + +static const TestCase gTests[] = { + { kAlpha_8_SkColorType, kPremul_SkAlphaType, kAlpha_SkColorTypeComponentFlag, true }, + { kRGB_565_SkColorType, kOpaque_SkAlphaType, kRGB_SkColorTypeComponentFlags, true }, + { kARGB_4444_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGBA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGB_888x_SkColorType, kOpaque_SkAlphaType, kRGB_SkColorTypeComponentFlags, true }, + { kBGRA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGBA_1010102_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGB_101010x_SkColorType, kOpaque_SkAlphaType, kRGB_SkColorTypeComponentFlags, true }, + { kGray_8_SkColorType, kOpaque_SkAlphaType, kGray_SkColorTypeComponentFlag, true }, + { kRGBA_F16Norm_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGBA_F16_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRGBA_F32_SkColorType, kPremul_SkAlphaType, kRGBA_SkColorTypeComponentFlags, true }, + { kRG_88_SkColorType, kOpaque_SkAlphaType, kRG_SkColorTypeComponentFlags, false } +}; + +static void raster_tests(skiatest::Reporter* reporter, const TestCase& test) { + + const SkImageInfo nativeII = SkImageInfo::Make(kSize, kSize, test.fColorType, test.fAlphaType); + const SkImageInfo f32Unpremul = SkImageInfo::Make(kSize, kSize, kRGBA_F32_SkColorType, + kUnpremul_SkAlphaType); + + uint32_t actualComponents = SkColorTypeComponentFlags(test.fColorType); + REPORTER_ASSERT(reporter, test.fComponents == actualComponents); + + // Not all colorTypes can be drawn to + { + auto s = SkSurface::MakeRaster(nativeII); + REPORTER_ASSERT(reporter, SkToBool(s) == test.fCanMakeSurfaces); + } + + // opaque formats should make transparent black become opaque + { + SkAutoPixmapStorage pm; + pm.alloc(nativeII); + pm.erase(SkColors::kTransparent); + SkColor actual = pm.getColor(0, 0); + SkColor4f expected = get_trans_black_expected_color(test.fComponents); + REPORTER_ASSERT(reporter, expected.toSkColor() == actual); + } + + // unused channels should drop out + { + SkAutoPixmapStorage pm; + pm.alloc(nativeII); + pm.erase(SkColors::kWhite); + SkColor actual = pm.getColor(0, 0); + SkColor4f expected = get_opaque_white_expected_color(test.fComponents); + REPORTER_ASSERT(reporter, expected.toSkColor() == actual); + } + + // Reading back from an image to the same colorType should always work + { + SkAutoPixmapStorage srcPM; + srcPM.alloc(nativeII); + srcPM.erase(SkColors::kWhite); + auto i = SkImage::MakeFromRaster(srcPM, nullptr, nullptr); + REPORTER_ASSERT(reporter, SkToBool(i)); + + SkAutoPixmapStorage readbackPM; + readbackPM.alloc(nativeII); + readbackPM.erase(SkColors::kTransparent); + + REPORTER_ASSERT(reporter, i->readPixels(readbackPM, 0, 0)); + + SkColor expected = srcPM.getColor(0, 0); + SkColor actual = readbackPM.getColor(0, 0); + REPORTER_ASSERT(reporter, expected == actual); + } + + // Rendering to an F32 surface should always work + { + SkAutoPixmapStorage srcPM; + srcPM.alloc(nativeII); + srcPM.erase(SkColors::kWhite); + auto i = SkImage::MakeFromRaster(srcPM, nullptr, nullptr); + REPORTER_ASSERT(reporter, SkToBool(i)); + + auto s = SkSurface::MakeRaster(f32Unpremul); + REPORTER_ASSERT(reporter, SkToBool(s)); + + { + auto c = s->getCanvas(); + c->drawImage(i, 0, 0); + } + + SkAutoPixmapStorage readbackPM; + readbackPM.alloc(f32Unpremul); + readbackPM.erase(SkColors::kTransparent); + + REPORTER_ASSERT(reporter, i->readPixels(readbackPM, 0, 0)); + + SkColor expected = srcPM.getColor(0, 0); + SkColor actual = readbackPM.getColor(0, 0); + REPORTER_ASSERT(reporter, expected == actual); + } +} + +static void compare_pixmaps(skiatest::Reporter* reporter, + const SkPixmap& expected, const SkPixmap& actual, + SkColorType nativeCT, const char* label) { + const float tols[4] = {0.0f, 0.0f, 0.0f, 0}; + + auto error = std::function( + [reporter, nativeCT, label](int x, int y, const float diffs[4]) { + SkASSERT(x >= 0 && y >= 0); + ERRORF(reporter, "%d %s - mismatch at %d, %d (%f, %f, %f %f)", + nativeCT, label, x, y, + diffs[0], diffs[1], diffs[2], diffs[3]); + }); + + compare_pixels(expected, actual, tols, error); +} + +static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const TestCase& test) { + + const SkImageInfo nativeII = SkImageInfo::Make(kSize, kSize, test.fColorType, test.fAlphaType); + const SkImageInfo f32Unpremul = SkImageInfo::Make(kSize, kSize, kRGBA_F32_SkColorType, + kUnpremul_SkAlphaType); + + // We had better not be able to render to prohibited colorTypes + if (!test.fCanMakeSurfaces) { + auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, nativeII); + REPORTER_ASSERT(reporter, !SkToBool(s)); + } + + if (!context->colorTypeSupportedAsImage(test.fColorType)) { + return; + } + + SkAutoPixmapStorage nativeExpected; + nativeExpected.alloc(nativeII); + nativeExpected.erase(SkColors::kWhite); + + for (bool fullInit : { false, true }) { + GrBackendTexture backendTex; + + if (fullInit) { + backendTex = context->priv().createBackendTexture(&nativeExpected, 1, + GrRenderable::kNo, + GrProtected::kNo); + } else { + backendTex = context->createBackendTexture(kSize, kSize, test.fColorType, + SkColors::kWhite, GrMipMapped::kNo, + GrRenderable::kNo, GrProtected::kNo); + } + REPORTER_ASSERT(reporter, backendTex.isValid()); + + auto img = SkImage::MakeFromTexture(context, backendTex, kTopLeft_GrSurfaceOrigin, + test.fColorType, test.fAlphaType, nullptr); + REPORTER_ASSERT(reporter, SkToBool(img)); + + { + SkAutoPixmapStorage nativeActual; + nativeActual.alloc(nativeII); + nativeActual.erase(SkColors::kTransparent); + + if (img->readPixels(nativeActual, 0, 0)) { + compare_pixmaps(reporter, nativeExpected, nativeActual, + test.fColorType, "SkImage::readPixels to native CT"); + } + + // SkSurface::readPixels with the same colorType as the source pixels round trips + // (when allowed) + if (context->colorTypeSupportedAsSurface(test.fColorType)) { + auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, nativeII); + REPORTER_ASSERT(reporter, SkToBool(s)); + + { + SkCanvas* c = s->getCanvas(); + c->drawImage(img, 0, 0); + } + + nativeActual.erase(SkColors::kTransparent); + REPORTER_ASSERT(reporter, s->readPixels(nativeActual, 0, 0)); + + compare_pixmaps(reporter, nativeExpected, nativeActual, + test.fColorType, "SkSurface::readPixels to native CT"); + } + } + + { + SkAutoPixmapStorage f32Expected; + f32Expected.alloc(f32Unpremul); + f32Expected.erase(get_opaque_white_expected_color(test.fComponents)); + + // read back to F32 if possible + { + SkAutoPixmapStorage f32Actual; + f32Actual.alloc(f32Unpremul); + f32Actual.erase(SkColors::kTransparent); + if (img->readPixels(f32Actual, 0, 0)) { + compare_pixmaps(reporter, f32Expected, f32Actual, + test.fColorType, "SkImage::readPixels to F32"); + } + } + + // drawing a native SkImage works appropriately (as assessed by reading back from an + // RGBA8 surface to an F32 pixmap) + { + const SkImageInfo rgba8888Premul = SkImageInfo::Make(kSize, kSize, + kRGBA_8888_SkColorType, + kPremul_SkAlphaType); + + auto s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, rgba8888Premul); + REPORTER_ASSERT(reporter, SkToBool(s)); + + { + SkCanvas* c = s->getCanvas(); + c->drawImage(img, 0, 0); + } + + SkAutoPixmapStorage f32Actual; + f32Actual.alloc(f32Unpremul); + f32Actual.erase(SkColors::kTransparent); + REPORTER_ASSERT(reporter, s->readPixels(f32Actual, 0, 0)); + + compare_pixmaps(reporter, f32Expected, f32Actual, + test.fColorType, "SkSurface::drawn to RGBA8888"); + } + } + + img.reset(); + context->flush(); + context->deleteBackendTexture(backendTex); + } +} + +DEF_TEST(ExtendedSkColorTypeTests_raster, reporter) { + for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { + raster_tests(reporter, gTests[i]); + } +} + +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ExtendedSkColorTypeTests_gpu, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + + for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { + gpu_tests(context, reporter, gTests[i]); + } +} diff --git a/tests/MtlBackendAllocationTest.mm b/tests/MtlBackendAllocationTest.mm index 3137e232d0..81803d63c8 100644 --- a/tests/MtlBackendAllocationTest.mm +++ b/tests/MtlBackendAllocationTest.mm @@ -63,7 +63,7 @@ DEF_GPUTEST_FOR_METAL_CONTEXT(MtlBackendAllocationTest, reporter, ctxInfo) { { GrColorType::kRGBA_F16_Clamped, MTLPixelFormatRGBA16Float, SkColors::kLtGray }, { GrColorType::kRGBA_F16, MTLPixelFormatRGBA16Float, SkColors::kYellow }, - { GrColorType::kRG_88, MTLPixelFormatRG8Unorm, { 0.5f, 0.5f, 0, 0 } }, + { GrColorType::kRG_88, MTLPixelFormatRG8Unorm, { 0.5f, 0.5f, 0, 1 } }, { GrColorType::kAlpha_F16, MTLPixelFormatR16Float, { 1.0f, 0, 0, 0.5f } }, { GrColorType::kR_16, MTLPixelFormatR16Unorm, SkColors::kRed }, diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 438f2cadfd..b1450a1927 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -626,6 +626,7 @@ static int min_rgb_channel_bits(SkColorType ct) { case kAlpha_8_SkColorType: return 8; case kRGB_565_SkColorType: return 5; case kARGB_4444_SkColorType: return 4; + case kRG_88_SkColorType: return 8; case kRGBA_8888_SkColorType: return 8; case kRGB_888x_SkColorType: return 8; case kBGRA_8888_SkColorType: return 8; diff --git a/tools/DDLPromiseImageHelper.cpp b/tools/DDLPromiseImageHelper.cpp index dc01185164..c35d83d80f 100644 --- a/tools/DDLPromiseImageHelper.cpp +++ b/tools/DDLPromiseImageHelper.cpp @@ -55,43 +55,23 @@ sk_sp DDLPromiseImageHelper::deflateSKP(const SkPicture* inputPicture) { return inputPicture->serialize(&procs); } -// needed until we have SkRG_88_ColorType; static GrBackendTexture create_yuva_texture(GrContext* context, const SkPixmap& pm, const SkYUVAIndex yuvaIndices[4], int texIndex) { SkASSERT(texIndex >= 0 && texIndex <= 3); + +#ifdef SK_DEBUG int channelCount = 0; for (int i = 0; i < SkYUVAIndex::kIndexCount; ++i) { if (yuvaIndices[i].fIndex == texIndex) { ++channelCount; } } - // Need to create an RG texture for two-channel planes - GrBackendTexture tex; if (2 == channelCount) { - const GrCaps* caps = context->priv().caps(); - GrGpu* gpu = context->priv().getGpu(); - - SkASSERT(kRGBA_8888_SkColorType == pm.colorType()); - SkAutoTMalloc pixels(2 * pm.width()*pm.height()); - char* currPixel = pixels; - for (int y = 0; y < pm.height(); ++y) { - for (int x = 0; x < pm.width(); ++x) { - SkColor color = pm.getColor(x, y); - currPixel[0] = SkColorGetR(color); - currPixel[1] = SkColorGetG(color); - currPixel += 2; - } - } - - GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRG_88, - GrRenderable::kNo); - tex = gpu->createBackendTexture(pm.width(), pm.height(), format, - GrMipMapped::kNo, GrRenderable::kNo, - pixels, 2 * pm.width(), nullptr, GrProtected::kNo); - } else { - tex = context->priv().createBackendTexture(&pm, 1, GrRenderable::kNo, GrProtected::kNo); + SkASSERT(kRG_88_SkColorType == pm.colorType()); } - return tex; +#endif + + return context->priv().createBackendTexture(&pm, 1, GrRenderable::kNo, GrProtected::kNo); } void DDLPromiseImageHelper::uploadAllToGPU(GrContext* context) { @@ -281,7 +261,7 @@ int DDLPromiseImageHelper::addImage(SkImage* image) { newImageInfo.setYUVData(std::move(yuvData), yuvaIndices, yuvColorSpace); // determine colortypes from index data - // for testing we only ever use A8 or RGBA8888 + // for testing we only ever use A8, RG_88 SkColorType colorTypes[SkYUVASizeInfo::kMaxCount] = { kUnknown_SkColorType, kUnknown_SkColorType, kUnknown_SkColorType, kUnknown_SkColorType @@ -295,7 +275,7 @@ int DDLPromiseImageHelper::addImage(SkImage* image) { if (kUnknown_SkColorType == colorTypes[texIdx]) { colorTypes[texIdx] = kAlpha_8_SkColorType; } else { - colorTypes[texIdx] = kRGBA_8888_SkColorType; + colorTypes[texIdx] = kRG_88_SkColorType; } } diff --git a/tools/HashAndEncode.cpp b/tools/HashAndEncode.cpp index e8a819ee08..2188308847 100644 --- a/tools/HashAndEncode.cpp +++ b/tools/HashAndEncode.cpp @@ -39,6 +39,7 @@ HashAndEncode::HashAndEncode(const SkBitmap& bitmap) : fSize(bitmap.info().dimen srcAlpha = skcms_AlphaFormat_Opaque; break; case kRGB_101010x_SkColorType: srcFmt = skcms_PixelFormat_RGBA_1010102; srcAlpha = skcms_AlphaFormat_Opaque; break; + case kRG_88_SkColorType: return; } skcms_ICCProfile srcProfile = *skcms_sRGB_profile(); diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp index f954d8772e..5f1a4c0220 100644 --- a/tools/ToolUtils.cpp +++ b/tools/ToolUtils.cpp @@ -61,6 +61,7 @@ const char* colortype_name(SkColorType ct) { case kRGBA_F16Norm_SkColorType: return "RGBA_F16Norm"; case kRGBA_F16_SkColorType: return "RGBA_F16"; case kRGBA_F32_SkColorType: return "RGBA_F32"; + case kRG_88_SkColorType: return "RG_88"; } SkASSERT(false); return "unexpected colortype"; @@ -81,6 +82,7 @@ const char* colortype_depth(SkColorType ct) { case kRGBA_F16Norm_SkColorType: return "F16Norm"; // TODO: "F16"? case kRGBA_F16_SkColorType: return "F16"; case kRGBA_F32_SkColorType: return "F32"; + case kRG_88_SkColorType: return "88"; } SkASSERT(false); return "unexpected colortype";