4848#include "../gfx.h"
4949#include "../ramdomain.h"
5050#include "../swgfx.h"
51- #include "bitmask.h"
51+ #include "old- bitmask.h"
5252
5353DECL_BEGIN
5454
@@ -70,10 +70,10 @@ bitmask_destroy(struct video_buffer *__restrict self) {
7070PRIVATE ATTR_INOUT (1 ) ATTR_OUT (2 ) int FCC
7171bitmask_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,
8686PRIVATE ATTR_INOUT (1 ) NONNULL ((2 )) int FCC
8787bitmask_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,
103103PRIVATE ATTR_IN (1 ) video_pixel_t CC
104104bitmask_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
113113bitmask_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-
270238DECL_END
271239
272240#endif /* !GUARD_LIBVIDEO_GFX_BUFFER_BITMASK_C */
0 commit comments