-#define XBLEND(FN, temp_type, type, max, components, ofs, round) { \
- temp_type opcty = fade * max + round, trnsp = max - opcty; \
- type** output_rows = (type**)output->get_rows(); \
- type** input_rows = (type**)input->get_rows(); \
- ix *= components; ox *= components; \
- \
- for(int i = pkg->out_row1; i < pkg->out_row2; i++) { \
- type* in_row = input_rows[i + iy] + ix; \
- type* output = output_rows[i] + ox; \
- for(int j = 0; j < ow; j++) { \
- if( components == 4 ) { \
- temp_type r, g, b, a; \
- ALPHA4_BLEND(FN, temp_type, in_row, output, max, ofs, ofs, round); \
- ALPHA4_STORE(output, ofs, max); \
- } \
- else { \
- temp_type r, g, b; \
- ALPHA3_BLEND(FN, temp_type, in_row, output, max, ofs, ofs, round); \
- ALPHA3_STORE(output, ofs, max); \
- } \
- in_row += components; output += components; \
- } \
- } \
- break; \
-}
-
-#define XBLEND_ONLY(FN) { \
- switch(input->get_color_model()) { \
- case BC_RGB_FLOAT: XBLEND(FN, z_float, z_float, 1.f, 3, 0, 0.f); \
- case BC_RGBA_FLOAT: XBLEND(FN, z_float, z_float, 1.f, 4, 0, 0.f); \
- case BC_RGB888: XBLEND(FN, z_int32_t, z_uint8_t, 0xff, 3, 0, .5f); \
- case BC_YUV888: XBLEND(FN, z_int32_t, z_uint8_t, 0xff, 3, 0x80, .5f); \
- case BC_RGBA8888: XBLEND(FN, z_int32_t, z_uint8_t, 0xff, 4, 0, .5f); \
- case BC_YUVA8888: XBLEND(FN, z_int32_t, z_uint8_t, 0xff, 4, 0x80, .5f); \
- case BC_RGB161616: XBLEND(FN, z_int64_t, z_uint16_t, 0xffff, 3, 0, .5f); \
- case BC_YUV161616: XBLEND(FN, z_int64_t, z_uint16_t, 0xffff, 3, 0x8000, .5f); \
- case BC_RGBA16161616: XBLEND(FN, z_int64_t, z_uint16_t, 0xffff, 4, 0, .5f); \
- case BC_YUVA16161616: XBLEND(FN, z_int64_t, z_uint16_t, 0xffff, 4, 0x8000, .5f); \
- } \
- break; \
-}
-