mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-09 23:58:25 +03:00
Simplify gre_BlendUseAMap()
This commit is contained in:
@@ -70,7 +70,6 @@ add_library(modules STATIC
|
||||
lib/graph_blend_amap.c
|
||||
lib/graph_draw_amap.c
|
||||
lib/graph_cg.c
|
||||
lib/gre_blend_useamap.c
|
||||
nDEMO/nDEMO.c
|
||||
nDEMOE/nDEMOE.c
|
||||
oDEMO/oDEMO.c
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
gr_xxxx はクリッピングあり
|
||||
gre_xxxx はクリッピングなし
|
||||
*/
|
||||
|
||||
/**
|
||||
* surface から surface にコピーなどをする際に、転送元と転送先のsurface
|
||||
* の大きさや、転送元・転送先座標、転送する領域の大きさなどから、実際に
|
||||
|
||||
@@ -9,6 +9,40 @@
|
||||
#include "ngraph.h"
|
||||
#include "ags.h"
|
||||
|
||||
static void gre_BlendUseAMap(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height) {
|
||||
uint8_t *sp = GETOFFSET_PIXEL(src, sx, sy);
|
||||
uint8_t *dp = GETOFFSET_PIXEL(dst, dx, dy);
|
||||
uint8_t *ap = GETOFFSET_ALPHA(src, sx, sy);
|
||||
|
||||
switch(dst->depth) {
|
||||
case 16:
|
||||
for (int y = 0; y < height; y++) {
|
||||
uint16_t *yls = (uint16_t *)(sp + y * src->bytes_per_line);
|
||||
uint16_t *yld = (uint16_t *)(dp + y * dst->bytes_per_line);
|
||||
uint8_t *yla = (uint8_t *)(ap + y * src->width);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*yld = ALPHABLEND16(*yls, *yld, *yla);
|
||||
yls++; yld++; yla++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
for (int y = 0; y < height; y++) {
|
||||
uint32_t *yls = (uint32_t *)(sp + y * src->bytes_per_line);
|
||||
uint32_t *yld = (uint32_t *)(dp + y * dst->bytes_per_line);
|
||||
uint8_t *yla = (uint8_t *)(ap + y * src->width);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*yld = ALPHABLEND24(*yls, *yld, *yla);
|
||||
yls++; yld++; yla++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void gr_blend_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) {
|
||||
if (src == NULL || dst == NULL) return;
|
||||
if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return;
|
||||
@@ -18,6 +52,6 @@ void gr_blend_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx,
|
||||
return;
|
||||
}
|
||||
|
||||
gre_BlendUseAMap(dst, dx, dy, dst, dx, dy, src, sx, sy, sw, sh, src, sx, sy, 255);
|
||||
gre_BlendUseAMap(dst, dx, dy, src, sx, sy, sw, sh);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
// dst の上に src をalphamapを参照しつつ、ブレンド率 lv でブレンド
|
||||
// したものを write へ書き出し
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "portab.h"
|
||||
#include "surface.h"
|
||||
#include "ngraph.h"
|
||||
#include "ags.h"
|
||||
|
||||
void gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, surface_t *alpha, int ax, int ay, int lv) {
|
||||
uint8_t *sp, *dp, *wp, *ap;
|
||||
int x, y;
|
||||
|
||||
wp = GETOFFSET_PIXEL(write, wx, wy);
|
||||
sp = GETOFFSET_PIXEL(src, sx, sy);
|
||||
dp = GETOFFSET_PIXEL(dst, dx, dy);
|
||||
ap = GETOFFSET_ALPHA(alpha, ax, ay);
|
||||
|
||||
if (lv == 255) {
|
||||
switch(dst->depth) {
|
||||
case 16:
|
||||
{
|
||||
uint16_t *yls, *yld, *ylw;
|
||||
uint8_t *yla;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
yls = (uint16_t *)(sp + y * src->bytes_per_line);
|
||||
yld = (uint16_t *)(dp + y * dst->bytes_per_line);
|
||||
ylw = (uint16_t *)(wp + y * write->bytes_per_line);
|
||||
yla = (uint8_t *)(ap + y * alpha->width);
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
*ylw = ALPHABLEND16(*yls, *yld, *yla);
|
||||
yls++; yld++; ylw++; yla++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
uint32_t *yls, *yld, *ylw;
|
||||
uint8_t *yla;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
yls = (uint32_t *)(sp + y * src->bytes_per_line);
|
||||
yld = (uint32_t *)(dp + y * dst->bytes_per_line);
|
||||
ylw = (uint32_t *)(wp + y * write->bytes_per_line);
|
||||
yla = (uint8_t *)(ap + y * alpha->width);
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
*ylw = ALPHABLEND24(*yls, *yld, *yla);
|
||||
yls++; yld++; ylw++; yla++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
switch(dst->depth) {
|
||||
case 16:
|
||||
{
|
||||
uint16_t *yls, *yld, *ylw;
|
||||
uint8_t *yla;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
yls = (uint16_t *)(sp + y * src->bytes_per_line);
|
||||
yld = (uint16_t *)(dp + y * dst->bytes_per_line);
|
||||
ylw = (uint16_t *)(wp + y * write->bytes_per_line);
|
||||
yla = (uint8_t *)(ap + y * alpha->width);
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
*ylw = ALPHABLEND16(*yls, *yld, (*yla * lv) / 255);
|
||||
yls++; yld++; ylw++; yla++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
uint32_t *yls, *yld, *ylw;
|
||||
uint8_t *yla;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
yls = (uint32_t *)(sp + y * src->bytes_per_line);
|
||||
yld = (uint32_t *)(dp + y * dst->bytes_per_line);
|
||||
ylw = (uint32_t *)(wp + y * write->bytes_per_line);
|
||||
yla = (uint8_t *)(ap + y * alpha->width);
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
*ylw = ALPHABLEND24(*yls, *yld, (*yla * lv) / 255);
|
||||
yls++; yld++; ylw++; yla++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,6 @@ void gr_draw_amap(surface_t *dst, int dx, int dy, uint8_t *src, int width, int h
|
||||
#define gr_bright_dst_only(dst,dx,dy,w,h,lv) gr_copy_bright(dst,dx,dy,dst,dx,dy,w,h,lv)
|
||||
// void gr_bright_dst_only(surface_t *dst, int dx, int dy, int w, int h, int lv);
|
||||
|
||||
/* in gre_blend_useamap.c */
|
||||
void gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, surface_t *alpha, int ax, int ay, int lv);
|
||||
|
||||
/* in graph_cg.c */
|
||||
void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y);
|
||||
void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y);
|
||||
|
||||
Reference in New Issue
Block a user