Skip to content

Commit

Permalink
Reduce shared library sizes
Browse files Browse the repository at this point in the history
Commented out some unused routines (including all RGBA routines).
This reduces sizes of shared binaries on all archs below 100 Kb mark.
  • Loading branch information
Alexander-- committed Jan 13, 2024
1 parent 857a484 commit 38fc40c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
24 changes: 7 additions & 17 deletions library/src/main/c/pngs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__ADLER32
#define WUFFS_CONFIG__MODULE__AUX__BASE
#define WUFFS_CONFIG__MODULE__AUX__IMAGE
#define WUFFS_CONFIG__MODULE__BASE
#define WUFFS_CONFIG__MODULE__BASE__CORE
#define WUFFS_CONFIG__MODULE__BASE__PIXCONV
#define WUFFS_CONFIG__MODULE__CRC32
#define WUFFS_CONFIG__MODULE__DEFLATE
#define WUFFS_CONFIG__MODULE__PNG
Expand Down Expand Up @@ -122,7 +121,7 @@ JNIEXPORT jint JNICALL Java_org_bitmapdecoder_PngDecoder_decode(
wuffs_png__decoder decoder;
wuffs_base__status i_status = wuffs_png__decoder__initialize(&decoder, sizeof decoder, WUFFS_VERSION, 0);
if (!wuffs_base__status__is_ok(&i_status)) {
LOG("Failed to initialize PNG decoder: %s\n", wuffs_base__status__message(&i_status));
LOG("%s\n", wuffs_base__status__message(&i_status));
return 0;
}

Expand All @@ -142,7 +141,7 @@ JNIEXPORT jint JNICALL Java_org_bitmapdecoder_PngDecoder_decode(
wuffs_base__image_config imageconfig;
wuffs_base__status dic_status = wuffs_png__decoder__decode_image_config(&decoder, &imageconfig, &src);
if (!wuffs_base__status__is_ok(&dic_status)) {
LOG("Header parsing failed: %s\n", wuffs_base__status__message(&dic_status));
LOG("%s\n", wuffs_base__status__message(&dic_status));
return 0;
}

Expand Down Expand Up @@ -185,16 +184,7 @@ JNIEXPORT jint JNICALL Java_org_bitmapdecoder_PngDecoder_decode(

AndroidBitmap_lockPixels(env, out_image, &dst_buffer);
} else if (out_palette == NULL) {
// decode as RGBA
//LOG("%s\n", "Decoding indexed as RGBA");

wuffs_base__pixel_config__set(
&imageconfig.pixcfg, WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL,
WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, img_width, img_height);

dst_len = img_width * img_height * 4;

AndroidBitmap_lockPixels(env, out_image, &dst_buffer);
return 0;
} else {
//LOG("%s\n", "Decoding indexed to ALPHA8 with palette");

Expand All @@ -217,7 +207,7 @@ JNIEXPORT jint JNICALL Java_org_bitmapdecoder_PngDecoder_decode(
wuffs_base__status newbuffer_status = wuffs_base__pixel_buffer__set_from_slice(&pb, &imageconfig.pixcfg, dstbuff);

if (!wuffs_base__status__is_ok(&newbuffer_status)) {
LOG("Failed to initialize pixel buffer: %s\n", wuffs_base__status__message(&newbuffer_status));
LOG("%s\n", wuffs_base__status__message(&newbuffer_status));
return 0;
}

Expand All @@ -232,7 +222,7 @@ JNIEXPORT jint JNICALL Java_org_bitmapdecoder_PngDecoder_decode(

wuffs_base__status framestatus = wuffs_png__decoder__decode_frame(&decoder, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, workbuff, NULL);
if (!wuffs_base__status__is_ok(&framestatus)) {
LOG("Failed to decode image: %s\n", wuffs_base__status__message(&framestatus));
LOG("Decoding failed: %s\n", wuffs_base__status__message(&framestatus));
return 0;
}

Expand Down
16 changes: 8 additions & 8 deletions library/src/main/c/wuffs-unsupported-snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -20754,7 +20754,7 @@ wuffs_base__pixel_swizzler__prepare__y(wuffs_base__pixel_swizzler* p,
switch (dst_pixfmt.repr) {
case WUFFS_BASE__PIXEL_FORMAT__Y:
return wuffs_base__pixel_swizzler__copy_1_1;

/*
case WUFFS_BASE__PIXEL_FORMAT__BGR_565:
return wuffs_base__pixel_swizzler__bgr_565__y;

Expand All @@ -20781,7 +20781,7 @@ wuffs_base__pixel_swizzler__prepare__y(wuffs_base__pixel_swizzler* p,
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_4X16LE:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL_4X16LE:
return wuffs_base__pixel_swizzler__xxxxxxxx__y;
return wuffs_base__pixel_swizzler__xxxxxxxx__y;*/
}
return NULL;
}
Expand Down Expand Up @@ -20846,7 +20846,7 @@ wuffs_base__pixel_swizzler__prepare__indexed__bgra_nonpremul(
return wuffs_base__pixel_swizzler__copy_1_1;
}
return NULL;

/*
case WUFFS_BASE__PIXEL_FORMAT__BGR_565:
switch (blend) {
case WUFFS_BASE__PIXEL_BLEND__SRC:
Expand Down Expand Up @@ -20972,7 +20972,7 @@ wuffs_base__pixel_swizzler__prepare__indexed__bgra_nonpremul(

case WUFFS_BASE__PIXEL_FORMAT__RGBX:
// TODO.
break;
break;*/
}
return NULL;
}
Expand All @@ -20997,7 +20997,7 @@ wuffs_base__pixel_swizzler__prepare__indexed__bgra_binary(
return wuffs_base__pixel_swizzler__copy_1_1;
}
return NULL;

/*
case WUFFS_BASE__PIXEL_FORMAT__BGR_565:
if (wuffs_base__pixel_swizzler__squash_align4_bgr_565_8888(
dst_palette.ptr, dst_palette.len, src_palette.ptr,
Expand Down Expand Up @@ -21085,7 +21085,7 @@ wuffs_base__pixel_swizzler__prepare__indexed__bgra_binary(
case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:
return wuffs_base__pixel_swizzler__xxxx__index_binary_alpha__src_over;
}
return NULL;
return NULL;*/
}
return NULL;
}
Expand Down Expand Up @@ -21742,7 +21742,7 @@ wuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,
func = wuffs_base__pixel_swizzler__prepare__indexed__bgra_binary(
p, dst_pixfmt, dst_palette, src_palette, blend);
break;

/*
case WUFFS_BASE__PIXEL_FORMAT__BGR_565:
func = wuffs_base__pixel_swizzler__prepare__bgr_565(
p, dst_pixfmt, dst_palette, src_palette, blend);
Expand Down Expand Up @@ -21786,7 +21786,7 @@ wuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
func = wuffs_base__pixel_swizzler__prepare__rgba_premul(
p, dst_pixfmt, dst_palette, src_palette, blend);
break;
break;*/
}

p->private_impl.func = func;
Expand Down

0 comments on commit 38fc40c

Please sign in to comment.