remove unused SkImageEncoderFns bits

  - remove a couple transform_scanline_procs
  - remove all use of SK_RESTRICT
  - remove the color table
  - reformat arguments etc.

Change-Id: I545dc6d74fffc7d95e3d53fb26ee748b94f93b65
Reviewed-on: https://skia-review.googlesource.com/c/167683
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/src/images/SkImageEncoderFns.h b/src/images/SkImageEncoderFns.h
index df5957b..60cb84c 100644
--- a/src/images/SkImageEncoderFns.h
+++ b/src/images/SkImageEncoderFns.h
@@ -8,62 +8,23 @@
 #ifndef SkImageEncoderFns_DEFINED
 #define SkImageEncoderFns_DEFINED
 
-/**
- * Functions to transform scanlines between packed-pixel formats.
- */
-
 #include "SkBitmap.h"
 #include "SkColor.h"
 #include "SkColorData.h"
 #include "SkICC.h"
 #include "SkOpts.h"
-#include "SkPreConfig.h"
 #include "SkRasterPipeline.h"
+#include "SkTypes.h"
 #include "SkUnPreMultiply.h"
 #include "SkUnPreMultiplyPriv.h"
 
-/**
- * Function template for transforming scanlines.
- * Transform 'width' pixels from 'src' buffer into 'dst' buffer,
- * repacking color channel data as appropriate for the given transformation.
- * 'bpp' is bytes per pixel in the 'src' buffer.
- */
-typedef void (*transform_scanline_proc)(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                        int width, int bpp, const SkPMColor* colors);
+typedef void (*transform_scanline_proc)(char* dst, const char* src, int width, int bpp);
 
-/**
- * Identity transformation: just copy bytes from src to dst.
- */
-static inline void transform_scanline_memcpy(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                             int width, int bpp, const SkPMColor*) {
+static inline void transform_scanline_memcpy(char* dst, const char* src, int width, int bpp) {
     memcpy(dst, src, width * bpp);
 }
 
-static inline void transform_scanline_index8_opaque(char* SK_RESTRICT dst,
-                                                    const char* SK_RESTRICT src, int width, int,
-                                                    const SkPMColor* colors) {
-    for (int i = 0; i < width; i++) {
-        const uint32_t c = colors[(uint8_t)*src++];
-        dst[0] = SkGetPackedR32(c);
-        dst[1] = SkGetPackedG32(c);
-        dst[2] = SkGetPackedB32(c);
-        dst += 3;
-    }
-}
-
-static inline void transform_scanline_index8_unpremul(char* SK_RESTRICT dst,
-                                                      const char* SK_RESTRICT src, int width, int,
-                                                      const SkPMColor* colors) {
-    uint32_t* SK_RESTRICT dst32 = (uint32_t*) dst;
-    for (int i = 0; i < width; i++) {
-        // This function swizzles R and B on platforms where SkPMColor is BGRA.  This is
-        // exactly what we want.
-        dst32[i] = SkSwizzle_RGBA_to_PMColor(colors[(uint8_t)*src++]);
-    }
-}
-
-static inline void transform_scanline_gray(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor* colors) {
+static inline void transform_scanline_gray(char* dst, const char* src, int width, int) {
     for (int i = 0; i < width; i++) {
         const uint8_t g = (uint8_t) *src++;
         dst[0] = g;
@@ -73,13 +34,7 @@
     }
 }
 
-/**
- * Transform from kRGB_565_Config to 3-bytes-per-pixel RGB.
- * Alpha channel data is not present in kRGB_565_Config format, so there is no
- * alpha channel data to preserve.
- */
-static inline void transform_scanline_565(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                          int width, int, const SkPMColor*) {
+static inline void transform_scanline_565(char* dst, const char* src, int width, int) {
     const uint16_t* srcP = (const uint16_t*)src;
     for (int i = 0; i < width; i++) {
         unsigned c = *srcP++;
@@ -89,24 +44,14 @@
     }
 }
 
-/**
- * Transform from kAlpha_8_Config to 2-bytes-per-pixel GrayAlpha.
- */
-static inline void transform_scanline_A8_to_GrayAlpha(char* SK_RESTRICT dst,
-                                                      const char* SK_RESTRICT src,
-                                                      int width, int, const SkPMColor*) {
+static inline void transform_scanline_A8_to_GrayAlpha(char* dst, const char* src, int width, int) {
     for (int i = 0; i < width; i++) {
         *dst++ = 0;         // gray (ignored)
         *dst++ = *src++;    // alpha
     }
 }
 
-/**
- * Transform from kRGBA_8888_SkColorType to 3-bytes-per-pixel RGB.
- * Alpha channel data is abandoned.
- */
-static inline void transform_scanline_RGBX(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_RGBX(char* dst, const char* src, int width, int) {
     const uint32_t* srcP = (const SkPMColor*)src;
     for (int i = 0; i < width; i++) {
         uint32_t c = *srcP++;
@@ -116,12 +61,7 @@
     }
 }
 
-/**
- * Transform from kBGRA_8888_SkColorType to 3-bytes-per-pixel RGB.
- * Alpha channel data is abandoned.
- */
-static inline void transform_scanline_BGRX(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_BGRX(char* dst, const char* src, int width, int) {
     const uint32_t* srcP = (const SkPMColor*)src;
     for (int i = 0; i < width; i++) {
         uint32_t c = *srcP++;
@@ -131,12 +71,7 @@
     }
 }
 
-/**
- * Transform from kARGB_4444_Config to 3-bytes-per-pixel RGB.
- * Alpha channel data, if any, is abandoned.
- */
-static inline void transform_scanline_444(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                          int width, int, const SkPMColor*) {
+static inline void transform_scanline_444(char* dst, const char* src, int width, int) {
     const SkPMColor16* srcP = (const SkPMColor16*)src;
     for (int i = 0; i < width; i++) {
         SkPMColor16 c = *srcP++;
@@ -146,36 +81,19 @@
     }
 }
 
-/**
- * Transform from legacy kPremul, kRGBA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
- */
-static inline void transform_scanline_rgbA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_rgbA(char* dst, const char* src, int width, int) {
     SkUnpremultiplyRow<false>((uint32_t*) dst, (const uint32_t*) src, width);
 }
 
-/**
- * Transform from legacy kPremul, kBGRA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
- */
-static inline void transform_scanline_bgrA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_bgrA(char* dst, const char* src, int width, int) {
     SkUnpremultiplyRow<true>((uint32_t*) dst, (const uint32_t*) src, width);
 }
 
-/**
- * Premultiply RGBA to rgbA.
- */
-static inline void transform_scanline_to_premul_legacy(char* SK_RESTRICT dst,
-                                                       const char* SK_RESTRICT src,
-                                                       int width, int, const SkPMColor*) {
+static inline void transform_scanline_to_premul_legacy(char* dst, const char* src, int width, int) {
     SkOpts::RGBA_to_rgbA((uint32_t*)dst, (const uint32_t*)src, width);
 }
 
-/**
- * Transform from kUnpremul, kBGRA_8888_SkColorType to 4-bytes-per-pixel unpremultiplied RGBA.
- */
-static inline void transform_scanline_BGRA(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_BGRA(char* dst, const char* src, int width, int) {
     const uint32_t* srcP = (const SkPMColor*)src;
     for (int i = 0; i < width; i++) {
         uint32_t c = *srcP++;
@@ -186,12 +104,7 @@
     }
 }
 
-/**
- * Transform from kARGB_8888_Config to 4-bytes-per-pixel RGBA,
- * with scaling of RGB based on alpha channel.
- */
-static inline void transform_scanline_4444(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_4444(char* dst, const char* src, int width, int) {
     const SkPMColor16* srcP = (const SkPMColor16*)src;
     const SkUnPreMultiply::Scale* table = SkUnPreMultiply::GetScaleTable();
 
@@ -215,9 +128,7 @@
     }
 }
 
-// 888x is opaque RGB in four bytes, with 8 junk bits.  We convert that to 3 byte RGB.
-static inline void transform_scanline_888x(char* dst, const char* src,
-                                           int width, int, const SkPMColor*) {
+static inline void transform_scanline_888x(char* dst, const char* src, int width, int) {
     while (width --> 0) {
         dst[0] = src[0];
         dst[1] = src[1];
@@ -227,9 +138,7 @@
     }
 }
 
-// 101010x is opaque RGB in four bytes, with 2 bits junk.  We convert to 6 byte RGB (big endian).
-static inline void transform_scanline_101010x(char* dst, const char* src,
-                                              int width, int, const SkPMColor*) {
+static inline void transform_scanline_101010x(char* dst, const char* src, int width, int) {
     auto d = (      uint16_t*)dst;
     auto s = (const uint32_t*)src;
     while (width --> 0) {
@@ -252,8 +161,7 @@
     }
 }
 
-static inline void transform_scanline_1010102(char* dst, const char* src,
-                                              int width, int, const SkPMColor*) {
+static inline void transform_scanline_1010102(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -262,8 +170,7 @@
     p.run(0,0, width,1);
 }
 
-static inline void transform_scanline_1010102_premul(char* dst, const char* src,
-                                                     int width, int, const SkPMColor*) {
+static inline void transform_scanline_1010102_premul(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -273,11 +180,7 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kRGBA_F16 to 8-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F16(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                          int width, int, const SkPMColor*) {
+static inline void transform_scanline_F16(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -288,11 +191,7 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kPremul, kRGBA_F16 to 8-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F16_premul(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                                 int width, int, const SkPMColor*) {
+static inline void transform_scanline_F16_premul(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -304,12 +203,7 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kRGBA_F16 to 4-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F16_to_8888(char* SK_RESTRICT dst,
-                                                  const char* SK_RESTRICT src, int width, int,
-                                                  const SkPMColor*) {
+static inline void transform_scanline_F16_to_8888(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -320,12 +214,10 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kPremul, kRGBA_F16 to 4-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F16_premul_to_8888(char* SK_RESTRICT dst,
-                                                         const char* SK_RESTRICT src, int width,
-                                                         int, const SkPMColor*) {
+static inline void transform_scanline_F16_premul_to_8888(char* dst,
+                                                         const char* src,
+                                                         int width,
+                                                         int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -337,11 +229,10 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kUnpremul, kRGBA_F16 to premultiplied rgbA 8888.
- */
-static inline void transform_scanline_F16_to_premul_8888(char* SK_RESTRICT dst,
-        const char* SK_RESTRICT src, int width, int, const SkPMColor*) {
+static inline void transform_scanline_F16_to_premul_8888(char* dst,
+                                                         const char* src,
+                                                         int width,
+                                                         int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -353,11 +244,7 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kRGBA_F32 to 8-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F32(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                          int width, int, const SkPMColor*) {
+static inline void transform_scanline_F32(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
@@ -368,11 +255,7 @@
     p.run(0,0, width,1);
 }
 
-/**
- * Transform from kPremul, kRGBA_F32 to 8-bytes-per-pixel RGBA.
- */
-static inline void transform_scanline_F32_premul(char* SK_RESTRICT dst, const char* SK_RESTRICT src,
-                                                 int width, int, const SkPMColor*) {
+static inline void transform_scanline_F32_premul(char* dst, const char* src, int width, int) {
     SkRasterPipeline_MemoryCtx src_ctx = { (void*)src, 0 },
                                dst_ctx = { (void*)dst, 0 };
     SkRasterPipeline_<256> p;
diff --git a/src/images/SkJpegEncoder.cpp b/src/images/SkJpegEncoder.cpp
index 239f9d8..d6828b4 100644
--- a/src/images/SkJpegEncoder.cpp
+++ b/src/images/SkJpegEncoder.cpp
@@ -221,8 +221,10 @@
     for (int i = 0; i < numRows; i++) {
         JSAMPLE* jpegSrcRow = (JSAMPLE*) srcRow;
         if (fEncoderMgr->proc()) {
-            fEncoderMgr->proc()((char*)fStorage.get(), (const char*)srcRow, fSrc.width(),
-                                fEncoderMgr->cinfo()->input_components, nullptr);
+            fEncoderMgr->proc()((char*)fStorage.get(),
+                                (const char*)srcRow,
+                                fSrc.width(),
+                                fEncoderMgr->cinfo()->input_components);
             jpegSrcRow = fStorage.get();
         }
 
diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp
index 685e611..3c8bb3b 100644
--- a/src/images/SkPngEncoder.cpp
+++ b/src/images/SkPngEncoder.cpp
@@ -409,8 +409,10 @@
 
     const void* srcRow = fSrc.addr(0, fCurrRow);
     for (int y = 0; y < numRows; y++) {
-        fEncoderMgr->proc()((char*) fStorage.get(), (const char*) srcRow, fSrc.width(),
-                            SkColorTypeBytesPerPixel(fSrc.colorType()), nullptr);
+        fEncoderMgr->proc()((char*)fStorage.get(),
+                            (const char*)srcRow,
+                            fSrc.width(),
+                            SkColorTypeBytesPerPixel(fSrc.colorType()));
 
         png_bytep rowPtr = (png_bytep) fStorage.get();
         png_write_rows(fEncoderMgr->pngPtr(), &rowPtr, 1);
diff --git a/src/images/SkWebpEncoder.cpp b/src/images/SkWebpEncoder.cpp
index 580f608..d516511 100644
--- a/src/images/SkWebpEncoder.cpp
+++ b/src/images/SkWebpEncoder.cpp
@@ -124,8 +124,6 @@
         return false;
     }
 
-    const SkPMColor* colors = nullptr;
-
     WebPConfig webp_config;
     if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, opts.fQuality)) {
         return false;
@@ -169,7 +167,10 @@
     // to RGB color space.
     std::unique_ptr<uint8_t[]> rgb(new uint8_t[rgbStride * pic.height]);
     for (int y = 0; y < pic.height; ++y) {
-        proc((char*) &rgb[y * rgbStride], (const char*) &src[y * rowBytes], pic.width, bpp, colors);
+        proc((char*) &rgb[y * rgbStride],
+             (const char*) &src[y * rowBytes],
+             pic.width,
+             bpp);
     }
 
     auto importProc = WebPPictureImportRGB;