Rename SkConfig8888/SkPixelInfo to SkConvertPixels

BUG=skia:

Change-Id: I4f3c6370b3ef4247aa446716c7c154899925d089
Reviewed-on: https://skia-review.googlesource.com/8442
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/bench/PremulAndUnpremulAlphaOpsBench.cpp b/bench/PremulAndUnpremulAlphaOpsBench.cpp
index a6b7a8c..89c9bd5 100644
--- a/bench/PremulAndUnpremulAlphaOpsBench.cpp
+++ b/bench/PremulAndUnpremulAlphaOpsBench.cpp
@@ -7,7 +7,6 @@
 
 #include "Benchmark.h"
 #include "SkCanvas.h"
-#include "SkConfig8888.h"
 #include "SkString.h"
 #include "sk_tool_utils.h"
 
diff --git a/gn/core.gni b/gn/core.gni
index 4ac3d56..d702919 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -88,8 +88,8 @@
   "$_src/core/SkColorSpaceXform_A2B.h",
   "$_src/core/SkColorTable.cpp",
   "$_src/core/SkComposeShader.cpp",
-  "$_src/core/SkConfig8888.cpp",
-  "$_src/core/SkConfig8888.h",
+  "$_src/core/SkConvertPixels.cpp",
+  "$_src/core/SkConvertPixels.h",
   "$_src/core/SkConvolver.cpp",
   "$_src/core/SkConvolver.h",
   "$_src/core/SkCoreBlitters.h",
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 3357549..bcc57a1 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -8,7 +8,7 @@
 #include "SkAtomics.h"
 #include "SkBitmap.h"
 #include "SkColorPriv.h"
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkData.h"
 #include "SkFilterQuality.h"
 #include "SkHalf.h"
@@ -726,8 +726,8 @@
 
     void* dstPixels = this->getAddr(rec.fX, rec.fY);
     const SkImageInfo dstInfo = fInfo.makeWH(rec.fInfo.width(), rec.fInfo.height());
-    SkPixelInfo::CopyPixels(dstInfo, dstPixels, this->rowBytes(), rec.fInfo, rec.fPixels,
-                            rec.fRowBytes, src.ctable());
+    SkConvertPixels(dstInfo, dstPixels, this->rowBytes(), rec.fInfo, rec.fPixels, rec.fRowBytes,
+                    src.ctable());
     return true;
 }
 
@@ -847,8 +847,8 @@
         return false;
     }
     const SkPixmap& pmap = apl.pixmap();
-    SkPixelInfo::CopyPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
-                            pmap.info(), pmap.addr(), pmap.rowBytes(), pmap.ctable());
+    SkConvertPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
+                    pmap.info(), pmap.addr(), pmap.rowBytes(), pmap.ctable());
     return true;
 }
 
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 5742e1d..8ed5120 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -6,7 +6,6 @@
  */
 
 #include "SkBitmapDevice.h"
-#include "SkConfig8888.h"
 #include "SkDraw.h"
 #include "SkImageFilter.h"
 #include "SkImageFilterCache.h"
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConvertPixels.cpp
similarity index 89%
rename from src/core/SkConfig8888.cpp
rename to src/core/SkConvertPixels.cpp
index 616ba19..50d375b 100644
--- a/src/core/SkConfig8888.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -5,18 +5,15 @@
  * found in the LICENSE file.
  */
 
-#include "SkBitmap.h"
-#include "SkCanvas.h"
 #include "SkColorSpaceXform.h"
 #include "SkColorSpaceXformPriv.h"
-#include "SkConfig8888.h"
-#include "SkColorPriv.h"
-#include "SkDither.h"
+#include "SkColorTable.h"
+#include "SkConvertPixels.h"
 #include "SkImageInfoPriv.h"
-#include "SkMathPriv.h"
 #include "SkOpts.h"
 #include "SkPM4fPriv.h"
 #include "SkRasterPipeline.h"
+#include "SkUnPreMultiply.h"
 #include "SkUnPreMultiplyPriv.h"
 
 // Fast Path 1: The memcpy() case.
@@ -41,6 +38,7 @@
            SkColorSpace::Equals(dstInfo.colorSpace(), srcInfo.colorSpace());
 }
 
+// Fast Path 2: Simple swizzles and premuls.
 enum AlphaVerb {
     kNothing_AlphaVerb,
     kPremul_AlphaVerb,
@@ -52,7 +50,6 @@
     SkUnpremultiplyRow<kSwapRB>(dst, (const uint32_t*) src, count);
 }
 
-// Fast Path 2: Simple swizzles and premuls.
 void swizzle_and_multiply(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
                           const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB) {
     void (*proc)(uint32_t* dst, const void* src, int count);
@@ -88,10 +85,123 @@
     }
 }
 
+// Fast Path 3: Color space xform.
+static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) {
+    if (kUnpremul_SkAlphaType == dstInfo.alphaType() && kPremul_SkAlphaType == srcInfo.alphaType())
+    {
+        return false;
+    }
+
+    switch (dstInfo.colorType()) {
+        case kRGBA_8888_SkColorType:
+        case kBGRA_8888_SkColorType:
+        case kRGBA_F16_SkColorType:
+            break;
+        default:
+            return false;
+    }
+
+    switch (srcInfo.colorType()) {
+        case kRGBA_8888_SkColorType:
+        case kBGRA_8888_SkColorType:
+            break;
+        default:
+            return false;
+    }
+
+    return true;
+}
+
+static inline void apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
+                                     const SkImageInfo& srcInfo, const void* srcPixels,
+                                     size_t srcRB) {
+    SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
+    SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(srcInfo.colorType());
+    SkAlphaType xformAlpha;
+    switch (srcInfo.alphaType()) {
+        case kOpaque_SkAlphaType:
+            xformAlpha = kOpaque_SkAlphaType;
+            break;
+        case kPremul_SkAlphaType:
+            SkASSERT(kPremul_SkAlphaType == dstInfo.alphaType());
+
+            // This signal means: copy the src alpha to the dst, do not premultiply (in this
+            // case because the pixels are already premultiplied).
+            xformAlpha = kUnpremul_SkAlphaType;
+            break;
+        case kUnpremul_SkAlphaType:
+            SkASSERT(kPremul_SkAlphaType == dstInfo.alphaType() ||
+                     kUnpremul_SkAlphaType == dstInfo.alphaType());
+
+            xformAlpha = dstInfo.alphaType();
+            break;
+        default:
+            SkASSERT(false);
+            xformAlpha = kUnpremul_SkAlphaType;
+            break;
+    }
+
+    std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcInfo.colorSpace(),
+                                                                      dstInfo.colorSpace());
+    SkASSERT(xform);
+
+    for (int y = 0; y < dstInfo.height(); y++) {
+        SkAssertResult(xform->apply(dstFormat, dstPixels, srcFormat, srcPixels, dstInfo.width(),
+                       xformAlpha));
+        dstPixels = SkTAddOffset<void>(dstPixels, dstRB);
+        srcPixels = SkTAddOffset<const void>(srcPixels, srcRB);
+    }
+}
+
+// Fast Path 4: Index 8 sources.
+template <typename T>
+void do_index8(const SkImageInfo& dstInfo, T* dstPixels, size_t dstRB,
+               const SkImageInfo& srcInfo, const uint8_t* srcPixels, size_t srcRB,
+               SkColorTable* ctable) {
+    T dstCTable[256];
+    int count = ctable->count();
+    SkImageInfo srcInfo8888 = srcInfo.makeColorType(kN32_SkColorType).makeWH(count, 1);
+    SkImageInfo dstInfoCT = dstInfo.makeWH(count, 1);
+    size_t rowBytes = count * sizeof(T);
+    SkConvertPixels(dstInfoCT, dstCTable, rowBytes, srcInfo8888, ctable->readColors(), rowBytes,
+                    nullptr);
+
+    for (int y = 0; y < dstInfo.height(); y++) {
+        for (int x = 0; x < dstInfo.width(); x++) {
+            dstPixels[x] = dstCTable[srcPixels[x]];
+        }
+        dstPixels = SkTAddOffset<T>(dstPixels, dstRB);
+        srcPixels = SkTAddOffset<const uint8_t>(srcPixels, srcRB);
+    }
+}
+
+void convert_from_index8(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
+                         const SkImageInfo& srcInfo, const uint8_t* srcPixels, size_t srcRB,
+                         SkColorTable* ctable) {
+    switch (dstInfo.colorType()) {
+        case kAlpha_8_SkColorType:
+            do_index8(dstInfo, (uint8_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
+            break;
+        case kRGB_565_SkColorType:
+        case kARGB_4444_SkColorType:
+            do_index8(dstInfo, (uint16_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
+            break;
+        case kRGBA_8888_SkColorType:
+        case kBGRA_8888_SkColorType:
+            do_index8(dstInfo, (uint32_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
+            break;
+        case kRGBA_F16_SkColorType:
+            do_index8(dstInfo, (uint64_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
+            break;
+        default:
+            SkASSERT(false);
+    }
+}
+
 // Default: Use the pipeline.
-static void copy_pipeline_pixels(const SkImageInfo& dstInfo, void* dstRow, size_t dstRB,
-                                 const SkImageInfo& srcInfo, const void* srcRow, size_t srcRB,
-                                 bool isColorAware) {
+static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size_t dstRB,
+                                  const SkImageInfo& srcInfo, const void* srcRow, size_t srcRB,
+                                  bool isColorAware) {
     SkRasterPipeline pipeline;
     switch (srcInfo.colorType()) {
         case kRGBA_8888_SkColorType:
@@ -176,122 +286,9 @@
     }
 }
 
-// Fast Path 3: Color space xform.
-static inline bool optimized_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo) {
-    if (kUnpremul_SkAlphaType == dstInfo.alphaType() && kPremul_SkAlphaType == srcInfo.alphaType())
-    {
-        return false;
-    }
-
-    switch (dstInfo.colorType()) {
-        case kRGBA_8888_SkColorType:
-        case kBGRA_8888_SkColorType:
-        case kRGBA_F16_SkColorType:
-            break;
-        default:
-            return false;
-    }
-
-    switch (srcInfo.colorType()) {
-        case kRGBA_8888_SkColorType:
-        case kBGRA_8888_SkColorType:
-            break;
-        default:
-            return false;
-    }
-
-    return true;
-}
-
-static inline void apply_color_xform(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
-                                     const SkImageInfo& srcInfo, const void* srcPixels,
-                                     size_t srcRB) {
-    SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
-    SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(srcInfo.colorType());
-    SkAlphaType xformAlpha;
-    switch (srcInfo.alphaType()) {
-        case kOpaque_SkAlphaType:
-            xformAlpha = kOpaque_SkAlphaType;
-            break;
-        case kPremul_SkAlphaType:
-            SkASSERT(kPremul_SkAlphaType == dstInfo.alphaType());
-
-            // This signal means: copy the src alpha to the dst, do not premultiply (in this
-            // case because the pixels are already premultiplied).
-            xformAlpha = kUnpremul_SkAlphaType;
-            break;
-        case kUnpremul_SkAlphaType:
-            SkASSERT(kPremul_SkAlphaType == dstInfo.alphaType() ||
-                     kUnpremul_SkAlphaType == dstInfo.alphaType());
-
-            xformAlpha = dstInfo.alphaType();
-            break;
-        default:
-            SkASSERT(false);
-            xformAlpha = kUnpremul_SkAlphaType;
-            break;
-    }
-
-    std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcInfo.colorSpace(),
-                                                                      dstInfo.colorSpace());
-    SkASSERT(xform);
-
-    for (int y = 0; y < dstInfo.height(); y++) {
-        SkAssertResult(xform->apply(dstFormat, dstPixels, srcFormat, srcPixels, dstInfo.width(),
-                       xformAlpha));
-        dstPixels = SkTAddOffset<void>(dstPixels, dstRB);
-        srcPixels = SkTAddOffset<const void>(srcPixels, srcRB);
-    }
-}
-
-// Fast Path 4: Index 8 sources.
-template <typename T>
-void do_index8(const SkImageInfo& dstInfo, T* dstPixels, size_t dstRB,
-               const SkImageInfo& srcInfo, const uint8_t* srcPixels, size_t srcRB,
-               SkColorTable* ctable) {
-    T dstCTable[256];
-    int count = ctable->count();
-    SkImageInfo srcInfo8888 = srcInfo.makeColorType(kN32_SkColorType).makeWH(count, 1);
-    SkImageInfo dstInfoCT = dstInfo.makeWH(count, 1);
-    size_t rowBytes = count * sizeof(T);
-    SkPixelInfo::CopyPixels(dstInfoCT, dstCTable, rowBytes, srcInfo8888, ctable->readColors(),
-                            rowBytes, nullptr);
-
-    for (int y = 0; y < dstInfo.height(); y++) {
-        for (int x = 0; x < dstInfo.width(); x++) {
-            dstPixels[x] = dstCTable[srcPixels[x]];
-        }
-        dstPixels = SkTAddOffset<T>(dstPixels, dstRB);
-        srcPixels = SkTAddOffset<const uint8_t>(srcPixels, srcRB);
-    }
-}
-
-void xform_from_index8(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
-                       const SkImageInfo& srcInfo, const uint8_t* srcPixels, size_t srcRB,
-                       SkColorTable* ctable) {
-    switch (dstInfo.colorType()) {
-        case kAlpha_8_SkColorType:
-            do_index8(dstInfo, (uint8_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
-            break;
-        case kRGB_565_SkColorType:
-        case kARGB_4444_SkColorType:
-            do_index8(dstInfo, (uint16_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
-            break;
-        case kRGBA_8888_SkColorType:
-        case kBGRA_8888_SkColorType:
-            do_index8(dstInfo, (uint32_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
-            break;
-        case kRGBA_F16_SkColorType:
-            do_index8(dstInfo, (uint64_t*) dstPixels, dstRB, srcInfo, srcPixels, srcRB, ctable);
-            break;
-        default:
-            SkASSERT(false);
-    }
-}
-
-void SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
-                             const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB,
-                             SkColorTable* ctable) {
+void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
+                     const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB,
+                     SkColorTable* ctable) {
     SkASSERT(dstInfo.dimensions() == srcInfo.dimensions());
     SkASSERT(SkImageInfoValidConversion(dstInfo, srcInfo));
 
@@ -319,11 +316,11 @@
     // Fast Path 4: Index 8 sources.
     if (kIndex_8_SkColorType == srcInfo.colorType()) {
         SkASSERT(ctable);
-        xform_from_index8(dstInfo, dstPixels, dstRB, srcInfo, (const uint8_t*) srcPixels, srcRB,
-                          ctable);
+        convert_from_index8(dstInfo, dstPixels, dstRB, srcInfo, (const uint8_t*) srcPixels, srcRB,
+                            ctable);
         return;
     }
 
     // Default: Use the pipeline.
-    copy_pipeline_pixels(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware);
+    convert_with_pipeline(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB, isColorAware);
 }
diff --git a/src/core/SkConfig8888.h b/src/core/SkConvertPixels.h
similarity index 70%
rename from src/core/SkConfig8888.h
rename to src/core/SkConvertPixels.h
index ae42242..aa641e5 100644
--- a/src/core/SkConfig8888.h
+++ b/src/core/SkConvertPixels.h
@@ -5,19 +5,17 @@
  * found in the LICENSE file.
  */
 
-#ifndef SkPixelInfo_DEFINED
-#define SkPixelInfo_DEFINED
+#ifndef SkConvertPixels_DEFINED
+#define SkConvertPixels_DEFINED
 
 #include "SkImageInfo.h"
 #include "SkTemplates.h"
 
 class SkColorTable;
 
-namespace SkPixelInfo {
-    void CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
-                    const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes,
-                    SkColorTable* srcCTable = nullptr);
-};
+void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
+                     const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes,
+                     SkColorTable* srcCTable = nullptr);
 
 static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
                                 size_t bytesPerRow, int rowCount) {
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 8b7171f..62dda16 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -8,7 +8,7 @@
 #include "SkBitmap.h"
 #include "SkCanvas.h"
 #include "SkColorPriv.h"
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkData.h"
 #include "SkImageInfoPriv.h"
 #include "SkHalf.h"
@@ -97,8 +97,8 @@
 
     const void* srcPixels = this->addr(rec.fX, rec.fY);
     const SkImageInfo srcInfo = fInfo.makeWH(rec.fInfo.width(), rec.fInfo.height());
-    SkPixelInfo::CopyPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, srcInfo, srcPixels,
-                            this->rowBytes(), this->ctable());
+    SkConvertPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, srcInfo, srcPixels, this->rowBytes(),
+                    this->ctable());
     return true;
 }
 
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 1001110..8460702 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -19,7 +19,7 @@
 #include "GrSurfaceProxyPriv.h"
 #include "GrTextureContext.h"
 
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkGrPriv.h"
 #include "SkUnPreMultiplyPriv.h"
 
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 14379d5..bf04927 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -22,7 +22,7 @@
 #include "SkBlendModePriv.h"
 #include "SkCanvas.h"
 #include "SkColorFilter.h"
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkData.h"
 #include "SkImageInfoPriv.h"
 #include "SkMaskFilter.h"
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index b6b8a5d..0f2f994 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -30,7 +30,7 @@
 #include "GrVkTransferBuffer.h"
 #include "GrVkVertexBuffer.h"
 
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkMipMap.h"
 
 #include "vk/GrVkInterface.h"
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index 575e776..b1310e3 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -6,7 +6,6 @@
  */
 
 #include "SkCanvas.h"
-#include "SkConfig8888.h"
 #include "SkSurface.h"
 #include "Test.h"
 #include "sk_tool_utils.h"