coding style
git-svn-id: http://skia.googlecode.com/svn/trunk@1091 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
bcc1d33e94
commit
eadc8072aa
@ -41,7 +41,8 @@ class SkARGB4444_Blitter : public SkRasterBlitter {
|
|||||||
public:
|
public:
|
||||||
SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& paint);
|
SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& paint);
|
||||||
virtual void blitH(int x, int y, int width);
|
virtual void blitH(int x, int y, int width);
|
||||||
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
|
virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||||
|
const int16_t runs[]);
|
||||||
virtual void blitV(int x, int y, int height, SkAlpha alpha);
|
virtual void blitV(int x, int y, int height, SkAlpha alpha);
|
||||||
virtual void blitRect(int x, int y, int width, int height);
|
virtual void blitRect(int x, int y, int width, int height);
|
||||||
virtual void blitMask(const SkMask&, const SkIRect&);
|
virtual void blitMask(const SkMask&, const SkIRect&);
|
||||||
@ -60,9 +61,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& paint)
|
SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device,
|
||||||
: INHERITED(device)
|
const SkPaint& paint) : INHERITED(device) {
|
||||||
{
|
|
||||||
// cache premultiplied versions in 4444
|
// cache premultiplied versions in 4444
|
||||||
SkPMColor c = SkPreMultiplyColor(paint.getColor());
|
SkPMColor c = SkPreMultiplyColor(paint.getColor());
|
||||||
fPMColor16 = SkPixel32ToPixel4444(c);
|
fPMColor16 = SkPixel32ToPixel4444(c);
|
||||||
@ -82,13 +82,6 @@ SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& pa
|
|||||||
fRawColor16Other = fRawColor16;
|
fRawColor16Other = fRawColor16;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /// don't think this assertion is true, but need it be?
|
|
||||||
|
|
||||||
// our dithered color will be the same or more opaque than the original
|
|
||||||
// so use dithered to compute our scale
|
|
||||||
SkASSERT(SkGetPackedA4444(fPMColor16Other) >= SkGetPackedA4444(fPMColor16));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fScale16 = SkAlpha15To16(SkGetPackedA4444(fPMColor16Other));
|
fScale16 = SkAlpha15To16(SkGetPackedA4444(fPMColor16Other));
|
||||||
if (16 == fScale16) {
|
if (16 == fScale16) {
|
||||||
// force the original to also be opaque
|
// force the original to also be opaque
|
||||||
@ -96,8 +89,7 @@ SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkBitmap* SkARGB4444_Blitter::justAnOpaqueColor(uint32_t* value)
|
const SkBitmap* SkARGB4444_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||||
{
|
|
||||||
if (16 == fScale16) {
|
if (16 == fScale16) {
|
||||||
*value = fPMColor16;
|
*value = fPMColor16;
|
||||||
return &fDevice;
|
return &fDevice;
|
||||||
@ -106,8 +98,7 @@ const SkBitmap* SkARGB4444_Blitter::justAnOpaqueColor(uint32_t* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void src_over_4444(SkPMColor16 dst[], SkPMColor16 color,
|
static void src_over_4444(SkPMColor16 dst[], SkPMColor16 color,
|
||||||
SkPMColor16 other, unsigned invScale, int count)
|
SkPMColor16 other, unsigned invScale, int count) {
|
||||||
{
|
|
||||||
int twice = count >> 1;
|
int twice = count >> 1;
|
||||||
while (--twice >= 0) {
|
while (--twice >= 0) {
|
||||||
*dst = color + SkAlphaMulQ4(*dst, invScale);
|
*dst = color + SkAlphaMulQ4(*dst, invScale);
|
||||||
@ -120,15 +111,13 @@ static void src_over_4444(SkPMColor16 dst[], SkPMColor16 color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t SkExpand_4444_Replicate(SkPMColor16 c)
|
static inline uint32_t SkExpand_4444_Replicate(SkPMColor16 c) {
|
||||||
{
|
|
||||||
uint32_t c32 = SkExpand_4444(c);
|
uint32_t c32 = SkExpand_4444(c);
|
||||||
return c32 | (c32 << 4);
|
return c32 | (c32 << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void src_over_4444x(SkPMColor16 dst[], uint32_t color,
|
static void src_over_4444x(SkPMColor16 dst[], uint32_t color,
|
||||||
uint32_t other, unsigned invScale, int count)
|
uint32_t other, unsigned invScale, int count) {
|
||||||
{
|
|
||||||
int twice = count >> 1;
|
int twice = count >> 1;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
while (--twice >= 0) {
|
while (--twice >= 0) {
|
||||||
@ -143,8 +132,7 @@ static void src_over_4444x(SkPMColor16 dst[], uint32_t color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkARGB4444_Blitter::blitH(int x, int y, int width)
|
void SkARGB4444_Blitter::blitH(int x, int y, int width) {
|
||||||
{
|
|
||||||
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
|
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
|
||||||
|
|
||||||
if (0 == fScale16) {
|
if (0 == fScale16) {
|
||||||
@ -161,16 +149,14 @@ void SkARGB4444_Blitter::blitH(int x, int y, int width)
|
|||||||
|
|
||||||
if (16 == fScale16) {
|
if (16 == fScale16) {
|
||||||
sk_dither_memset16(device, color, other, width);
|
sk_dither_memset16(device, color, other, width);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
src_over_4444x(device, SkExpand_4444_Replicate(color),
|
src_over_4444x(device, SkExpand_4444_Replicate(color),
|
||||||
SkExpand_4444_Replicate(other),
|
SkExpand_4444_Replicate(other),
|
||||||
16 - fScale16, width);
|
16 - fScale16, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkARGB4444_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
|
void SkARGB4444_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
|
||||||
{
|
|
||||||
if (0 == alpha || 0 == fScale16) {
|
if (0 == alpha || 0 == fScale16) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -208,9 +194,9 @@ void SkARGB4444_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkARGB4444_Blitter::blitRect(int x, int y, int width, int height)
|
void SkARGB4444_Blitter::blitRect(int x, int y, int width, int height) {
|
||||||
{
|
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() &&
|
||||||
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height());
|
y + height <= fDevice.height());
|
||||||
|
|
||||||
if (0 == fScale16) {
|
if (0 == fScale16) {
|
||||||
return;
|
return;
|
||||||
@ -243,8 +229,8 @@ void SkARGB4444_Blitter::blitRect(int x, int y, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkARGB4444_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
|
void SkARGB4444_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
|
||||||
{
|
const int16_t runs[]) {
|
||||||
if (0 == fScale16) {
|
if (0 == fScale16) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -295,19 +281,19 @@ void SkARGB4444_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define solid_8_pixels(mask, dst, color) \
|
#define solid_8_pixels(mask, dst, color) \
|
||||||
do { \
|
do { \
|
||||||
if (mask & 0x80) dst[0] = color; \
|
if (mask & 0x80) dst[0] = color; \
|
||||||
if (mask & 0x40) dst[1] = color; \
|
if (mask & 0x40) dst[1] = color; \
|
||||||
if (mask & 0x20) dst[2] = color; \
|
if (mask & 0x20) dst[2] = color; \
|
||||||
if (mask & 0x10) dst[3] = color; \
|
if (mask & 0x10) dst[3] = color; \
|
||||||
if (mask & 0x08) dst[4] = color; \
|
if (mask & 0x08) dst[4] = color; \
|
||||||
if (mask & 0x04) dst[5] = color; \
|
if (mask & 0x04) dst[5] = color; \
|
||||||
if (mask & 0x02) dst[6] = color; \
|
if (mask & 0x02) dst[6] = color; \
|
||||||
if (mask & 0x01) dst[7] = color; \
|
if (mask & 0x01) dst[7] = color; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SK_BLITBWMASK_NAME SkARGB4444_BlitBW
|
#define SK_BLITBWMASK_NAME SkARGB4444_BlitBW
|
||||||
#define SK_BLITBWMASK_ARGS , SkPMColor16 color
|
#define SK_BLITBWMASK_ARGS , SkPMColor16 color
|
||||||
@ -316,17 +302,17 @@ if (mask & 0x01) dst[7] = color; \
|
|||||||
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
||||||
#include "SkBlitBWMaskTemplate.h"
|
#include "SkBlitBWMaskTemplate.h"
|
||||||
|
|
||||||
#define blend_8_pixels(mask, dst, sc, dst_scale) \
|
#define blend_8_pixels(mask, dst, sc, dst_scale) \
|
||||||
do { \
|
do { \
|
||||||
if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ4(dst[0], dst_scale); } \
|
if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ4(dst[0], dst_scale); } \
|
||||||
if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ4(dst[1], dst_scale); } \
|
if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ4(dst[1], dst_scale); } \
|
||||||
if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ4(dst[2], dst_scale); } \
|
if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ4(dst[2], dst_scale); } \
|
||||||
if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ4(dst[3], dst_scale); } \
|
if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ4(dst[3], dst_scale); } \
|
||||||
if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ4(dst[4], dst_scale); } \
|
if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ4(dst[4], dst_scale); } \
|
||||||
if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ4(dst[5], dst_scale); } \
|
if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ4(dst[5], dst_scale); } \
|
||||||
if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ4(dst[6], dst_scale); } \
|
if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ4(dst[6], dst_scale); } \
|
||||||
if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ4(dst[7], dst_scale); } \
|
if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ4(dst[7], dst_scale); } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SK_BLITBWMASK_NAME SkARGB4444_BlendBW
|
#define SK_BLITBWMASK_NAME SkARGB4444_BlendBW
|
||||||
#define SK_BLITBWMASK_ARGS , uint16_t sc, unsigned dst_scale
|
#define SK_BLITBWMASK_ARGS , uint16_t sc, unsigned dst_scale
|
||||||
@ -335,8 +321,7 @@ if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ4(dst[7], dst_scale); } \
|
|||||||
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
#define SK_BLITBWMASK_DEVTYPE uint16_t
|
||||||
#include "SkBlitBWMaskTemplate.h"
|
#include "SkBlitBWMaskTemplate.h"
|
||||||
|
|
||||||
void SkARGB4444_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
|
void SkARGB4444_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
|
||||||
{
|
|
||||||
SkASSERT(mask.fBounds.contains(clip));
|
SkASSERT(mask.fBounds.contains(clip));
|
||||||
|
|
||||||
if (0 == fScale16) {
|
if (0 == fScale16) {
|
||||||
@ -375,7 +360,7 @@ void SkARGB4444_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
|
|||||||
} while (--height != 0);
|
} while (--height != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class SkARGB4444_Shader_Blitter : public SkShaderBlitter {
|
class SkARGB4444_Shader_Blitter : public SkShaderBlitter {
|
||||||
SkXfermode* fXfermode;
|
SkXfermode* fXfermode;
|
||||||
@ -386,8 +371,7 @@ class SkARGB4444_Shader_Blitter : public SkShaderBlitter {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
SkARGB4444_Shader_Blitter(const SkBitmap& device, const SkPaint& paint)
|
SkARGB4444_Shader_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||||
: INHERITED(device, paint)
|
: INHERITED(device, paint) {
|
||||||
{
|
|
||||||
const int width = device.width();
|
const int width = device.width();
|
||||||
fBuffer = (SkPMColor*)sk_malloc_throw(width * sizeof(SkPMColor) + width);
|
fBuffer = (SkPMColor*)sk_malloc_throw(width * sizeof(SkPMColor) + width);
|
||||||
fAAExpand = (uint8_t*)(fBuffer + width);
|
fAAExpand = (uint8_t*)(fBuffer + width);
|
||||||
|
@ -18,18 +18,17 @@
|
|||||||
#include "SkCoreBlitters.h"
|
#include "SkCoreBlitters.h"
|
||||||
|
|
||||||
SkA1_Blitter::SkA1_Blitter(const SkBitmap& device, const SkPaint& paint)
|
SkA1_Blitter::SkA1_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||||
: INHERITED(device)
|
: INHERITED(device) {
|
||||||
{
|
fSrcA = paint.getAlpha();
|
||||||
fSrcA = SkToU8(SkColorGetA(paint.getColor()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkA1_Blitter::blitH(int x, int y, int width)
|
void SkA1_Blitter::blitH(int x, int y, int width) {
|
||||||
{
|
SkASSERT(x >= 0 && y >= 0 &&
|
||||||
SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
|
(unsigned)(x + width) <= (unsigned)fDevice.width());
|
||||||
|
|
||||||
if (fSrcA <= 0x7F)
|
if (fSrcA <= 0x7F) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
uint8_t* dst = fDevice.getAddr1(x, y);
|
uint8_t* dst = fDevice.getAddr1(x, y);
|
||||||
int right = x + width;
|
int right = x + width;
|
||||||
|
|
||||||
@ -37,23 +36,20 @@ void SkA1_Blitter::blitH(int x, int y, int width)
|
|||||||
int rite_mask = 0xFF << (8 - (right & 7));
|
int rite_mask = 0xFF << (8 - (right & 7));
|
||||||
int full_runs = (right >> 3) - ((x + 7) >> 3);
|
int full_runs = (right >> 3) - ((x + 7) >> 3);
|
||||||
|
|
||||||
// check for empty right mask, so we don't read off the end (or go slower than we need to)
|
// check for empty right mask, so we don't read off the end
|
||||||
if (rite_mask == 0)
|
// (or go slower than we need to)
|
||||||
{
|
if (rite_mask == 0) {
|
||||||
SkASSERT(full_runs >= 0);
|
SkASSERT(full_runs >= 0);
|
||||||
full_runs -= 1;
|
full_runs -= 1;
|
||||||
rite_mask = 0xFF;
|
rite_mask = 0xFF;
|
||||||
}
|
}
|
||||||
if (left_mask == 0xFF)
|
if (left_mask == 0xFF) {
|
||||||
full_runs -= 1;
|
full_runs -= 1;
|
||||||
|
}
|
||||||
if (full_runs < 0)
|
if (full_runs < 0) {
|
||||||
{
|
|
||||||
SkASSERT((left_mask & rite_mask) != 0);
|
SkASSERT((left_mask & rite_mask) != 0);
|
||||||
*dst |= (left_mask & rite_mask);
|
*dst |= (left_mask & rite_mask);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
*dst++ |= left_mask;
|
*dst++ |= left_mask;
|
||||||
memset(dst, 0xFF, full_runs);
|
memset(dst, 0xFF, full_runs);
|
||||||
dst += full_runs;
|
dst += full_runs;
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#include "SkXfermode.h"
|
#include "SkXfermode.h"
|
||||||
|
|
||||||
SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint)
|
SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint)
|
||||||
: INHERITED(device) {
|
: INHERITED(device) {
|
||||||
fSrcA = SkColorGetA(paint.getColor());
|
fSrcA = paint.getAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) {
|
const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user