1010102, 101010x, 888x in sw

Same sort of deal as before, now with all three new formats.
While I was at it, I made sure RGBA 8888 and BGRA 8888 both work too.

We don't want the 101010's in lowp, but 888x should be fine.

After looking at the DM images on monitors at work, I decided to
re-enable dither even on 10-bit images.

Looking at the GMs in 888x or 101010x is interesting... I think we must
not be clearing the memory allocated for layers?  Seems like we want to
allocate layers as 8888?

Change-Id: I3a85b4f00877792a6425a7e7eb31eacb04ae9218
Reviewed-on: https://skia-review.googlesource.com/101640
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index ac8cdd9..e926353 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -168,16 +168,19 @@
         is_opaque = is_opaque && (colorFilter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag);
     }
 
-    // Not all formats make sense to dither (think, F16).  We set their dither rate to zero.
-    // We need to decide if we're going to dither now to keep is_constant accurate.
+    // Not all formats make sense to dither (think, F16).  We set their dither rate
+    // 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;
+            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:
+            case  kRGB_888x_SkColorType:
             case kRGBA_8888_SkColorType:
-            case kBGRA_8888_SkColorType: blitter->fDitherRate = 1/255.0f; break;
+            case kBGRA_8888_SkColorType:    blitter->fDitherRate =  1/255.0f; break;
+            case kRGB_101010x_SkColorType:
+            case kRGBA_1010102_SkColorType: blitter->fDitherRate = 1/1023.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
@@ -227,15 +230,23 @@
 }
 
 void SkRasterPipelineBlitter::append_load_dst(SkRasterPipeline* p) const {
+    const void* ctx = &fDstPtr;
     switch (fDst.info().colorType()) {
-        case kGray_8_SkColorType:    p->append(SkRasterPipeline::load_g8_dst,   &fDstPtr); break;
-        case kAlpha_8_SkColorType:   p->append(SkRasterPipeline::load_a8_dst,   &fDstPtr); break;
-        case kRGB_565_SkColorType:   p->append(SkRasterPipeline::load_565_dst,  &fDstPtr); break;
-        case kARGB_4444_SkColorType: p->append(SkRasterPipeline::load_4444_dst, &fDstPtr); break;
-        case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::load_bgra_dst, &fDstPtr); break;
-        case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::load_8888_dst, &fDstPtr); break;
-        case kRGBA_F16_SkColorType:  p->append(SkRasterPipeline::load_f16_dst,  &fDstPtr); break;
-        default:                                                                           break;
+        default: break;
+
+        case kGray_8_SkColorType:       p->append(SkRasterPipeline::load_g8_dst,      ctx); break;
+        case kAlpha_8_SkColorType:      p->append(SkRasterPipeline::load_a8_dst,      ctx); break;
+        case kRGB_565_SkColorType:      p->append(SkRasterPipeline::load_565_dst,     ctx); break;
+        case kARGB_4444_SkColorType:    p->append(SkRasterPipeline::load_4444_dst,    ctx); break;
+        case kBGRA_8888_SkColorType:    p->append(SkRasterPipeline::load_bgra_dst,    ctx); break;
+        case kRGBA_8888_SkColorType:    p->append(SkRasterPipeline::load_8888_dst,    ctx); break;
+        case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::load_1010102_dst, ctx); break;
+        case kRGBA_F16_SkColorType:     p->append(SkRasterPipeline::load_f16_dst,     ctx); break;
+
+        case kRGB_888x_SkColorType:     p->append(SkRasterPipeline::load_8888_dst,    ctx);
+                                        p->append(SkRasterPipeline::force_opaque_dst     ); break;
+        case kRGB_101010x_SkColorType:  p->append(SkRasterPipeline::load_1010102_dst, ctx);
+                                        p->append(SkRasterPipeline::force_opaque_dst     ); break;
     }
     if (fDst.info().gammaCloseToSRGB()) {
         p->append(SkRasterPipeline::from_srgb_dst);
@@ -258,15 +269,24 @@
         p->append(SkRasterPipeline::dither, &fDitherRate);
     }
 
+    const void* ctx = &fDstPtr;
     switch (fDst.info().colorType()) {
-        case kGray_8_SkColorType:    p->append(SkRasterPipeline::luminance_to_alpha); // fallthru
-        case kAlpha_8_SkColorType:   p->append(SkRasterPipeline::store_a8,   &fDstPtr); break;
-        case kRGB_565_SkColorType:   p->append(SkRasterPipeline::store_565,  &fDstPtr); break;
-        case kARGB_4444_SkColorType: p->append(SkRasterPipeline::store_4444, &fDstPtr); break;
-        case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::store_bgra, &fDstPtr); break;
-        case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::store_8888, &fDstPtr); break;
-        case kRGBA_F16_SkColorType:  p->append(SkRasterPipeline::store_f16,  &fDstPtr); break;
         default: break;
+
+        case kGray_8_SkColorType:       p->append(SkRasterPipeline::luminance_to_alpha);
+                                        p->append(SkRasterPipeline::store_a8,      ctx); break;
+        case kAlpha_8_SkColorType:      p->append(SkRasterPipeline::store_a8,      ctx); break;
+        case kRGB_565_SkColorType:      p->append(SkRasterPipeline::store_565,     ctx); break;
+        case kARGB_4444_SkColorType:    p->append(SkRasterPipeline::store_4444,    ctx); break;
+        case kBGRA_8888_SkColorType:    p->append(SkRasterPipeline::store_bgra,    ctx); break;
+        case kRGBA_8888_SkColorType:    p->append(SkRasterPipeline::store_8888,    ctx); break;
+        case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::store_1010102, ctx); break;
+        case kRGBA_F16_SkColorType:     p->append(SkRasterPipeline::store_f16,     ctx); break;
+
+        case kRGB_888x_SkColorType:     p->append(SkRasterPipeline::force_opaque         );
+                                        p->append(SkRasterPipeline::store_8888,       ctx); break;
+        case kRGB_101010x_SkColorType:  p->append(SkRasterPipeline::force_opaque         );
+                                        p->append(SkRasterPipeline::store_1010102,    ctx); break;
     }
 }