Rename SkConfig8888/SkPixelInfo to SkConvertPixels
authorMatt Sarett <msarett@google.com>
Tue, 14 Feb 2017 19:18:27 +0000 (14:18 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 15 Feb 2017 13:50:55 +0000 (13:50 +0000)
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>
bench/PremulAndUnpremulAlphaOpsBench.cpp
gn/core.gni
src/core/SkBitmap.cpp
src/core/SkBitmapDevice.cpp
src/core/SkConvertPixels.cpp [moved from src/core/SkConfig8888.cpp with 89% similarity]
src/core/SkConvertPixels.h [moved from src/core/SkConfig8888.h with 70% similarity]
src/core/SkPixmap.cpp
src/gpu/GrContext.cpp
src/gpu/SkGr.cpp
src/gpu/vk/GrVkGpu.cpp
tests/PremulAlphaRoundTripTest.cpp

index a6b7a8c..89c9bd5 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "Benchmark.h"
 #include "SkCanvas.h"
-#include "SkConfig8888.h"
 #include "SkString.h"
 #include "sk_tool_utils.h"
 
index 4ac3d56..d702919 100644 (file)
@@ -88,8 +88,8 @@ skia_core_sources = [
   "$_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",
index 3357549..bcc57a1 100644 (file)
@@ -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 @@ bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY) {
 
     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 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha, int
         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;
 }
 
index 5742e1d..8ed5120 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "SkBitmapDevice.h"
-#include "SkConfig8888.h"
 #include "SkDraw.h"
 #include "SkImageFilter.h"
 #include "SkImageFilterCache.h"
similarity index 89%
rename from src/core/SkConfig8888.cpp
rename to src/core/SkConvertPixels.cpp
index 616ba19..50d375b 100644 (file)
@@ -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 @@ static inline bool can_memcpy(const SkImageInfo& dstInfo, const SkImageInfo& src
            SkColorSpace::Equals(dstInfo.colorSpace(), srcInfo.colorSpace());
 }
 
+// Fast Path 2: Simple swizzles and premuls.
 enum AlphaVerb {
     kNothing_AlphaVerb,
     kPremul_AlphaVerb,
@@ -52,7 +50,6 @@ static void wrap_unpremultiply(uint32_t* dst, const void* src, int count) {
     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,94 +85,6 @@ void swizzle_and_multiply(const SkImageInfo& dstInfo, void* dstPixels, size_t ds
     }
 }
 
-// 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) {
-    SkRasterPipeline pipeline;
-    switch (srcInfo.colorType()) {
-        case kRGBA_8888_SkColorType:
-            pipeline.append(SkRasterPipeline::load_8888, &srcRow);
-            break;
-        case kBGRA_8888_SkColorType:
-            pipeline.append(SkRasterPipeline::load_8888, &srcRow);
-            pipeline.append(SkRasterPipeline::swap_rb);
-            break;
-        case kRGB_565_SkColorType:
-            pipeline.append(SkRasterPipeline::load_565, &srcRow);
-            break;
-        case kRGBA_F16_SkColorType:
-            pipeline.append(SkRasterPipeline::load_f16, &srcRow);
-            break;
-        case kGray_8_SkColorType:
-            pipeline.append(SkRasterPipeline::load_g8, &srcRow);
-            break;
-        case kARGB_4444_SkColorType:
-            pipeline.append(SkRasterPipeline::load_4444, &srcRow);
-            break;
-        default:
-            SkASSERT(false);
-            break;
-    }
-
-    if (isColorAware && srcInfo.gammaCloseToSRGB()) {
-        pipeline.append_from_srgb(srcInfo.alphaType());
-    }
-
-    float matrix[12];
-    if (isColorAware) {
-        SkAssertResult(append_gamut_transform(&pipeline, matrix, srcInfo.colorSpace(),
-                                              dstInfo.colorSpace()));
-    }
-
-    SkAlphaType sat = srcInfo.alphaType();
-    SkAlphaType dat = dstInfo.alphaType();
-    if (sat == kPremul_SkAlphaType && dat == kUnpremul_SkAlphaType) {
-        pipeline.append(SkRasterPipeline::unpremul);
-    } else if (sat == kUnpremul_SkAlphaType && dat == kPremul_SkAlphaType) {
-        pipeline.append(SkRasterPipeline::premul);
-    }
-
-    if (isColorAware && dstInfo.gammaCloseToSRGB()) {
-        pipeline.append(SkRasterPipeline::to_srgb);
-    }
-
-    switch (dstInfo.colorType()) {
-        case kRGBA_8888_SkColorType:
-            pipeline.append(SkRasterPipeline::store_8888, &dstRow);
-            break;
-        case kBGRA_8888_SkColorType:
-            pipeline.append(SkRasterPipeline::swap_rb);
-            pipeline.append(SkRasterPipeline::store_8888, &dstRow);
-            break;
-        case kRGB_565_SkColorType:
-            pipeline.append(SkRasterPipeline::store_565, &dstRow);
-            break;
-        case kRGBA_F16_SkColorType:
-            pipeline.append(SkRasterPipeline::store_f16, &dstRow);
-            break;
-        case kAlpha_8_SkColorType:
-            pipeline.append(SkRasterPipeline::store_a8, &dstRow);
-            break;
-        case kARGB_4444_SkColorType:
-            pipeline.append(SkRasterPipeline::store_4444, &dstRow);
-            break;
-        default:
-            SkASSERT(false);
-            break;
-    }
-
-    auto p = pipeline.compile();
-
-    for (int y = 0; y < srcInfo.height(); ++y) {
-        p(0,srcInfo.width());
-        // The pipeline has pointers to srcRow and dstRow, so we just need to update them in the
-        // loop to move between rows of src/dst.
-        dstRow = SkTAddOffset<void>(dstRow, dstRB);
-        srcRow = SkTAddOffset<const void>(srcRow, srcRB);
-    }
-}
-
 // 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())
@@ -254,8 +163,8 @@ void do_index8(const SkImageInfo& dstInfo, T* dstPixels, size_t dstRB,
     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);
+    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++) {
@@ -266,9 +175,9 @@ void do_index8(const SkImageInfo& dstInfo, T* dstPixels, size_t dstRB,
     }
 }
 
-void xform_from_index8(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
-                       const SkImageInfo& srcInfo, const uint8_t* srcPixels, size_t srcRB,
-                       SkColorTable* ctable) {
+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);
@@ -289,9 +198,97 @@ void xform_from_index8(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB
     }
 }
 
-void SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
-                             const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB,
-                             SkColorTable* ctable) {
+// Default: Use the pipeline.
+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:
+            pipeline.append(SkRasterPipeline::load_8888, &srcRow);
+            break;
+        case kBGRA_8888_SkColorType:
+            pipeline.append(SkRasterPipeline::load_8888, &srcRow);
+            pipeline.append(SkRasterPipeline::swap_rb);
+            break;
+        case kRGB_565_SkColorType:
+            pipeline.append(SkRasterPipeline::load_565, &srcRow);
+            break;
+        case kRGBA_F16_SkColorType:
+            pipeline.append(SkRasterPipeline::load_f16, &srcRow);
+            break;
+        case kGray_8_SkColorType:
+            pipeline.append(SkRasterPipeline::load_g8, &srcRow);
+            break;
+        case kARGB_4444_SkColorType:
+            pipeline.append(SkRasterPipeline::load_4444, &srcRow);
+            break;
+        default:
+            SkASSERT(false);
+            break;
+    }
+
+    if (isColorAware && srcInfo.gammaCloseToSRGB()) {
+        pipeline.append_from_srgb(srcInfo.alphaType());
+    }
+
+    float matrix[12];
+    if (isColorAware) {
+        SkAssertResult(append_gamut_transform(&pipeline, matrix, srcInfo.colorSpace(),
+                                              dstInfo.colorSpace()));
+    }
+
+    SkAlphaType sat = srcInfo.alphaType();
+    SkAlphaType dat = dstInfo.alphaType();
+    if (sat == kPremul_SkAlphaType && dat == kUnpremul_SkAlphaType) {
+        pipeline.append(SkRasterPipeline::unpremul);
+    } else if (sat == kUnpremul_SkAlphaType && dat == kPremul_SkAlphaType) {
+        pipeline.append(SkRasterPipeline::premul);
+    }
+
+    if (isColorAware && dstInfo.gammaCloseToSRGB()) {
+        pipeline.append(SkRasterPipeline::to_srgb);
+    }
+
+    switch (dstInfo.colorType()) {
+        case kRGBA_8888_SkColorType:
+            pipeline.append(SkRasterPipeline::store_8888, &dstRow);
+            break;
+        case kBGRA_8888_SkColorType:
+            pipeline.append(SkRasterPipeline::swap_rb);
+            pipeline.append(SkRasterPipeline::store_8888, &dstRow);
+            break;
+        case kRGB_565_SkColorType:
+            pipeline.append(SkRasterPipeline::store_565, &dstRow);
+            break;
+        case kRGBA_F16_SkColorType:
+            pipeline.append(SkRasterPipeline::store_f16, &dstRow);
+            break;
+        case kAlpha_8_SkColorType:
+            pipeline.append(SkRasterPipeline::store_a8, &dstRow);
+            break;
+        case kARGB_4444_SkColorType:
+            pipeline.append(SkRasterPipeline::store_4444, &dstRow);
+            break;
+        default:
+            SkASSERT(false);
+            break;
+    }
+
+    auto p = pipeline.compile();
+
+    for (int y = 0; y < srcInfo.height(); ++y) {
+        p(0,srcInfo.width());
+        // The pipeline has pointers to srcRow and dstRow, so we just need to update them in the
+        // loop to move between rows of src/dst.
+        dstRow = SkTAddOffset<void>(dstRow, dstRB);
+        srcRow = SkTAddOffset<const void>(srcRow, srcRB);
+    }
+}
+
+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 @@ void SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
     // 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);
 }
similarity index 70%
rename from src/core/SkConfig8888.h
rename to src/core/SkConvertPixels.h
index ae42242..aa641e5 100644 (file)
@@ -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) {
index 8b7171f..62dda16 100644 (file)
@@ -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 {
 
     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;
 }
 
index 1001110..8460702 100644 (file)
@@ -19,7 +19,7 @@
 #include "GrSurfaceProxyPriv.h"
 #include "GrTextureContext.h"
 
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkGrPriv.h"
 #include "SkUnPreMultiplyPriv.h"
 
index 14379d5..bf04927 100644 (file)
@@ -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"
index b6b8a5d..0f2f994 100644 (file)
@@ -30,7 +30,7 @@
 #include "GrVkTransferBuffer.h"
 #include "GrVkVertexBuffer.h"
 
-#include "SkConfig8888.h"
+#include "SkConvertPixels.h"
 #include "SkMipMap.h"
 
 #include "vk/GrVkInterface.h"
index 575e776..b1310e3 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "SkCanvas.h"
-#include "SkConfig8888.h"
 #include "SkSurface.h"
 #include "Test.h"
 #include "sk_tool_utils.h"