Simplify bitmappremul GM a bit, remove more SkColorData 4444 macros
Bug: skia: Change-Id: I294e70708aab2c39a6077a11de76518c6fe7f712 Reviewed-on: https://skia-review.googlesource.com/c/167941 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
13245412d4
commit
bdd0f5171e
@ -19,8 +19,6 @@
|
||||
*/
|
||||
|
||||
constexpr int SLIDE_SIZE = 256;
|
||||
constexpr int PIXEL_SIZE_8888 = SLIDE_SIZE / 256;
|
||||
constexpr int PIXEL_SIZE_4444 = SLIDE_SIZE / 16;
|
||||
|
||||
static void init_bitmap(SkColorType ct, SkBitmap* bitmap) {
|
||||
bitmap->allocPixels(SkImageInfo::Make(SLIDE_SIZE, SLIDE_SIZE, ct,
|
||||
@ -31,15 +29,10 @@ static void init_bitmap(SkColorType ct, SkBitmap* bitmap) {
|
||||
static SkBitmap make_argb8888_gradient() {
|
||||
SkBitmap bitmap;
|
||||
init_bitmap(kN32_SkColorType, &bitmap);
|
||||
uint8_t rowColor = 0;
|
||||
for (int y = 0; y < SLIDE_SIZE; y++) {
|
||||
uint32_t* dst = bitmap.getAddr32(0, y);
|
||||
for (int x = 0; x < SLIDE_SIZE; x++) {
|
||||
dst[x] = SkPackARGB32(rowColor, rowColor,
|
||||
rowColor, rowColor);
|
||||
}
|
||||
if (y % PIXEL_SIZE_8888 == PIXEL_SIZE_8888 - 1) {
|
||||
rowColor++;
|
||||
dst[x] = SkPackARGB32(y, y, y, y);
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
@ -48,17 +41,10 @@ static SkBitmap make_argb8888_gradient() {
|
||||
static SkBitmap make_argb4444_gradient() {
|
||||
SkBitmap bitmap;
|
||||
init_bitmap(kARGB_4444_SkColorType, &bitmap);
|
||||
uint8_t rowColor = 0;
|
||||
for (int y = 0; y < SLIDE_SIZE; y++) {
|
||||
uint16_t* dst = bitmap.getAddr16(0, y);
|
||||
for (int x = 0; x < SLIDE_SIZE; x++) {
|
||||
dst[x] = SkPackARGB4444(rowColor, rowColor,
|
||||
rowColor, rowColor);
|
||||
}
|
||||
if (y % PIXEL_SIZE_4444 == PIXEL_SIZE_4444 - 1) {
|
||||
rowColor++;
|
||||
}
|
||||
}
|
||||
// Using draw rather than readPixels to suppress dither
|
||||
SkPaint paint;
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
SkCanvas{ bitmap }.drawBitmap(make_argb8888_gradient(), 0, 0, &paint);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@ -84,19 +70,10 @@ static SkBitmap make_argb8888_stripes() {
|
||||
static SkBitmap make_argb4444_stripes() {
|
||||
SkBitmap bitmap;
|
||||
init_bitmap(kARGB_4444_SkColorType, &bitmap);
|
||||
uint8_t rowColor = 0;
|
||||
for (int y = 0; y < SLIDE_SIZE; y++) {
|
||||
uint16_t* dst = bitmap.getAddr16(0, y);
|
||||
for (int x = 0; x < SLIDE_SIZE; x++) {
|
||||
dst[x] = SkPackARGB4444(rowColor, rowColor,
|
||||
rowColor, rowColor);
|
||||
}
|
||||
if (rowColor == 0) {
|
||||
rowColor = 15;
|
||||
} else {
|
||||
rowColor = 0;
|
||||
}
|
||||
}
|
||||
// Using draw rather than readPixels to suppress dither
|
||||
SkPaint paint;
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
SkCanvas{ bitmap }.drawBitmap(make_argb8888_stripes(), 0, 0, &paint);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
@ -381,11 +381,6 @@ typedef uint16_t SkPMColor16;
|
||||
#define SK_G4444_SHIFT 8
|
||||
#define SK_B4444_SHIFT 4
|
||||
|
||||
#define SkA32To4444(a) ((unsigned)(a) >> 4)
|
||||
#define SkR32To4444(r) ((unsigned)(r) >> 4)
|
||||
#define SkG32To4444(g) ((unsigned)(g) >> 4)
|
||||
#define SkB32To4444(b) ((unsigned)(b) >> 4)
|
||||
|
||||
static inline U8CPU SkReplicateNibble(unsigned nib) {
|
||||
SkASSERT(nib <= 0xF);
|
||||
return (nib << 4) | nib;
|
||||
@ -398,27 +393,6 @@ static inline U8CPU SkReplicateNibble(unsigned nib) {
|
||||
|
||||
#define SkPacked4444ToA32(c) SkReplicateNibble(SkGetPackedA4444(c))
|
||||
|
||||
static inline SkPMColor16 SkPackARGB4444(unsigned a, unsigned r,
|
||||
unsigned g, unsigned b) {
|
||||
SkASSERT(a <= 0xF);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
|
||||
return (SkPMColor16)((a << SK_A4444_SHIFT) | (r << SK_R4444_SHIFT) |
|
||||
(g << SK_G4444_SHIFT) | (b << SK_B4444_SHIFT));
|
||||
}
|
||||
|
||||
/** Expand the SkPMColor16 color into a 32bit value that can be scaled all at
|
||||
once by a value up to 16.
|
||||
*/
|
||||
static inline uint32_t SkExpand_4444(U16CPU c) {
|
||||
SkASSERT(c == (uint16_t)c);
|
||||
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
return (c & mask) | ((c & ~mask) << 12);
|
||||
}
|
||||
|
||||
static inline SkPMColor SkPixel4444ToPixel32(U16CPU c) {
|
||||
uint32_t d = (SkGetPackedA4444(c) << SK_A32_SHIFT) |
|
||||
(SkGetPackedR4444(c) << SK_R32_SHIFT) |
|
||||
|
Loading…
Reference in New Issue
Block a user