mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Remove setRect() and setOffset() macros
This commit is contained in:
+2
-2
@@ -174,12 +174,12 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, BYTE cl) {
|
||||
TTF_SizeUTF8(fontset->id, str_utf8, &w, &h);
|
||||
// Center vertically to the box.
|
||||
y -= (TTF_FontHeight(fontset->id) - fontset->size) / 2;
|
||||
setRect(r_dst, x, y, w, h);
|
||||
r_dst = (SDL_Rect){x, y, w, h};
|
||||
|
||||
if (sdl_dib->format->BitsPerPixel == 8 && this.antialiase_on) {
|
||||
sdl_drawAntiAlias_8bpp(x, y, fs, cl);
|
||||
} else {
|
||||
setRect(r_src, 0, 0, w, h);
|
||||
r_src = (SDL_Rect){0, 0, w, h};
|
||||
SDL_BlitSurface(fs, &r_src, sdl_dib, &r_dst);
|
||||
}
|
||||
|
||||
|
||||
+19
-38
@@ -113,9 +113,7 @@ void sdl_updateArea(MyRectangle *src, MyPoint *dst) {
|
||||
|
||||
/* 全画面更新 */
|
||||
static void sdl_updateAll() {
|
||||
SDL_Rect rect;
|
||||
|
||||
setRect(rect, winoffset_x, winoffset_y, view_w, view_h);
|
||||
SDL_Rect rect = {winoffset_x, winoffset_y, view_w, view_h};
|
||||
|
||||
SDL_BlitSurface(sdl_dib, &sdl_view, sdl_display, &rect);
|
||||
|
||||
@@ -139,33 +137,29 @@ void sdl_setPalette(Palette256 *pal, int src, int cnt) {
|
||||
|
||||
/* 矩形の描画 */
|
||||
void sdl_drawRectangle(int x, int y, int w, int h, BYTE c) {
|
||||
SDL_Rect rect;
|
||||
|
||||
sdl_pal_check();
|
||||
|
||||
Uint32 col = (sdl_dib->format->BitsPerPixel == 8) ? c
|
||||
: SDL_MapRGB(sdl_dib->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b);
|
||||
|
||||
setRect(rect,x,y,w,1);
|
||||
SDL_Rect rect = {x, y, w, 1};
|
||||
SDL_FillRect(sdl_dib, &rect, col);
|
||||
|
||||
setRect(rect,x,y,1,h);
|
||||
rect = (SDL_Rect){x, y, 1, h};
|
||||
SDL_FillRect(sdl_dib, &rect, col);
|
||||
|
||||
setRect(rect,x,y+h-1,w,1);
|
||||
rect = (SDL_Rect){x, y + h - 1, w, 1};
|
||||
SDL_FillRect(sdl_dib, &rect, col);
|
||||
|
||||
setRect(rect,x+w-1,y,1,h);
|
||||
rect = (SDL_Rect){x + w - 1, y, 1, h};
|
||||
SDL_FillRect(sdl_dib, &rect, col);
|
||||
}
|
||||
|
||||
/* 矩形塗りつぶし */
|
||||
void sdl_fillRectangle(int x, int y, int w, int h, BYTE c) {
|
||||
SDL_Rect rect;
|
||||
|
||||
sdl_pal_check();
|
||||
|
||||
setRect(rect,x,y,w,h);
|
||||
SDL_Rect rect = {x, y, w, h};
|
||||
|
||||
Uint32 col = (sdl_dib->format->BitsPerPixel == 8) ? c
|
||||
: SDL_MapRGB(sdl_dib->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b);
|
||||
@@ -178,9 +172,8 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (sx == dx && sy == dy)
|
||||
return;
|
||||
|
||||
SDL_Rect r_src, r_dst;
|
||||
setRect(r_src, sx, sy, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
|
||||
SDL_Rect intersect;
|
||||
if (SDL_IntersectRect(&r_src, &r_dst, &intersect)) {
|
||||
@@ -195,8 +188,6 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
* dib に指定のパレット sp を抜いてコピー
|
||||
*/
|
||||
void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp) {
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
sdl_pal_check();
|
||||
|
||||
Uint32 col = sp;
|
||||
@@ -209,19 +200,15 @@ void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp) {
|
||||
|
||||
SDL_SetColorKey(sdl_dib, SDL_TRUE, col);
|
||||
|
||||
setRect(r_src, sx, sy, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
|
||||
SDL_BlitSurface(sdl_dib, &r_src, sdl_dib, &r_dst);
|
||||
SDL_SetColorKey(sdl_dib, SDL_FALSE, 0);
|
||||
}
|
||||
|
||||
void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int w, int h) {
|
||||
SDL_Surface *s;
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0);
|
||||
|
||||
SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0);
|
||||
SDL_LockSurface(s);
|
||||
|
||||
#if 0 /* for broken cg */
|
||||
@@ -268,8 +255,8 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int w, int h) {
|
||||
SDL_SetColorKey(s, SDL_TRUE, cg->spritecolor);
|
||||
}
|
||||
|
||||
setRect(r_src, 0, 0, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = { 0, 0, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
|
||||
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
|
||||
SDL_FreeSurface(s);
|
||||
@@ -380,8 +367,6 @@ static void fader_in(int n) {
|
||||
static SDL_Surface *s_fader;
|
||||
|
||||
if (n == 0) {
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
s_fader = SDL_CreateRGBSurface(0, sdl_display->w, sdl_display->h,
|
||||
sdl_display->format->BitsPerPixel, 0, 0, 0, 0);
|
||||
|
||||
@@ -390,8 +375,8 @@ static void fader_in(int n) {
|
||||
sdl_display->format->palette->colors,
|
||||
sizeof(SDL_Color) * 256);
|
||||
}
|
||||
setRect(r_src, view_x, view_y, view_w, view_h);
|
||||
setRect(r_dst, winoffset_x, winoffset_y, view_w, view_h);
|
||||
SDL_Rect r_src = {view_x, view_y, view_w, view_h};
|
||||
SDL_Rect r_dst = {winoffset_x, winoffset_y, view_w, view_h};
|
||||
SDL_BlitSurface(sdl_dib, &r_src, s_fader, &r_dst);
|
||||
}
|
||||
|
||||
@@ -427,8 +412,7 @@ static void fader_out(int n,Uint32 c) {
|
||||
}
|
||||
|
||||
static __inline void sdl_fade_blit(void) {
|
||||
SDL_Rect r_dst;
|
||||
setRect(r_dst, winoffset_x, winoffset_y, view_w, view_h);
|
||||
SDL_Rect r_dst = {winoffset_x, winoffset_y, view_w, view_h};
|
||||
|
||||
SDL_BlitSurface(sdl_dib, &sdl_view, sdl_display, &r_dst);
|
||||
sdl_dirty = TRUE;
|
||||
@@ -474,20 +458,17 @@ void sdl_whiteOut(int step) {
|
||||
* 指定範囲にパレット col を rate の割合で重ねる CK1
|
||||
*/
|
||||
void sdl_wrapColor(int sx, int sy, int w, int h, BYTE c, int rate) {
|
||||
SDL_Surface *s;
|
||||
SDL_Rect r_src,r_dst;
|
||||
|
||||
s = SDL_CreateRGBSurface(0, w, h, sdl_dib->format->BitsPerPixel, 0, 0, 0, 0);
|
||||
SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, sdl_dib->format->BitsPerPixel, 0, 0, 0, 0);
|
||||
assert(s->format->BitsPerPixel > 8);
|
||||
|
||||
Uint32 col = SDL_MapRGB(sdl_dib->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b);
|
||||
|
||||
setRect(r_src, 0, 0, w, h);
|
||||
SDL_Rect r_src = {0, 0, w, h};
|
||||
SDL_FillRect(s, &r_src, col);
|
||||
|
||||
SDL_SetSurfaceBlendMode(s, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetSurfaceAlphaMod(s, rate);
|
||||
setRect(r_dst, sx, sy, w, h);
|
||||
SDL_Rect r_dst = {sx, sy, w, h};
|
||||
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
+22
-34
@@ -44,7 +44,6 @@ static void sdl_scaledCopyAreaInternal(SDL_Surface *src, SDL_Surface *dst, int s
|
||||
int *row, *col;
|
||||
int x, y;
|
||||
SDL_Surface *ss;
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
ss = SDL_CreateRGBSurface(0, dw, dh, dst->format->BitsPerPixel, 0, 0, 0, 0);
|
||||
|
||||
@@ -127,8 +126,8 @@ static void sdl_scaledCopyAreaInternal(SDL_Surface *src, SDL_Surface *dst, int s
|
||||
|
||||
SDL_UnlockSurface(ss);
|
||||
|
||||
setRect(r_src, 0, 0, dw, dh);
|
||||
setRect(r_dst, dx, dy, dw, dh);
|
||||
SDL_Rect r_src = { 0, 0, dw, dh};
|
||||
SDL_Rect r_dst = {dx, dy, dw, dh};
|
||||
SDL_BlitSurface(ss, &r_src, dst, &r_dst);
|
||||
|
||||
SDL_FreeSurface(ss);
|
||||
@@ -153,7 +152,6 @@ void sdl_zoom(int x, int y, int w, int h) {
|
||||
void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int w, int h) {
|
||||
/* draw alpha pixel */
|
||||
SDL_Surface *s;
|
||||
SDL_Rect r_src,r_dst;
|
||||
BYTE *pic_save = NULL;
|
||||
|
||||
/* set alpha Level */
|
||||
@@ -209,8 +207,8 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int w, int h) {
|
||||
}
|
||||
SDL_UnlockSurface(s);
|
||||
}
|
||||
setRect(r_src, 0, 0, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = { 0, 0, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
|
||||
SDL_FreeSurface(s);
|
||||
|
||||
@@ -239,12 +237,11 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l
|
||||
BYTE *p_src, *p_dst, *p_ds;
|
||||
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_Rect r_src, r_dst;
|
||||
int x, y;
|
||||
|
||||
setRect(r_dst, sx, sy, w, h);
|
||||
setRect(r_src, 0, 0, w, h);
|
||||
SDL_BlitSurface(sdl_dib, &r_dst, s, &r_src);
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_tmp = { 0, 0, w, h};
|
||||
SDL_BlitSurface(sdl_dib, &r_src, s, &r_tmp);
|
||||
|
||||
SDL_LockSurface(s);
|
||||
|
||||
@@ -284,16 +281,14 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l
|
||||
}
|
||||
SDL_UnlockSurface(s);
|
||||
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_BlitSurface(s, &r_src, sdl_dib, &r_dst);
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
SDL_BlitSurface(s, &r_tmp, sdl_dib, &r_dst);
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
setRect(r_src, sx, sy, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetSurfaceAlphaMod(sdl_dib, lv);
|
||||
SDL_BlitSurface(sdl_dib, &r_src, sdl_dib, &r_dst);
|
||||
@@ -301,9 +296,8 @@ void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, i
|
||||
}
|
||||
|
||||
#define copyAreaSP_level(fn, cn, v) void sdl_copyAreaSP16_##fn(int sx, int sy, int w, int h, int dx, int dy, int lv) { \
|
||||
SDL_Rect r_src,r_dst; \
|
||||
setRect(r_src, sx, sy, w, h); \
|
||||
setRect(r_dst, dx, dy, w, h); \
|
||||
SDL_Rect r_src = {sx, sy, w, h}; \
|
||||
SDL_Rect r_dst = {dx, dy, w, h}; \
|
||||
SDL_SetSurfaceBlendMode(sdl_dib, SDL_BLENDMODE_BLEND); \
|
||||
SDL_SetSurfaceAlphaMod(sdl_dib, v); \
|
||||
SDL_FillRect(sdl_dib, &r_dst, cn); \
|
||||
@@ -332,12 +326,11 @@ void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C
|
||||
void sdl_getPixel(int x, int y, Palette *cell) {
|
||||
SDL_LockSurface(sdl_dib);
|
||||
|
||||
BYTE *p = PIXEL_AT(sdl_dib, x, y);
|
||||
if (sdl_dib->format->BitsPerPixel == 8) {
|
||||
BYTE *rt = setOffset(sdl_dib, x, y);
|
||||
cell->pixel = *rt;
|
||||
cell->pixel = *p;
|
||||
} else {
|
||||
Uint32 cl=0;
|
||||
BYTE *p = setOffset(sdl_dib, x, y);
|
||||
|
||||
switch (sdl_dib->format->BytesPerPixel) {
|
||||
case 2:
|
||||
@@ -370,17 +363,14 @@ void sdl_getPixel(int x, int y, Palette *cell) {
|
||||
* dib から領域の切り出し
|
||||
*/
|
||||
void* sdl_saveRegion(int x, int y, int w, int h) {
|
||||
SDL_Surface *s;
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
s = SDL_CreateRGBSurface(0, w, h, sdl_dib->format->BitsPerPixel,
|
||||
SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, sdl_dib->format->BitsPerPixel,
|
||||
sdl_dib->format->Rmask, sdl_dib->format->Gmask,
|
||||
sdl_dib->format->Bmask, sdl_dib->format->Amask);
|
||||
if (sdl_dib->format->BitsPerPixel == 8)
|
||||
memcpy(s->format->palette->colors, sdl_dib->format->palette->colors,
|
||||
sizeof(SDL_Color) * sdl_dib->format->palette->ncolors);
|
||||
setRect(r_src, x, y, w, h);
|
||||
setRect(r_dst, 0, 0, w, h);
|
||||
SDL_Rect r_src = {x, y, w, h};
|
||||
SDL_Rect r_dst = {0, 0, w, h};
|
||||
SDL_BlitSurface(sdl_dib, &r_src, s, &r_dst);
|
||||
return s;
|
||||
}
|
||||
@@ -397,10 +387,9 @@ void sdl_delRegion(void *psrc) {
|
||||
*/
|
||||
void sdl_putRegion(void *psrc, int x, int y) {
|
||||
SDL_Surface *src = (SDL_Surface *)psrc;
|
||||
SDL_Rect r_src,r_dst;
|
||||
|
||||
setRect(r_src, 0, 0, src->w, src->h);
|
||||
setRect(r_dst, x, y, src->w, src->h);
|
||||
SDL_Rect r_src = {0, 0, src->w, src->h};
|
||||
SDL_Rect r_dst = {x, y, src->w, src->h};
|
||||
|
||||
SDL_BlitSurface(src, &r_src, sdl_dib, &r_dst);
|
||||
}
|
||||
@@ -410,10 +399,9 @@ void sdl_putRegion(void *psrc, int x, int y) {
|
||||
*/
|
||||
void sdl_CopyRegion(void *psrc, int sx, int sy, int w,int h, int dx, int dy) {
|
||||
SDL_Surface *src = (SDL_Surface *)psrc;
|
||||
SDL_Rect r_src,r_dst;
|
||||
|
||||
setRect(r_src, sx, sy, w, h);
|
||||
setRect(r_dst, dx, dy, w, h);
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
|
||||
SDL_BlitSurface(src, &r_src, sdl_dib, &r_dst);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,4 @@ extern struct sdl_private_data *sdl_videodev;
|
||||
#define winoffset_y (sdl_videodev->winoffset_y)
|
||||
#define sdl_custom_event_handler (sdl_videodev->custom_event_handler)
|
||||
|
||||
#define setRect(r,xx,yy,ww,hh) (r).x=(xx),(r).y=(yy),(r).w=(ww),(r).h=(hh)
|
||||
#define setOffset(s,x,y) (s->pixels) + (x) * (s->format->BytesPerPixel) + (y) * s->pitch
|
||||
|
||||
#endif /* __SDL_PRIVATE_H__ */
|
||||
|
||||
Reference in New Issue
Block a user