rename blitrow::proc and add (uncalled) hook for colorproc16
BUG=skia:3302 Review URL: https://codereview.chromium.org/847443003
This commit is contained in:
parent
e55fb177e9
commit
a7f11918d9
@ -26,17 +26,26 @@ public:
|
||||
a corresponding scanline of 16bit colors (specific format based on the
|
||||
config passed to the Factory.
|
||||
|
||||
The x,y params are useful just for dithering
|
||||
The x,y params provide the dithering phase for the start of the scanline
|
||||
|
||||
@param alpha A global alpha to be applied to all of the src colors
|
||||
@param x The x coordinate of the beginning of the scanline
|
||||
@param y THe y coordinate of the scanline
|
||||
*/
|
||||
typedef void (*Proc)(uint16_t* dst,
|
||||
const SkPMColor* src,
|
||||
int count, U8CPU alpha, int x, int y);
|
||||
typedef void (*Proc16)(uint16_t dst[], const SkPMColor src[], int count,
|
||||
U8CPU alpha, int x, int y);
|
||||
|
||||
static Proc Factory(unsigned flags, SkColorType);
|
||||
static Proc16 Factory16(unsigned flags);
|
||||
|
||||
/**
|
||||
* Function pointer that blends a single src color onto a scaline of dst colors.
|
||||
*
|
||||
* The x,y params provide the dithering phase for the start of the scanline
|
||||
*/
|
||||
typedef void (*ColorProc16)(uint16_t dst[], SkPMColor src, int count, int x, int y);
|
||||
|
||||
// Note : we ignore the kGlobalAlpha_Flag setting, but do respect kSrcPixelAlpha_Flag
|
||||
static ColorProc16 ColorFactory16(unsigned flags);
|
||||
|
||||
///////////// D32 version
|
||||
|
||||
@ -51,34 +60,30 @@ public:
|
||||
@param count number of colors to blend
|
||||
@param alpha global alpha to be applied to all src colors
|
||||
*/
|
||||
typedef void (*Proc32)(uint32_t* dst,
|
||||
const SkPMColor* src,
|
||||
int count, U8CPU alpha);
|
||||
typedef void (*Proc32)(uint32_t dst[], const SkPMColor src[], int count, U8CPU alpha);
|
||||
|
||||
static Proc32 Factory32(unsigned flags32);
|
||||
|
||||
/** Function pointer that blends a single color with a row of 32-bit colors
|
||||
onto a 32-bit destination
|
||||
*/
|
||||
typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count,
|
||||
SkPMColor color);
|
||||
typedef void (*ColorProc)(SkPMColor dst[], const SkPMColor src[], int count, SkPMColor color);
|
||||
|
||||
/** Blend a single color onto a row of S32 pixels, writing the result
|
||||
into a row of D32 pixels. src and dst may be the same memory, but
|
||||
if they are not, they may not overlap.
|
||||
*/
|
||||
static void Color32(SkPMColor dst[], const SkPMColor src[],
|
||||
int count, SkPMColor color);
|
||||
static void Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMColor color);
|
||||
|
||||
//! Public entry-point to return a blit function ptr
|
||||
static ColorProc ColorProcFactory();
|
||||
|
||||
/** Function pointer that blends a single color onto a 32-bit rectangle. */
|
||||
typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height,
|
||||
typedef void (*ColorRectProc)(SkPMColor dst[], int width, int height,
|
||||
size_t rowBytes, SkPMColor color);
|
||||
|
||||
/** Blend a single color into a rectangle of D32 pixels. */
|
||||
static void ColorRect32(SkPMColor* dst, int width, int height,
|
||||
static void ColorRect32(SkPMColor dst[], int width, int height,
|
||||
size_t rowBytes, SkPMColor color);
|
||||
|
||||
//! Public entry-point to return a blit function ptr
|
||||
@ -91,9 +96,11 @@ public:
|
||||
*/
|
||||
|
||||
static Proc32 PlatformProcs32(unsigned flags);
|
||||
static Proc PlatformProcs565(unsigned flags);
|
||||
static ColorProc PlatformColorProc();
|
||||
|
||||
static Proc16 PlatformFactory565(unsigned flags);
|
||||
static ColorProc16 PlatformColorFactory565(unsigned flags);
|
||||
|
||||
private:
|
||||
enum {
|
||||
kFlags16_Mask = 7,
|
||||
|
@ -202,10 +202,30 @@ static void S32A_D565_Blend_Dither(uint16_t* SK_RESTRICT dst,
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static uint32_t pmcolor_to_expand16(SkPMColor c) {
|
||||
unsigned r = SkGetPackedR32(c);
|
||||
unsigned g = SkGetPackedG32(c);
|
||||
unsigned b = SkGetPackedB32(c);
|
||||
return (g << 24) | (r << 13) | (b << 2);
|
||||
}
|
||||
|
||||
static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y) {
|
||||
SkASSERT(count > 0);
|
||||
uint32_t src_expand = pmcolor_to_expand16(src);
|
||||
unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3;
|
||||
do {
|
||||
uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale;
|
||||
*dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5);
|
||||
dst += 1;
|
||||
} while (--count != 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const SkBlitRow::Proc gDefault_565_Procs[] = {
|
||||
static const SkBlitRow::Proc16 gDefault_565_Procs[] = {
|
||||
// no dither
|
||||
S32_D565_Opaque,
|
||||
S32_D565_Blend,
|
||||
@ -221,22 +241,45 @@ static const SkBlitRow::Proc gDefault_565_Procs[] = {
|
||||
S32A_D565_Blend_Dither
|
||||
};
|
||||
|
||||
SkBlitRow::Proc SkBlitRow::Factory(unsigned flags, SkColorType ct) {
|
||||
SkBlitRow::Proc16 SkBlitRow::Factory16(unsigned flags) {
|
||||
SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_Procs));
|
||||
// just so we don't crash
|
||||
flags &= kFlags16_Mask;
|
||||
|
||||
SkBlitRow::Proc proc = NULL;
|
||||
|
||||
switch (ct) {
|
||||
case kRGB_565_SkColorType:
|
||||
proc = PlatformProcs565(flags);
|
||||
if (NULL == proc) {
|
||||
proc = gDefault_565_Procs[flags];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
SkBlitRow::Proc16 proc = PlatformFactory565(flags);
|
||||
if (NULL == proc) {
|
||||
proc = gDefault_565_Procs[flags];
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
||||
static const SkBlitRow::ColorProc16 gDefault_565_ColorProcs[] = {
|
||||
#if 0
|
||||
Color32_D565,
|
||||
Color32A_D565,
|
||||
Color32_D565_Dither,
|
||||
Color32A_D565_Dither
|
||||
#else
|
||||
// TODO: stop cheating and fill in the above specializations!
|
||||
Color32A_D565,
|
||||
Color32A_D565,
|
||||
Color32A_D565,
|
||||
Color32A_D565,
|
||||
#endif
|
||||
};
|
||||
|
||||
SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) {
|
||||
SkASSERT((flags & ~kFlags16_Mask) == 0);
|
||||
// just so we don't crash
|
||||
flags &= kFlags16_Mask;
|
||||
// we ignore kGlobalAlpha_Flag, so shift down
|
||||
flags >>= 1;
|
||||
|
||||
SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs));
|
||||
|
||||
SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags);
|
||||
if (NULL == proc) {
|
||||
proc = gDefault_565_ColorProcs[flags];
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
@ -122,9 +122,9 @@ public:
|
||||
void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
|
||||
|
||||
protected:
|
||||
SkPMColor* fBuffer;
|
||||
SkBlitRow::Proc fOpaqueProc;
|
||||
SkBlitRow::Proc fAlphaProc;
|
||||
SkPMColor* fBuffer;
|
||||
SkBlitRow::Proc16 fOpaqueProc;
|
||||
SkBlitRow::Proc16 fAlphaProc;
|
||||
|
||||
private:
|
||||
// illegal
|
||||
@ -836,10 +836,9 @@ SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkBitmap& device,
|
||||
flags |= SkBlitRow::kDither_Flag;
|
||||
}
|
||||
// used when we know our global alpha is 0xFF
|
||||
fOpaqueProc = SkBlitRow::Factory(flags, kRGB_565_SkColorType);
|
||||
fOpaqueProc = SkBlitRow::Factory16(flags);
|
||||
// used when we know our global alpha is < 0xFF
|
||||
fAlphaProc = SkBlitRow::Factory(flags | SkBlitRow::kGlobalAlpha_Flag,
|
||||
kRGB_565_SkColorType);
|
||||
fAlphaProc = SkBlitRow::Factory16(flags | SkBlitRow::kGlobalAlpha_Flag);
|
||||
}
|
||||
|
||||
SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter() {
|
||||
@ -856,7 +855,7 @@ void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) {
|
||||
|
||||
void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) {
|
||||
SkShader::Context* shaderContext = fShaderContext;
|
||||
SkBlitRow::Proc proc = fOpaqueProc;
|
||||
SkBlitRow::Proc16 proc = fOpaqueProc;
|
||||
SkPMColor* buffer = fBuffer;
|
||||
uint16_t* dst = fDevice.getAddr16(x, y);
|
||||
size_t dstRB = fDevice.rowBytes();
|
||||
@ -920,7 +919,7 @@ void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
|
||||
|
||||
SkPMColor* localSpan = span;
|
||||
for (;;) {
|
||||
SkBlitRow::Proc proc = (aa == 0xFF) ? fOpaqueProc : fAlphaProc;
|
||||
SkBlitRow::Proc16 proc = (aa == 0xFF) ? fOpaqueProc : fAlphaProc;
|
||||
proc(device, localSpan, count, aa, x, y);
|
||||
|
||||
x += count;
|
||||
|
@ -278,7 +278,7 @@ public:
|
||||
if (paint.isDither()) {
|
||||
flags |= SkBlitRow::kDither_Flag;
|
||||
}
|
||||
fProc = SkBlitRow::Factory(flags, kRGB_565_SkColorType);
|
||||
fProc = SkBlitRow::Factory16(flags);
|
||||
}
|
||||
|
||||
void blitRect(int x, int y, int width, int height) SK_OVERRIDE {
|
||||
@ -287,7 +287,7 @@ public:
|
||||
y - fTop);
|
||||
size_t dstRB = fDevice->rowBytes();
|
||||
size_t srcRB = fSource->rowBytes();
|
||||
SkBlitRow::Proc proc = fProc;
|
||||
SkBlitRow::Proc16 proc = fProc;
|
||||
U8CPU alpha = fPaint->getAlpha();
|
||||
|
||||
while (--height >= 0) {
|
||||
@ -299,7 +299,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SkBlitRow::Proc fProc;
|
||||
SkBlitRow::Proc16 fProc;
|
||||
|
||||
typedef SkSpriteBlitter INHERITED;
|
||||
};
|
||||
|
@ -347,7 +347,7 @@ void S32A_Blend_BlitRow32_arm(SkPMColor* SK_RESTRICT dst,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const SkBlitRow::Proc sk_blitrow_platform_565_procs_arm[] = {
|
||||
static const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm[] = {
|
||||
// no dither
|
||||
// NOTE: For the functions below, we don't have a special version
|
||||
// that assumes that each source pixel is opaque. But our S32A is
|
||||
@ -373,10 +373,14 @@ static const SkBlitRow::Proc32 sk_blitrow_platform_32_procs_arm[] = {
|
||||
|
||||
#endif // USE_ARM_CODE
|
||||
|
||||
SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) {
|
||||
SkBlitRow::Proc16 SkBlitRow::PlatformFactory565(unsigned flags) {
|
||||
return SK_ARM_NEON_WRAP(sk_blitrow_platform_565_procs_arm)[flags];
|
||||
}
|
||||
|
||||
SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) {
|
||||
return SK_ARM_NEON_WRAP(sk_blitrow_platform_32_procs_arm)[flags];
|
||||
}
|
||||
|
@ -1646,7 +1646,7 @@ void Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const SkBlitRow::Proc sk_blitrow_platform_565_procs_arm_neon[] = {
|
||||
const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm_neon[] = {
|
||||
// no dither
|
||||
S32_D565_Opaque_neon,
|
||||
S32_D565_Blend_neon,
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "SkBlitRow.h"
|
||||
|
||||
extern const SkBlitRow::Proc sk_blitrow_platform_565_procs_arm_neon[];
|
||||
extern const SkBlitRow::Proc16 sk_blitrow_platform_565_procs_arm_neon[];
|
||||
extern const SkBlitRow::Proc32 sk_blitrow_platform_32_procs_arm_neon[];
|
||||
|
||||
extern void Color32_arm_neon(SkPMColor* dst, const SkPMColor* src, int count,
|
||||
|
@ -921,7 +921,7 @@ void blitmask_d565_opaque_mips(int width, int height, uint16_t* device,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const SkBlitRow::Proc platform_565_procs_mips_dsp[] = {
|
||||
const SkBlitRow::Proc16 platform_565_procs_mips_dsp[] = {
|
||||
// no dither
|
||||
NULL,
|
||||
S32_D565_Blend_mips_dsp,
|
||||
@ -942,10 +942,14 @@ static const SkBlitRow::Proc32 platform_32_procs_mips_dsp[] = {
|
||||
NULL, // S32A_Blend,
|
||||
};
|
||||
|
||||
SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) {
|
||||
SkBlitRow::Proc16 SkBlitRow::PlatformFactory565(unsigned flags) {
|
||||
return platform_565_procs_mips_dsp[flags];
|
||||
}
|
||||
|
||||
SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkBlitRow::Proc32 SkBlitRow::PlatformProcs32(unsigned flags) {
|
||||
return platform_32_procs_mips_dsp[flags];
|
||||
}
|
||||
|
@ -9,7 +9,11 @@
|
||||
|
||||
// Platform impl of Platform_procs with no overrides
|
||||
|
||||
SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) {
|
||||
SkBlitRow::Proc16 SkBlitRow::PlatformFactory565(unsigned flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ void SkBitmapProcState::platformProcs() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkBlitRow::Proc platform_16_procs[] = {
|
||||
static SkBlitRow::Proc16 platform_16_procs[] = {
|
||||
S32_D565_Opaque_SSE2, // S32_D565_Opaque
|
||||
NULL, // S32_D565_Blend
|
||||
S32A_D565_Opaque_SSE2, // S32A_D565_Opaque
|
||||
@ -217,7 +217,7 @@ static SkBlitRow::Proc platform_16_procs[] = {
|
||||
NULL, // S32A_D565_Blend_Dither
|
||||
};
|
||||
|
||||
SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) {
|
||||
SkBlitRow::Proc16 SkBlitRow::PlatformFactory565(unsigned flags) {
|
||||
if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) {
|
||||
return platform_16_procs[flags];
|
||||
} else {
|
||||
@ -225,6 +225,10 @@ SkBlitRow::Proc SkBlitRow::PlatformProcs565(unsigned flags) {
|
||||
}
|
||||
}
|
||||
|
||||
SkBlitRow::ColorProc16 SkBlitRow::PlatformColorFactory565(unsigned flags) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SkBlitRow::Proc32 platform_32_procs_SSE2[] = {
|
||||
NULL, // S32_Opaque,
|
||||
S32_Blend_BlitRow32_SSE2, // S32_Blend,
|
||||
|
Loading…
Reference in New Issue
Block a user