Skip to content

Commit 537dbfa

Browse files
committed
Fix some problems with 3-way buffer blitting
1 parent cd3afe8 commit 537dbfa

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

kos/include/libvideo/gfx/blend.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,19 @@ __DECL_END
141141

142142
/* Same as `GFX_BLENDMODE_ALPHA', but with an additional constant factor "ca"
143143
* that gets multiplied in in every calculation (useful for defining "global"
144-
* alpha values) */
144+
* alpha values)
145+
*
146+
* NOTE: "ca" is the SOURCE-alpha factor (iow: 0xff means "GFX_BLENDMODE_ALPHA") */
145147
#define GFX_BLENDMODE_ALPHA_FACTOR(ca) \
146148
GFX_BLENDMODE_EX(/*RGB=*/SRC_ALPHA_MUL_CONSTANT_ALPHA, ADD, ONE_MINUS_SRC_ALPHA_MUL_CONSTANT_ALPHA, \
147149
/*A =*/ONE, ADD, ONE_MINUS_SRC_ALPHA_MUL_CONSTANT_ALPHA, \
148150
0, 0, 0, ca)
149151

150152
/* Same as `GFX_BLENDMODE_ALPHA', but use "ca" instead of source alpha values
151153
* In this sense, this is the same as "GFX_BLENDMODE_ALPHA_FACTOR()", but is
152-
* faster when the source colors always use `VIDEO_CHANNEL_MAX' for alpha. */
154+
* faster when the source colors always use `VIDEO_CHANNEL_MAX' for alpha.
155+
*
156+
* NOTE: "ca" is the SOURCE-alpha factor (iow: 0xff means "GFX_BLENDMODE_OVERRIDE") */
153157
#define GFX_BLENDMODE_ALPHA_OVERRIDE(ca) \
154158
GFX_BLENDMODE_EX(/*RGB=*/CONSTANT_ALPHA, ADD, ONE_MINUS_CONSTANT_ALPHA, \
155159
/*A =*/ONE, ADD, ONE_MINUS_CONSTANT_ALPHA, \

kos/src/apps/showpic/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ do_showpic(struct screen_buffer *screen,
345345
#elif 1
346346
{
347347
struct video_gfx flipgfx = image_gfx;
348-
video_gfx_hmirror(&flipgfx);
349-
video_gfx_setblend(&flipgfx, GFX_BLENDMODE_ALPHA_OVERRIDE(240));
348+
video_gfx_lrot90(&flipgfx);
349+
video_gfx_setblend(&flipgfx, GFX_BLENDMODE_ALPHA_OVERRIDE(200));
350350
video_gfx_stretch3(&screen_gfx, blit_x, blit_y,
351351
&flipgfx, 0, 0,
352352
blit_w, blit_h,

kos/src/libvideo/gfx/gfx-debug.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
DECL_BEGIN
3535

36+
#undef GFX_DEBUG
37+
#if !defined(NDEBUG) && 0
38+
#define GFX_DEBUG
39+
#endif
40+
3641
#ifndef PRIdOFF
3742
#include <inttypes.h>
3843
#define PRIdOFF __PRIN_PREFIX(__SIZEOF_VIDEO_OFFSET_T__) "d"
@@ -44,11 +49,6 @@ DECL_BEGIN
4449
#define PRIxCOL __PRIN_PREFIX(__SIZEOF_VIDEO_COLOR_T__) "x"
4550
#endif /* !PRIdOFF */
4651

47-
#undef GFX_DEBUG
48-
#if !defined(NDEBUG) && 0
49-
#define GFX_DEBUG
50-
#endif
51-
5252
#ifdef GFX_DEBUG
5353
#include <sys/syslog.h>
5454
#define TRACE_START(...) syslog(LOG_DEBUG, "[gfx] start: " __VA_ARGS__)

kos/src/libvideo/gfx/swgfx/hl_blit-nowrap.c.inl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ LOCAL_libvideo_swblitter_blit(LOCAL_struct_video_blitter const *__restrict self
532532
}
533533
#undef LOCAL_dst_vx_flags
534534

535-
/* Calculate rddst->wrdst transformation matrix */
535+
/* Calculate dst->out transformation matrix */
536536
#ifdef LOCAL_USE_SWBLITTER3
537537
dst_matrix = VIDEO_IMATRIX2D_INIT(1, 0, 0, 1);
538538
if ((dst->vx_flags ^ out->vx_flags) & VIDEO_GFX_F_XMIRROR) {
@@ -543,7 +543,14 @@ LOCAL_libvideo_swblitter_blit(LOCAL_struct_video_blitter const *__restrict self
543543
video_imatrix2d_set(&dst_matrix, 1, 1, -1);
544544
dst_y += LOCAL_dst_size_y - 1;
545545
}
546-
if ((dst->vx_flags ^ out->vx_flags) & VIDEO_GFX_F_XYSWAP) {
546+
547+
/* Apply X/Y-swap rules and finalize dst_x/dst_y coords */
548+
if (dst->vx_flags & VIDEO_GFX_F_XYSWAP) {
549+
video_imatrix2d_swap(&dst_matrix, 0, 0, /**/ 1, 0);
550+
video_imatrix2d_swap(&dst_matrix, 1, 1, /**/ 0, 1);
551+
Tswap(video_offset_t, dst_x, dst_y);
552+
}
553+
if (out->vx_flags & VIDEO_GFX_F_XYSWAP) {
547554
video_imatrix2d_swap(&dst_matrix, 0, 0, /**/ 0, 1);
548555
video_imatrix2d_swap(&dst_matrix, 1, 1, /**/ 1, 0);
549556
Tswap(video_offset_t, dst_x, dst_y);

0 commit comments

Comments
 (0)