diff options
author | 2017-02-14 14:18:27 -0500 | |
---|---|---|
committer | 2017-02-15 13:50:55 +0000 | |
commit | 485c499a2797c1eb0e750fa4aaec57192799b424 (patch) | |
tree | fa6649c37a56d35b1019edcb29fad3f962786a22 /src | |
parent | 0168e0442e00a42d8367422542033bc8a1ac9efe (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmap.cpp | 10 | ||||
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 1 | ||||
-rw-r--r-- | src/core/SkConvertPixels.cpp (renamed from src/core/SkConfig8888.cpp) | 209 | ||||
-rw-r--r-- | src/core/SkConvertPixels.h (renamed from src/core/SkConfig8888.h) | 12 | ||||
-rw-r--r-- | src/core/SkPixmap.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 2 |
8 files changed, 119 insertions, 125 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 33575499e6..bcc57a1c02 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 @@ 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; } diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 5742e1d0a3..8ed5120251 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 index 616ba192a7..50d375b9d6 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 @@ 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); } diff --git a/src/core/SkConfig8888.h b/src/core/SkConvertPixels.h index ae42242ad5..aa641e552d 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 8b7171f96f..62dda1696c 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 { 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 1001110614..8460702a44 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 14379d5f8f..bf04927ab1 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 b6b8a5d827..0f2f9946b2 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" |