Premultiply in DM before drawing unpremul f16
authorLeon Scroggins III <scroggo@google.com>
Tue, 23 May 2017 20:58:09 +0000 (16:58 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 24 May 2017 12:05:11 +0000 (12:05 +0000)
We special case N32, but need to also handle f16

Change-Id: I0d6061d55e55c5952c740255e4600366d8d77919
Reviewed-on: https://skia-review.googlesource.com/17786
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>

dm/DMSrcSink.cpp

index 8979d2d..643a1a4 100644 (file)
@@ -326,6 +326,16 @@ static void premultiply_if_necessary(SkBitmap& bitmap) {
     }
 
     switch (bitmap.colorType()) {
+        case kRGBA_F16_SkColorType:
+            for (int y = 0; y < bitmap.height(); y++) {
+                void* row = bitmap.getAddr(0, y);
+                SkRasterPipeline p;
+                p.append(SkRasterPipeline::load_f16, &row);
+                p.append(SkRasterPipeline::premul);
+                p.append(SkRasterPipeline::store_f16, &row);
+                p.run(0, bitmap.width());
+            }
+            break;
         case kN32_SkColorType:
             for (int y = 0; y < bitmap.height(); y++) {
                 uint32_t* row = (uint32_t*) bitmap.getAddr(0, y);