Skip to content

Commit 11b4f1a

Browse files
committed
Remove public API for video_buffer_forbitmask()
No, it won't come back, but you can get (almost) the same functionality via `video_domain_formem()` (with the only exception being that the later doesn't support non-byte-aligned strides)
1 parent 3ba70e2 commit 11b4f1a

File tree

4 files changed

+48
-125
lines changed

4 files changed

+48
-125
lines changed

kos/include/libvideo/gfx/buffer.h

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -679,36 +679,6 @@ __CXXDECL_END
679679
__DEFINE_REFCNT_FUNCTIONS(struct video_buffer, vb_refcnt, video_buffer_destroy)
680680

681681

682-
#if 1 /* TODO: BEGIN DEPRECATED */
683-
684-
/* Create a video buffer that represents the pixel data defined by a
685-
* given `__bm' (bitmask). This function is primarily used internally
686-
* by `video_gfx_absfillmask()' and `video_gfx_absfillstretchmask()'
687-
* to deal with GFX contexts where the bitmask cannot be rendered
688-
* using the default method, but has to be rendered by being blit.
689-
*
690-
* @param: __size_x: Width of the given `__bm' (in pixels)
691-
* @param: __size_y: Height of the given `__bm' (in pixels)
692-
* @param: __bm: Bitmask whose data should be referenced interpreted
693-
* @param: __bg_fg_colors: Colors that 0/1 bits of `__bm' should map to
694-
* @return: * : The newly created video buffer
695-
* @return: NULL: [errno=ENOMEM] Insufficient memory (won't happen when
696-
* used internally, where struct is just
697-
* allocated on-stack) */
698-
typedef __ATTR_WUNUSED_T __ATTR_IN_T(3) __ATTR_IN_T(4) __REF struct video_buffer *
699-
(LIBVIDEO_GFX_CC *PVIDEO_BUFFER_FORBITMASK)(video_dim_t __size_x, video_dim_t __size_y,
700-
struct video_bitmask const *__restrict __bm,
701-
video_color_t const __bg_fg_colors[2]);
702-
#ifdef LIBVIDEO_GFX_WANT_PROTOTYPES
703-
LIBVIDEO_GFX_DECL __ATTR_WUNUSED __ATTR_IN(3) __ATTR_IN(4) __REF struct video_buffer *LIBVIDEO_GFX_CC
704-
video_buffer_forbitmask(video_dim_t __size_x, video_dim_t __size_y,
705-
struct video_bitmask const *__restrict __bm,
706-
video_color_t const __bg_fg_colors[2]);
707-
#endif /* LIBVIDEO_GFX_WANT_PROTOTYPES */
708-
709-
#endif /* TODO: END DEPRECATED */
710-
711-
712682
/* Convert `__self' into the specified domain and format. */
713683
typedef __ATTR_WUNUSED_T __ATTR_INOUT_T(1) __ATTR_NONNULL_T((2)) __ATTR_IN_T(3) __REF struct video_buffer *
714684
(LIBVIDEO_GFX_CC *PVIDEO_BUFFER_CONVERT)(struct video_buffer *__restrict __self,
@@ -768,6 +738,11 @@ typedef void __NOTHROW_T(LIBVIDEO_GFX_CC *video_buffer_custom_revoke_t)(void *__
768738
typedef __ATTR_WUNUSED_T __ATTR_NONNULL_T((3, 4, 5)) __REF struct video_buffer *
769739
(LIBVIDEO_GFX_CC *PVIDEO_BUFFER_FORCUSTOM)(video_dim_t __size_x, video_dim_t __size_y,
770740
struct video_format const *__restrict __format,
741+
/* TODO: Instead of passing each operator individually,
742+
* define a helper struct that packages them all
743+
* together, and document that said struct gets
744+
* copied (and doesn't need to remain valid) once
745+
* this call returns. */
771746
video_buffer_custom_getpixel_t __getpixel,
772747
video_buffer_custom_setpixel_t __setpixel,
773748
video_buffer_custom_destroy_t __destroy,
Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include "../gfx.h"
4949
#include "../ramdomain.h"
5050
#include "../swgfx.h"
51-
#include "bitmask.h"
51+
#include "old-bitmask.h"
5252

5353
DECL_BEGIN
5454

@@ -70,10 +70,10 @@ bitmask_destroy(struct video_buffer *__restrict self) {
7070
PRIVATE ATTR_INOUT(1) ATTR_OUT(2) int FCC
7171
bitmask_lock(struct video_buffer *__restrict self,
7272
struct video_lock *__restrict lock) {
73-
struct bitmask_buffer *me = (struct bitmask_buffer *)self;
73+
struct old_bitmask_buffer *me = (struct old_bitmask_buffer *)self;
7474
if ((me->bmb_bm.vbm_scan & 7) || me->bmb_bm.vbm_skip) {
7575
/* Not scanline-aligned -> cannot "lock" into memory */
76-
errno = EINVAL;
76+
errno = ENOTSUP;
7777
return -1;
7878
}
7979
lock->vl_data = (byte_t *)me->bmb_bm.vbm_mask;
@@ -86,11 +86,11 @@ bitmask_lock(struct video_buffer *__restrict self,
8686
PRIVATE ATTR_INOUT(1) NONNULL((2)) int FCC
8787
bitmask_lockregion(struct video_buffer *__restrict self,
8888
struct video_regionlock *__restrict lock) {
89-
struct bitmask_buffer *me = (struct bitmask_buffer *)self;
89+
struct old_bitmask_buffer *me = (struct old_bitmask_buffer *)self;
9090
video_regionlock_assert(me, lock);
9191
if (me->bmb_bm.vbm_scan & 7) {
9292
/* Not scanline-aligned -> cannot "lock" into memory */
93-
errno = EINVAL;
93+
errno = ENOTSUP;
9494
return -1;
9595
}
9696
lock->vrl_lock.vl_stride = me->bmb_bm.vbm_scan >> 3;
@@ -103,7 +103,7 @@ bitmask_lockregion(struct video_buffer *__restrict self,
103103
PRIVATE ATTR_IN(1) video_pixel_t CC
104104
bitmask_gfx__getpixel(struct video_gfx const *__restrict self,
105105
video_coord_t x, video_coord_t y) {
106-
struct bitmask_buffer *me = (struct bitmask_buffer *)self->vx_buffer;
106+
struct old_bitmask_buffer *me = (struct old_bitmask_buffer *)self->vx_buffer;
107107
uintptr_t bitoff = me->bmb_bm.vbm_skip + x + y * me->bmb_bm.vbm_scan;
108108
byte_t const *bm = (byte_t const *)me->bmb_bm.vbm_mask;
109109
return (bm[bitoff >> 3] >> (7 - (bitoff & 7))) & 1;
@@ -113,7 +113,7 @@ PRIVATE ATTR_IN(1) void CC
113113
bitmask_gfx__setpixel(struct video_gfx const *__restrict self,
114114
video_coord_t x, video_coord_t y,
115115
video_pixel_t pixel) {
116-
struct bitmask_buffer *me = (struct bitmask_buffer *)self->vx_buffer;
116+
struct old_bitmask_buffer *me = (struct old_bitmask_buffer *)self->vx_buffer;
117117
uintptr_t bitoff = me->bmb_bm.vbm_skip + x + y * me->bmb_bm.vbm_scan;
118118
byte_t mask, value, *bm = (byte_t *)me->bmb_bm.vbm_mask;
119119
bm += bitoff >> 3;
@@ -145,7 +145,7 @@ bitmask_gfx_optimize(struct video_gfx *__restrict self) {
145145
/* When no blending is being done, speed up color lookup by directly translating bits */
146146
struct gfx_bitmaskdrv *drv = video_bitmaskgfx_getdrv(self);
147147
if likely(drv->xsw_getcolor == &libvideo_swgfx_generic__getcolor_noblend) {
148-
struct bitmask_buffer *me = (struct bitmask_buffer *)self->vx_buffer;
148+
struct old_bitmask_buffer *me = (struct old_bitmask_buffer *)self->vx_buffer;
149149
drv->xsw_getcolor = &bitmask_gfx__getcolor;
150150
drv->gbmd_pal[0] = me->bmb_pal.vp_pal[0];
151151
drv->gbmd_pal[1] = me->bmb_pal.vp_pal[1];
@@ -185,41 +185,39 @@ bitmask_initgfx(struct video_gfx *__restrict self) {
185185

186186

187187

188-
#undef bitmask_ops
189-
PRIVATE struct video_buffer_ops bitmask_ops = {};
190-
INTERN ATTR_RETNONNULL WUNUSED struct video_buffer_ops const *CC _bitmask_ops(void) {
191-
if unlikely(!bitmask_ops.vi_destroy) {
192-
bitmask_ops.vi_rlock = &bitmask_rlock;
193-
bitmask_ops.vi_wlock = &bitmask_wlock;
194-
bitmask_ops.vi_unlock = &libvideo_buffer_noop_unlock;
195-
bitmask_ops.vi_rlockregion = &bitmask_rlockregion;
196-
bitmask_ops.vi_wlockregion = &bitmask_wlockregion;
197-
bitmask_ops.vi_unlockregion = &libvideo_buffer_noop_unlockregion;
198-
bitmask_ops.vi_initgfx = &bitmask_initgfx;
199-
bitmask_ops.vi_updategfx = &bitmask_updategfx;
188+
PRIVATE struct video_buffer_ops old_bitmask_ops = {};
189+
PRIVATE ATTR_RETNONNULL WUNUSED struct video_buffer_ops const *CC _old_bitmask_ops(void) {
190+
if unlikely(!old_bitmask_ops.vi_destroy) {
191+
old_bitmask_ops.vi_rlock = &bitmask_rlock;
192+
old_bitmask_ops.vi_wlock = &bitmask_wlock;
193+
old_bitmask_ops.vi_unlock = &libvideo_buffer_noop_unlock;
194+
old_bitmask_ops.vi_rlockregion = &bitmask_rlockregion;
195+
old_bitmask_ops.vi_wlockregion = &bitmask_wlockregion;
196+
old_bitmask_ops.vi_unlockregion = &libvideo_buffer_noop_unlockregion;
197+
old_bitmask_ops.vi_initgfx = &bitmask_initgfx;
198+
old_bitmask_ops.vi_updategfx = &bitmask_updategfx;
200199
COMPILER_WRITE_BARRIER();
201-
bitmask_ops.vi_destroy = &bitmask_destroy;
200+
old_bitmask_ops.vi_destroy = &bitmask_destroy;
202201
COMPILER_WRITE_BARRIER();
203202
}
204-
return &bitmask_ops;
203+
return &old_bitmask_ops;
205204
}
206-
#define bitmask_ops (*_bitmask_ops())
207205

208206

209-
/* Initialize a "struct bitmask_buffer"
207+
/* Initialize a "struct old_bitmask_buffer"
210208
* @return: * : Always re-returns `self' */
211-
INTERN ATTR_RETNONNULL ATTR_OUT(1) ATTR_IN(4) ATTR_IN(5) struct bitmask_buffer *CC
212-
bitmask_buffer_init(struct bitmask_buffer *__restrict self,
213-
video_dim_t size_x, video_dim_t size_y,
214-
struct video_bitmask const *__restrict bm,
215-
video_color_t const bg_fg_colors[2]) {
209+
INTERN ATTR_RETNONNULL ATTR_OUT(1) ATTR_IN(4) ATTR_IN(5) struct old_bitmask_buffer *CC
210+
old_bitmask_buffer_init(struct old_bitmask_buffer *__restrict self,
211+
video_dim_t size_x, video_dim_t size_y,
212+
struct video_bitmask const *__restrict bm,
213+
video_color_t const bg_fg_colors[2]) {
216214
memcpy(&self->bmb_bm, bm, sizeof(struct video_bitmask));
217215
self->bmb_bm.vbm_mask = (byte_t const *)self->bmb_bm.vbm_mask + (self->bmb_bm.vbm_skip >> 3);
218216
self->bmb_bm.vbm_skip &= 7;
219217
self->bmb_pal.vp_cnt = 2;
220218
self->bmb_pal.vp_pal[0] = bg_fg_colors[0];
221219
self->bmb_pal.vp_pal[1] = bg_fg_colors[1];
222-
self->vb_ops = &bitmask_ops;
220+
self->vb_ops = _old_bitmask_ops();
223221
self->vb_format.vf_codec = video_codec_lookup(VIDEO_CODEC_P1_MSB);
224222
self->vb_format.vf_pal = video_palette_optimize((struct video_palette *)&self->bmb_pal); /* For "vp_color2pixel" */
225223
assert(self->vb_format.vf_codec);
@@ -237,36 +235,6 @@ bitmask_buffer_init(struct bitmask_buffer *__restrict self,
237235
return self;
238236
}
239237

240-
241-
/* Create a video buffer that represents the pixel data defined by a
242-
* given `__bm' (bitmask). This function is primarily used internally
243-
* by `video_gfx_absfillmask()' and `video_gfx_absfillstretchmask()'
244-
* to deal with GFX contexts where the bitmask cannot be rendered
245-
* using the default method, but has to be rendered by being blit.
246-
*
247-
* @param: __size_x: Width of the given `__bm' (in pixels)
248-
* @param: __size_y: Height of the given `__bm' (in pixels)
249-
* @param: __bm: Bitmask whose data should be referenced interpreted
250-
* @param: __bg_fg_colors: Colors that 0/1 bits of `__bm' should map to
251-
* @return: * : The newly created video buffer
252-
* @return: NULL: [errno=ENOMEM] Insufficient memory (won't happen when
253-
* used internally, where struct is just
254-
* allocated on-stack) */
255-
DEFINE_PUBLIC_ALIAS(video_buffer_forbitmask, libvideo_buffer_forbitmask);
256-
INTERN WUNUSED ATTR_IN(3) ATTR_IN(4) REF struct video_buffer *CC
257-
libvideo_buffer_forbitmask(video_dim_t size_x, video_dim_t size_y,
258-
struct video_bitmask const *__restrict bm,
259-
video_color_t const bg_fg_colors[2]) {
260-
REF struct bitmask_buffer *result;
261-
result = (REF struct bitmask_buffer *)malloc(sizeof(struct bitmask_buffer));
262-
if likely(result) {
263-
result = bitmask_buffer_init(result, size_x, size_y, bm, bg_fg_colors);
264-
result->vb_refcnt = 1;
265-
result->vb_domain = _libvideo_ramdomain();
266-
}
267-
return result;
268-
}
269-
270238
DECL_END
271239

272240
#endif /* !GUARD_LIBVIDEO_GFX_BUFFER_BITMASK_C */
Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,20 @@ struct video_palette2 {
5656
};
5757

5858

59-
struct bitmask_buffer: video_buffer {
59+
struct old_bitmask_buffer: video_buffer {
6060
struct video_bitmask bmb_bm; /* Bitmask representing this video buffer */
6161
struct video_palette2 bmb_pal; /* Palette */
6262
};
6363

6464

65-
/* Initialize a "struct bitmask_buffer"
65+
/* Initialize a "struct old_bitmask_buffer"
6666
* @return: * : Always re-returns `self' */
67-
INTDEF ATTR_RETNONNULL ATTR_OUT(1) ATTR_IN(4) ATTR_IN(5) struct bitmask_buffer *CC
68-
bitmask_buffer_init(struct bitmask_buffer *__restrict self,
69-
video_dim_t size_x, video_dim_t size_y,
70-
struct video_bitmask const *__restrict bm,
71-
video_color_t const bg_fg_colors[2]);
72-
#define bitmask_buffer_fini(self) (void)0
73-
74-
75-
/* Create a video buffer that represents the pixel data defined by a
76-
* given `__bm' (bitmask). This function is primarily used internally
77-
* by `video_gfx_absfillmask()' and `video_gfx_absfillstretchmask()'
78-
* to deal with GFX contexts where the bitmask cannot be rendered
79-
* using the default method, but has to be rendered by being blit.
80-
*
81-
* @param: __size_x: Width of the given `__bm' (in pixels)
82-
* @param: __size_y: Height of the given `__bm' (in pixels)
83-
* @param: __bm: Bitmask whose data should be referenced interpreted
84-
* @param: __bg_fg_colors: Colors that 0/1 bits of `__bm' should map to
85-
* @return: * : The newly created video buffer
86-
* @return: NULL: [errno=ENOMEM] Insufficient memory (won't happen when
87-
* used internally, where struct is just
88-
* allocated on-stack) */
89-
INTDEF WUNUSED ATTR_IN(3) ATTR_IN(4) REF struct video_buffer *CC
90-
libvideo_buffer_forbitmask(video_dim_t size_x, video_dim_t size_y,
91-
struct video_bitmask const *__restrict bm,
92-
video_color_t const bg_fg_colors[2]);
67+
INTDEF ATTR_RETNONNULL ATTR_OUT(1) ATTR_IN(4) ATTR_IN(5) struct old_bitmask_buffer *CC
68+
old_bitmask_buffer_init(struct old_bitmask_buffer *__restrict self,
69+
video_dim_t size_x, video_dim_t size_y,
70+
struct video_bitmask const *__restrict bm,
71+
video_color_t const bg_fg_colors[2]);
72+
#define old_bitmask_buffer_fini(self) (void)0
9373

9474
DECL_END
9575

kos/src/libvideo/gfx/swgfx-hl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ gcc_opt.append("-O3"); // Force _all_ optimizations because stuff in here is per
4242
#include <libvideo/gfx/gfx.h>
4343
#include <libvideo/types.h>
4444

45-
#include "buffer/bitmask.h"
45+
#include "buffer/old-bitmask.h" /* TODO: Get rid of mask-fill operators */
4646
#include "gfx-empty.h"
4747
#include "gfx-utils.h"
4848
#include "swgfx.h"
@@ -329,11 +329,11 @@ libvideo_swgfx_fillmask_byblit(struct video_gfx const *__restrict self,
329329
video_color_t const bg_fg_colors[2],
330330
struct video_bitmask const *__restrict bm) {
331331
struct video_gfx bm_gfx, *pgfx;
332-
struct bitmask_buffer temp, *pbuf;
333-
pbuf = bitmask_buffer_init(&temp, size_x, size_y, bm, bg_fg_colors);
332+
struct old_bitmask_buffer temp, *pbuf;
333+
pbuf = old_bitmask_buffer_init(&temp, size_x, size_y, bm, bg_fg_colors);
334334
pgfx = video_buffer_getgfx(pbuf, &bm_gfx, GFX_BLENDMODE_OVERRIDE, VIDEO_GFX_F_NORMAL, 0);
335335
video_gfx_bitblit(self, dst_x, dst_y, pgfx, 0, 0, size_x, size_y);
336-
bitmask_buffer_fini(pbuf);
336+
old_bitmask_buffer_fini(pbuf);
337337
}
338338

339339

@@ -345,12 +345,12 @@ libvideo_swgfx_fillstretchmask_byblit(struct video_gfx const *__restrict self,
345345
video_dim_t src_size_x, video_dim_t src_size_y,
346346
struct video_bitmask const *__restrict bm) {
347347
struct video_gfx bm_gfx, *pgfx;
348-
struct bitmask_buffer temp, *pbuf;
349-
pbuf = bitmask_buffer_init(&temp, src_size_x, src_size_y, bm, bg_fg_colors);
348+
struct old_bitmask_buffer temp, *pbuf;
349+
pbuf = old_bitmask_buffer_init(&temp, src_size_x, src_size_y, bm, bg_fg_colors);
350350
pgfx = video_buffer_getgfx(pbuf, &bm_gfx, GFX_BLENDMODE_OVERRIDE, VIDEO_GFX_F_NORMAL, 0);
351351
video_gfx_stretch(self, dst_x, dst_y, dst_size_x, dst_size_y,
352352
pgfx, 0, 0, src_size_x, src_size_y);
353-
bitmask_buffer_fini(pbuf);
353+
old_bitmask_buffer_fini(pbuf);
354354
}
355355

356356
DECL_END

0 commit comments

Comments
 (0)