basic, untested BGR 1010102 and 101010x

Updated every switch that yelled at me, and added support to dm and fm,
and then founds some more switches that shouldn't have defaults...

The tricky spots outside those were mips and dither,
since they aren't simply exhaustive switches.

_Now_ no diffs between RGB/BGR 1010102 and 101010x.

No GPU support.

Bug: skia:9893
Change-Id: I73ab3fd22bdef0519296dfe4cb84031e23ca0be3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270114
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 1914561..ba68db0 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -957,23 +957,25 @@
 #define SINK(t, sink, ...) if (config->getBackend().equals(t)) return new sink(__VA_ARGS__)
 
     if (FLAGS_cpu) {
-        SINK("g8",      RasterSink, kGray_8_SkColorType);
-        SINK("565",     RasterSink, kRGB_565_SkColorType);
-        SINK("4444",    RasterSink, kARGB_4444_SkColorType);
-        SINK("8888",    RasterSink, kN32_SkColorType);
-        SINK("rgba",    RasterSink, kRGBA_8888_SkColorType);
-        SINK("bgra",    RasterSink, kBGRA_8888_SkColorType);
-        SINK("rgbx",    RasterSink, kRGB_888x_SkColorType);
-        SINK("1010102", RasterSink, kRGBA_1010102_SkColorType);
-        SINK("101010x", RasterSink, kRGB_101010x_SkColorType);
-        SINK("pdf",     PDFSink, false, SK_ScalarDefaultRasterDPI);
-        SINK("skp",     SKPSink);
-        SINK("svg",     SVGSink);
-        SINK("null",    NullSink);
-        SINK("xps",     XPSSink);
-        SINK("pdfa",    PDFSink, true,  SK_ScalarDefaultRasterDPI);
-        SINK("pdf300",  PDFSink, false, 300);
-        SINK("jsdebug", DebugSink);
+        SINK("g8",          RasterSink, kGray_8_SkColorType);
+        SINK("565",         RasterSink, kRGB_565_SkColorType);
+        SINK("4444",        RasterSink, kARGB_4444_SkColorType);
+        SINK("8888",        RasterSink, kN32_SkColorType);
+        SINK("rgba",        RasterSink, kRGBA_8888_SkColorType);
+        SINK("bgra",        RasterSink, kBGRA_8888_SkColorType);
+        SINK("rgbx",        RasterSink, kRGB_888x_SkColorType);
+        SINK("1010102",     RasterSink, kRGBA_1010102_SkColorType);
+        SINK("101010x",     RasterSink, kRGB_101010x_SkColorType);
+        SINK("bgra1010102", RasterSink, kBGRA_1010102_SkColorType);
+        SINK("bgr101010x",  RasterSink, kBGR_101010x_SkColorType);
+        SINK("pdf",         PDFSink, false, SK_ScalarDefaultRasterDPI);
+        SINK("skp",         SKPSink);
+        SINK("svg",         SVGSink);
+        SINK("null",        NullSink);
+        SINK("xps",         XPSSink);
+        SINK("pdfa",        PDFSink, true,  SK_ScalarDefaultRasterDPI);
+        SINK("pdf300",      PDFSink, false, 300);
+        SINK("jsdebug",     DebugSink);
 
         // Configs relevant to color management testing (and 8888 for reference).
 
diff --git a/docs/examples/unexpected_setAlphaType.cpp b/docs/examples/unexpected_setAlphaType.cpp
index 52df753..1ec1d9f 100644
--- a/docs/examples/unexpected_setAlphaType.cpp
+++ b/docs/examples/unexpected_setAlphaType.cpp
@@ -25,6 +25,8 @@
         case kBGRA_8888_SkColorType:          return "BGRA_8888";
         case kRGBA_1010102_SkColorType:       return "RGBA_1010102";
         case kRGB_101010x_SkColorType:        return "RGB_101010x";
+        case kBGRA_1010102_SkColorType:       return "BGRA_1010102";
+        case kBGR_101010x_SkColorType:        return "BGR_101010x";
         case kGray_8_SkColorType:             return "Gray_8";
         case kRGBA_F16Norm_SkColorType:       return "RGBA_F16Norm";
         case kRGBA_F16_SkColorType:           return "RGBA_F16";
diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp
index 4f8b59c..1761860 100644
--- a/gm/bitmapcopy.cpp
+++ b/gm/bitmapcopy.cpp
@@ -36,6 +36,8 @@
         case kBGRA_8888_SkColorType:          return "8888";
         case kRGBA_1010102_SkColorType:       return "1010102";
         case kRGB_101010x_SkColorType:        return "101010x";
+        case kBGRA_1010102_SkColorType:       return "bgra1010102";
+        case kBGR_101010x_SkColorType:        return "bgr101010x";
         case kGray_8_SkColorType:             return "G8";
         case kRGBA_F16Norm_SkColorType:       return "F16Norm";
         case kRGBA_F16_SkColorType:           return "F16";
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 68c7968..98a6547 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -76,7 +76,9 @@
     kRGB_888x_SkColorType,     //!< pixel with 8 bits each for red, green, blue; in 32-bit word
     kBGRA_8888_SkColorType,    //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
     kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
+    kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
     kRGB_101010x_SkColorType,  //!< pixel with 10 bits each for red, green, blue; in 32-bit word
+    kBGR_101010x_SkColorType,  //!< pixel with 10 bits each for blue, green, red; in 32-bit word
     kGray_8_SkColorType,       //!< pixel with grayscale level in 8-bit byte
     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
@@ -127,15 +129,6 @@
     kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned,
     canonical is ignored.
 
-    For kUnknown_SkColorType: set canonical to kUnknown_SkAlphaType and return true.
-    For kAlpha_8_SkColorType: set canonical to kPremul_SkAlphaType or
-    kOpaque_SkAlphaType and return true if alphaType is not kUnknown_SkAlphaType.
-    For kRGB_565_SkColorType, kRGB_888x_SkColorType, kRGB_101010x_SkColorType, and
-    kGray_8_SkColorType: set canonical to kOpaque_SkAlphaType and return true.
-    For kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
-    kRGBA_1010102_SkColorType, and kRGBA_F16_SkColorType: set canonical to alphaType
-    and return true if alphaType is not kUnknown_SkAlphaType.
-
     @param canonical  storage for SkAlphaType
     @return           true if valid SkAlphaType can be associated with colorType
 */
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index c3504db..00167d7 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -865,6 +865,8 @@
         case kRGBA_F16_SkColorType:           return GrColorType::kRGBA_F16;
         case kRGBA_1010102_SkColorType:       return GrColorType::kRGBA_1010102;
         case kRGB_101010x_SkColorType:        return GrColorType::kUnknown;
+        case kBGRA_1010102_SkColorType:       return GrColorType::kUnknown;
+        case kBGR_101010x_SkColorType:        return GrColorType::kUnknown;
         case kRGBA_F32_SkColorType:           return GrColorType::kRGBA_F32;
         case kR8G8_unorm_SkColorType:         return GrColorType::kRG_88;
         case kA16_unorm_SkColorType:          return GrColorType::kAlpha_16;
diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h
index 15f0224..c55e2a9 100644
--- a/include/private/SkImageInfoPriv.h
+++ b/include/private/SkImageInfoPriv.h
@@ -36,6 +36,8 @@
         case kBGRA_8888_SkColorType:          return kRGBA_SkColorTypeComponentFlags;
         case kRGBA_1010102_SkColorType:       return kRGBA_SkColorTypeComponentFlags;
         case kRGB_101010x_SkColorType:        return kRGB_SkColorTypeComponentFlags;
+        case kBGRA_1010102_SkColorType:       return kRGBA_SkColorTypeComponentFlags;
+        case kBGR_101010x_SkColorType:        return kRGB_SkColorTypeComponentFlags;
         case kGray_8_SkColorType:             return kGray_SkColorTypeComponentFlag;
         case kRGBA_F16Norm_SkColorType:       return kRGBA_SkColorTypeComponentFlags;
         case kRGBA_F16_SkColorType:           return kRGBA_SkColorTypeComponentFlags;
@@ -69,6 +71,8 @@
         case kBGRA_8888_SkColorType:          return 2;
         case kRGBA_1010102_SkColorType:       return 2;
         case kRGB_101010x_SkColorType:        return 2;
+        case kBGRA_1010102_SkColorType:       return 2;
+        case kBGR_101010x_SkColorType:        return 2;
         case kGray_8_SkColorType:             return 0;
         case kRGBA_F16Norm_SkColorType:       return 3;
         case kRGBA_F16_SkColorType:           return 3;
@@ -109,6 +113,8 @@
         case kBGRA_8888_SkColorType:
         case kRGBA_1010102_SkColorType:
         case kRGB_101010x_SkColorType:
+        case kBGRA_1010102_SkColorType:
+        case kBGR_101010x_SkColorType:
         case kGray_8_SkColorType:
         case kRGBA_F16Norm_SkColorType:
         case kR8G8_unorm_SkColorType:
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index ca50a95..2eb840c 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -102,7 +102,8 @@
         case kR16G16_unorm_SkColorType:
         case kR16G16_float_SkColorType:
         case kRGB_888x_SkColorType:
-        case kRGB_101010x_SkColorType: {
+        case kRGB_101010x_SkColorType:
+        case kBGR_101010x_SkColorType: {
             for (int y = 0; y < srcInfo.height(); ++y) {
                memset(dst, 0xFF, srcInfo.width());
                dst = SkTAddOffset<uint8_t>(dst, dstRB);
@@ -135,7 +136,8 @@
             return true;
         }
 
-        case kRGBA_1010102_SkColorType: {
+        case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType: {
             auto src32 = (const uint32_t*) src;
             for (int y = 0; y < srcInfo.height(); y++) {
                 for (int x = 0; x < srcInfo.width(); x++) {
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp
index e6e12bc..b5179f8 100644
--- a/src/core/SkImageInfo.cpp
+++ b/src/core/SkImageInfo.cpp
@@ -21,6 +21,8 @@
         case kRGB_888x_SkColorType:           return 4;
         case kRGBA_1010102_SkColorType:       return 4;
         case kRGB_101010x_SkColorType:        return 4;
+        case kBGRA_1010102_SkColorType:       return 4;
+        case kBGR_101010x_SkColorType:        return 4;
         case kGray_8_SkColorType:             return 1;
         case kRGBA_F16Norm_SkColorType:       return 8;
         case kRGBA_F16_SkColorType:           return 8;
@@ -93,6 +95,7 @@
         case kRGBA_8888_SkColorType:
         case kBGRA_8888_SkColorType:
         case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType:
         case kRGBA_F16Norm_SkColorType:
         case kRGBA_F16_SkColorType:
         case kRGBA_F32_SkColorType:
@@ -108,10 +111,9 @@
         case kRGB_565_SkColorType:
         case kRGB_888x_SkColorType:
         case kRGB_101010x_SkColorType:
+        case kBGR_101010x_SkColorType:
             alphaType = kOpaque_SkAlphaType;
             break;
-        default:
-            return false;
     }
     if (canonical) {
         *canonical = alphaType;
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index 21cf377..225c4a4 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -495,6 +495,7 @@
             proc_3_3 = downsample_3_3<ColorTypeFilter_16>;
             break;
         case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType:
             proc_1_2 = downsample_1_2<ColorTypeFilter_1010102>;
             proc_1_3 = downsample_1_3<ColorTypeFilter_1010102>;
             proc_2_1 = downsample_2_1<ColorTypeFilter_1010102>;
@@ -534,7 +535,12 @@
             proc_3_2 = downsample_3_2<ColorTypeFilter_16161616>;
             proc_3_3 = downsample_3_3<ColorTypeFilter_16161616>;
             break;
-        default:
+
+        case kUnknown_SkColorType:
+        case kRGB_888x_SkColorType:     // TODO: use 8888?
+        case kRGB_101010x_SkColorType:  // TODO: use 1010102?
+        case kBGR_101010x_SkColorType:  // TODO: use 1010102?
+        case kRGBA_F32_SkColorType:
             return nullptr;
     }
 
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index c8a09ff..1e6ddd1 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -106,6 +106,7 @@
         case kRGB_565_SkColorType:
         case kRGB_888x_SkColorType:
         case kRGB_101010x_SkColorType:
+        case kBGR_101010x_SkColorType:
             return 1;
         case kAlpha_8_SkColorType:
             value = static_cast<const uint8_t*>(srcPtr)[0] * (1.0f/255);
@@ -127,7 +128,8 @@
         case kBGRA_8888_SkColorType:
             value = static_cast<const uint8_t*>(srcPtr)[3] * (1.0f/255);
             break;
-        case kRGBA_1010102_SkColorType: {
+        case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType: {
             uint32_t u32 = static_cast<const uint32_t*>(srcPtr)[0];
             value = (u32 >> 30) * (1.0f/3);
             break;
@@ -333,13 +335,25 @@
                  | (uint32_t)( ((value >> 20) & 0x3ff) * (255/1023.0f) ) <<  0
                  | 0xff000000;
         }
-        case kRGBA_1010102_SkColorType: {
+        case kBGR_101010x_SkColorType: {
+            uint32_t value = *this->addr32(x, y);
+            // Convert 10-bit bgr to 8-bit bgr, and mask in 0xff alpha at the top.
+            return (uint32_t)( ((value >>  0) & 0x3ff) * (255/1023.0f) ) <<  0
+                 | (uint32_t)( ((value >> 10) & 0x3ff) * (255/1023.0f) ) <<  8
+                 | (uint32_t)( ((value >> 20) & 0x3ff) * (255/1023.0f) ) << 16
+                 | 0xff000000;
+        }
+        case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType: {
             uint32_t value = *this->addr32(x, y);
 
             float r = ((value >>  0) & 0x3ff) * (1/1023.0f),
                   g = ((value >> 10) & 0x3ff) * (1/1023.0f),
                   b = ((value >> 20) & 0x3ff) * (1/1023.0f),
                   a = ((value >> 30) & 0x3  ) * (1/   3.0f);
+            if (this->colorType() == kBGRA_1010102_SkColorType) {
+                std::swap(r,b);
+            }
             if (a != 0 && needsUnpremul) {
                 r = SkTPin(r/a, 0.0f, 1.0f);
                 g = SkTPin(g/a, 0.0f, 1.0f);
@@ -395,10 +409,11 @@
             // p4 is RGBA, but we want BGRA, so we need to swap next
             return SkSwizzle_RB(c);
         }
-        default:
-            SkDEBUGFAIL("");
-            return SkColorSetARGB(0, 0, 0, 0);
+        case kUnknown_SkColorType:
+            break;
     }
+    SkDEBUGFAIL("");
+    return SkColorSetARGB(0, 0, 0, 0);
 }
 
 bool SkPixmap::computeIsOpaque() const {
@@ -450,6 +465,7 @@
         case kR16G16_float_SkColorType:
         case kRGB_888x_SkColorType:
         case kRGB_101010x_SkColorType:
+        case kBGR_101010x_SkColorType:
             return true;
             break;
         case kARGB_4444_SkColorType: {
@@ -504,7 +520,8 @@
             }
             return true;
         }
-        case kRGBA_1010102_SkColorType: {
+        case kRGBA_1010102_SkColorType:
+        case kBGRA_1010102_SkColorType: {
             uint32_t c = ~0;
             for (int y = 0; y < height; ++y) {
                 const uint32_t* row = this->addr32(0, y);
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 8711c10..2a4fbd0 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -190,10 +190,19 @@
                                              this->append(force_opaque);
                                              break;
 
+        case kBGRA_1010102_SkColorType:      this->append(load_1010102, ctx);
+                                             this->append(swap_rb);
+                                             break;
+
         case kRGB_101010x_SkColorType:       this->append(load_1010102, ctx);
                                              this->append(force_opaque);
                                              break;
 
+        case kBGR_101010x_SkColorType:       this->append(load_1010102, ctx);
+                                             this->append(force_opaque);
+                                             this->append(swap_rb);
+                                             break;
+
         case kBGRA_8888_SkColorType:         this->append(load_8888, ctx);
                                              this->append(swap_rb);
                                              break;
@@ -227,10 +236,19 @@
                                               this->append(force_opaque_dst);
                                               break;
 
+        case kBGRA_1010102_SkColorType:       this->append(load_1010102_dst, ctx);
+                                              this->append(swap_rb_dst);
+                                              break;
+
         case kRGB_101010x_SkColorType:        this->append(load_1010102_dst, ctx);
                                               this->append(force_opaque_dst);
                                               break;
 
+        case kBGR_101010x_SkColorType:        this->append(load_1010102_dst, ctx);
+                                              this->append(force_opaque_dst);
+                                              this->append(swap_rb_dst);
+                                              break;
+
         case kBGRA_8888_SkColorType:          this->append(load_8888_dst, ctx);
                                               this->append(swap_rb_dst);
                                               break;
@@ -260,10 +278,19 @@
                                               this->append(store_8888, ctx);
                                               break;
 
+        case kBGRA_1010102_SkColorType:       this->append(swap_rb);
+                                              this->append(store_1010102, ctx);
+                                              break;
+
         case kRGB_101010x_SkColorType:        this->append(force_opaque);
                                               this->append(store_1010102, ctx);
                                               break;
 
+        case kBGR_101010x_SkColorType:        this->append(force_opaque);
+                                              this->append(swap_rb);
+                                              this->append(store_1010102, ctx);
+                                              break;
+
         case kGray_8_SkColorType:             this->append(bt709_luminance_or_luma_to_alpha);
                                               this->append(store_a8, ctx);
                                               break;
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index b983d3b..3fd6366 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -162,7 +162,6 @@
     // to zero.  We need to decide if we're going to dither now to keep is_constant accurate.
     if (paint.isDither()) {
         switch (dst.info().colorType()) {
-            default:                        blitter->fDitherRate =      0.0f; break;
             case kARGB_4444_SkColorType:    blitter->fDitherRate =   1/15.0f; break;
             case   kRGB_565_SkColorType:    blitter->fDitherRate =   1/63.0f; break;
             case    kGray_8_SkColorType:
@@ -170,7 +169,21 @@
             case kRGBA_8888_SkColorType:
             case kBGRA_8888_SkColorType:    blitter->fDitherRate =  1/255.0f; break;
             case kRGB_101010x_SkColorType:
-            case kRGBA_1010102_SkColorType: blitter->fDitherRate = 1/1023.0f; break;
+            case kRGBA_1010102_SkColorType:
+            case kBGR_101010x_SkColorType:
+            case kBGRA_1010102_SkColorType: blitter->fDitherRate = 1/1023.0f; break;
+
+            case kUnknown_SkColorType:
+            case kAlpha_8_SkColorType:
+            case kRGBA_F16_SkColorType:
+            case kRGBA_F16Norm_SkColorType:
+            case kRGBA_F32_SkColorType:
+            case kR8G8_unorm_SkColorType:
+            case kA16_float_SkColorType:
+            case kA16_unorm_SkColorType:
+            case kR16G16_float_SkColorType:
+            case kR16G16_unorm_SkColorType:
+            case kR16G16B16A16_unorm_SkColorType: blitter->fDitherRate = 0.0f; break;
         }
         // TODO: for constant colors, we could try to measure the effect of dithering, and if
         //       it has no value (i.e. all variations result in the same 32bit color, then we
diff --git a/src/core/SkVMBlitter.cpp b/src/core/SkVMBlitter.cpp
index 3c2cfeb..4fefc69 100644
--- a/src/core/SkVMBlitter.cpp
+++ b/src/core/SkVMBlitter.cpp
@@ -319,7 +319,6 @@
 
             float dither_rate = 0.0f;
             switch (params.colorType) {
-                default:                        dither_rate =      0.0f; break;
                 case kARGB_4444_SkColorType:    dither_rate =   1/15.0f; break;
                 case   kRGB_565_SkColorType:    dither_rate =   1/63.0f; break;
                 case    kGray_8_SkColorType:
@@ -327,7 +326,21 @@
                 case kRGBA_8888_SkColorType:
                 case kBGRA_8888_SkColorType:    dither_rate =  1/255.0f; break;
                 case kRGB_101010x_SkColorType:
-                case kRGBA_1010102_SkColorType: dither_rate = 1/1023.0f; break;
+                case kRGBA_1010102_SkColorType:
+                case kBGR_101010x_SkColorType:
+                case kBGRA_1010102_SkColorType: dither_rate = 1/1023.0f; break;
+
+                case kUnknown_SkColorType:
+                case kAlpha_8_SkColorType:
+                case kRGBA_F16_SkColorType:
+                case kRGBA_F16Norm_SkColorType:
+                case kRGBA_F32_SkColorType:
+                case kR8G8_unorm_SkColorType:
+                case kA16_float_SkColorType:
+                case kA16_unorm_SkColorType:
+                case kR16G16_float_SkColorType:
+                case kR16G16_unorm_SkColorType:
+                case kR16G16B16A16_unorm_SkColorType: dither_rate = 0.0f; break;
             }
             if (params.dither && dither_rate > 0) {
                 // See SkRasterPipeline dither stage.
diff --git a/src/images/SkImageEncoderFns.h b/src/images/SkImageEncoderFns.h
index 42b9dd7..fece76c 100644
--- a/src/images/SkImageEncoderFns.h
+++ b/src/images/SkImageEncoderFns.h
@@ -113,6 +113,24 @@
           skcms_PixelFormat_RGBA_16161616BE, skcms_AlphaFormat_Unpremul);
 }
 
+static inline void transform_scanline_bgr_101010x(char* dst, const char* src, int width, int) {
+    skcms(dst, src, width,
+          skcms_PixelFormat_BGRA_1010102, skcms_AlphaFormat_Unpremul,
+          skcms_PixelFormat_RGB_161616BE, skcms_AlphaFormat_Unpremul);
+}
+
+static inline void transform_scanline_bgra_1010102(char* dst, const char* src, int width, int) {
+    skcms(dst, src, width,
+          skcms_PixelFormat_BGRA_1010102,    skcms_AlphaFormat_Unpremul,
+          skcms_PixelFormat_RGBA_16161616BE, skcms_AlphaFormat_Unpremul);
+}
+
+static inline void transform_scanline_bgra_1010102_premul(char* dst, const char* src, int width, int) {
+    skcms(dst, src, width,
+          skcms_PixelFormat_BGRA_1010102,    skcms_AlphaFormat_PremulAsEncoded,
+          skcms_PixelFormat_RGBA_16161616BE, skcms_AlphaFormat_Unpremul);
+}
+
 static inline void transform_scanline_F16(char* dst, const char* src, int width, int) {
     skcms(dst, src, width,
           skcms_PixelFormat_RGBA_hhhh,       skcms_AlphaFormat_Unpremul,
diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp
index 831d356..f0a8bf9 100644
--- a/src/images/SkPngEncoder.cpp
+++ b/src/images/SkPngEncoder.cpp
@@ -312,8 +312,20 @@
                     SkASSERT(false);
                     return nullptr;
             }
-        case kRGB_101010x_SkColorType:
-            return transform_scanline_101010x;
+        case kBGRA_1010102_SkColorType:
+            switch (info.alphaType()) {
+                case kOpaque_SkAlphaType:
+                case kUnpremul_SkAlphaType:
+                    return transform_scanline_bgra_1010102;
+                case kPremul_SkAlphaType:
+                    return transform_scanline_bgra_1010102_premul;
+                default:
+                    SkASSERT(false);
+                    return nullptr;
+            }
+        case kRGB_101010x_SkColorType: return transform_scanline_101010x;
+        case kBGR_101010x_SkColorType: return transform_scanline_bgr_101010x;
+
         case kAlpha_8_SkColorType:
             return transform_scanline_A8_to_GrayAlpha;
         case kR8G8_unorm_SkColorType:
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index f82772c..9e6a3fc 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -460,9 +460,16 @@
             case kRGB_888x_SkColorType:     p->append(SkRasterPipeline::gather_8888,    ctx);
                                             p->append(SkRasterPipeline::force_opaque       ); break;
 
+            case kBGRA_1010102_SkColorType: p->append(SkRasterPipeline::gather_1010102, ctx);
+                                            p->append(SkRasterPipeline::swap_rb            ); break;
+
             case kRGB_101010x_SkColorType:  p->append(SkRasterPipeline::gather_1010102, ctx);
                                             p->append(SkRasterPipeline::force_opaque       ); break;
 
+            case kBGR_101010x_SkColorType:  p->append(SkRasterPipeline::gather_1010102, ctx);
+                                            p->append(SkRasterPipeline::force_opaque       );
+                                            p->append(SkRasterPipeline::swap_rb            ); break;
+
             case kBGRA_8888_SkColorType:    p->append(SkRasterPipeline::gather_8888,    ctx);
                                             p->append(SkRasterPipeline::swap_rb            ); break;
 
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index 527ddeb..a177089 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -594,8 +594,10 @@
         { kBGRA_8888_SkColorType,         { 1, 0, 0, 1.0f }        },
         // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
         { kRGBA_1010102_SkColorType,      { .25f, .5f, .75f, 1.0f }},
-        // The kRGB_101010x_SkColorType has no Ganesh correlate
+        // RGB/BGR 101010x and BGRA 1010102 have no Ganesh correlate
         { kRGB_101010x_SkColorType,       { 0, 0.5f, 0, 0.5f }     },
+        { kBGRA_1010102_SkColorType,      { 0, 0.5f, 0, 0.5f }     },
+        { kBGR_101010x_SkColorType,       { 0, 0.5f, 0, 0.5f }     },
         { kGray_8_SkColorType,            kGrayCol                 },
         { kRGBA_F16Norm_SkColorType,      SkColors::kLtGray        },
         { kRGBA_F16_SkColorType,          SkColors::kYellow        },
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 675ce44..64f8eed 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -592,6 +592,8 @@
         case kBGRA_8888_SkColorType:          return 8;
         case kRGBA_1010102_SkColorType:       return 10;
         case kRGB_101010x_SkColorType:        return 10;
+        case kBGRA_1010102_SkColorType:       return 10;
+        case kBGR_101010x_SkColorType:        return 10;
         case kGray_8_SkColorType:             return 8;   // counting gray as "rgb"
         case kRGBA_F16Norm_SkColorType:       return 10;  // just counting the mantissa
         case kRGBA_F16_SkColorType:           return 10;  // just counting the mantissa
@@ -617,6 +619,8 @@
         case kBGRA_8888_SkColorType:          return 8;
         case kRGBA_1010102_SkColorType:       return 2;
         case kRGB_101010x_SkColorType:        return 0;
+        case kBGRA_1010102_SkColorType:       return 2;
+        case kBGR_101010x_SkColorType:        return 0;
         case kGray_8_SkColorType:             return 0;
         case kRGBA_F16Norm_SkColorType:       return 10;  // just counting the mantissa
         case kRGBA_F16_SkColorType:           return 10;  // just counting the mantissa
@@ -693,8 +697,8 @@
         } else if (!rules.fAllowUnpremulRead && readAT == kUnpremul_SkAlphaType) {
             REPORTER_ASSERT(reporter, !success);
         } else if (!success) {
-            // TODO: Support kRGB_101010x at all in GPU.
-            if (readCT != kRGB_101010x_SkColorType) {
+            // TODO: Support RGB/BGR 101010x, BGRA 1010102 on the GPU.
+            if (SkColorTypeToGrColorType(readCT) != GrColorType::kUnknown) {
                 ERRORF(reporter,
                        "Read failed. Src CT: %s, Src AT: %s Read CT: %s, Read AT: %s, "
                        "Rect [%d, %d, %d, %d], CS conversion: %d\n",
@@ -811,7 +815,8 @@
         // We could but 1010102 premul is kind of dubious anyway. So for now just keep the data
         // opaque.
         if (srcAT != kOpaque_SkAlphaType &&
-            (srcAT == kPremul_SkAlphaType && srcCT != kRGBA_1010102_SkColorType)) {
+            (srcAT == kPremul_SkAlphaType && srcCT != kRGBA_1010102_SkColorType
+                                          && srcCT != kBGRA_1010102_SkColorType)) {
             static constexpr SkColor kColors3[] = {SK_ColorWHITE,
                                                    SK_ColorWHITE,
                                                    0x60FFFFFF,
diff --git a/tools/HashAndEncode.cpp b/tools/HashAndEncode.cpp
index 76d4b76..c50ca30 100644
--- a/tools/HashAndEncode.cpp
+++ b/tools/HashAndEncode.cpp
@@ -30,6 +30,7 @@
         case kRGBA_8888_SkColorType:          srcFmt = skcms_PixelFormat_RGBA_8888;    break;
         case kBGRA_8888_SkColorType:          srcFmt = skcms_PixelFormat_BGRA_8888;    break;
         case kRGBA_1010102_SkColorType:       srcFmt = skcms_PixelFormat_RGBA_1010102; break;
+        case kBGRA_1010102_SkColorType:       srcFmt = skcms_PixelFormat_BGRA_1010102; break;
         case kGray_8_SkColorType:             srcFmt = skcms_PixelFormat_G_8;          break;
         case kRGBA_F16Norm_SkColorType:       srcFmt = skcms_PixelFormat_RGBA_hhhh;    break;
         case kRGBA_F16_SkColorType:           srcFmt = skcms_PixelFormat_RGBA_hhhh;    break;
@@ -39,6 +40,8 @@
                                               srcAlpha = skcms_AlphaFormat_Opaque;     break;
         case kRGB_101010x_SkColorType:        srcFmt = skcms_PixelFormat_RGBA_1010102;
                                               srcAlpha = skcms_AlphaFormat_Opaque;     break;
+        case kBGR_101010x_SkColorType:        srcFmt = skcms_PixelFormat_BGRA_1010102;
+                                              srcAlpha = skcms_AlphaFormat_Opaque;     break;
         case kR8G8_unorm_SkColorType:         return;
         case kR16G16_unorm_SkColorType:       return;
         case kR16G16_float_SkColorType:       return;
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
index f8af706..b41e985 100644
--- a/tools/ToolUtils.cpp
+++ b/tools/ToolUtils.cpp
@@ -59,6 +59,8 @@
         case kBGRA_8888_SkColorType:          return "BGRA_8888";
         case kRGBA_1010102_SkColorType:       return "RGBA_1010102";
         case kRGB_101010x_SkColorType:        return "RGB_101010x";
+        case kBGRA_1010102_SkColorType:       return "BGRA_1010102";
+        case kBGR_101010x_SkColorType:        return "BGR_101010x";
         case kGray_8_SkColorType:             return "Gray_8";
         case kRGBA_F16Norm_SkColorType:       return "RGBA_F16Norm";
         case kRGBA_F16_SkColorType:           return "RGBA_F16";
@@ -85,6 +87,8 @@
         case kBGRA_8888_SkColorType:          return "8888";
         case kRGBA_1010102_SkColorType:       return "1010102";
         case kRGB_101010x_SkColorType:        return "101010";
+        case kBGRA_1010102_SkColorType:       return "1010102";
+        case kBGR_101010x_SkColorType:        return "101010";
         case kGray_8_SkColorType:             return "G8";
         case kRGBA_F16Norm_SkColorType:       return "F16Norm";  // TODO: "F16"?
         case kRGBA_F16_SkColorType:           return "F16";
diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp
index 53ef7c9..afc7d8b 100644
--- a/tools/fm/fm.cpp
+++ b/tools/fm/fm.cpp
@@ -501,19 +501,21 @@
         { "mock"           , GrContextFactory::kMock_ContextType },
     };
     const FlagOption<SkColorType> kColorTypes[] = {
-        { "a8",           kAlpha_8_SkColorType },
-        { "g8",            kGray_8_SkColorType },
-        { "565",          kRGB_565_SkColorType },
-        { "4444",       kARGB_4444_SkColorType },
-        { "8888",             kN32_SkColorType },
-        { "888x",        kRGB_888x_SkColorType },
-        { "1010102", kRGBA_1010102_SkColorType },
-        { "101010x",  kRGB_101010x_SkColorType },
-        { "f16norm", kRGBA_F16Norm_SkColorType },
-        { "f16",         kRGBA_F16_SkColorType },
-        { "f32",         kRGBA_F32_SkColorType },
-        { "rgba",       kRGBA_8888_SkColorType },
-        { "bgra",       kBGRA_8888_SkColorType },
+        { "a8",               kAlpha_8_SkColorType },
+        { "g8",                kGray_8_SkColorType },
+        { "565",              kRGB_565_SkColorType },
+        { "4444",           kARGB_4444_SkColorType },
+        { "8888",                 kN32_SkColorType },
+        { "888x",            kRGB_888x_SkColorType },
+        { "1010102",     kRGBA_1010102_SkColorType },
+        { "101010x",      kRGB_101010x_SkColorType },
+        { "bgra1010102", kBGRA_1010102_SkColorType },
+        { "bgr101010x",   kBGR_101010x_SkColorType },
+        { "f16norm",     kRGBA_F16Norm_SkColorType },
+        { "f16",             kRGBA_F16_SkColorType },
+        { "f32",             kRGBA_F32_SkColorType },
+        { "rgba",           kRGBA_8888_SkColorType },
+        { "bgra",           kBGRA_8888_SkColorType },
     };
     const FlagOption<SkAlphaType> kAlphaTypes[] = {
         {   "premul",   kPremul_SkAlphaType },