4444
4545#include "../buffer.h"
4646#include "../ramdomain.h"
47- #include "old-gfx.h"
4847#include "lockable.h"
49- #include "old-ram .h"
48+ #include "region .h"
5049
5150DECL_BEGIN
5251
@@ -56,24 +55,19 @@ DECL_BEGIN
5655#define DBG_memset (p , c , n ) (void)0
5756#endif /* NDEBUG || NDEBUG_FINI */
5857
59- #undef LOCKABLE_BUFFER_PALREF
60- #if 0
61- #define LOCKABLE_BUFFER_PALREF
62- #endif
63-
6458/* Indices into `struct video_lock::_vl_driver' */
6559#define LOCKABLE_BUFFER_VLOCK_ISWRITE 0
6660static_assert (_VIDEO_LOCK__N_DRIVER >= 1 );
6761
6862/* Initialize a mock ram-buffer using the video lock of "self" */
6963PRIVATE ATTR_OUT (1 ) ATTR_IN (2 ) void FCC
70- lockable_asram (struct old_video_rambuffer * __restrict rb ,
64+ lockable_asram (struct video_rambuffer_base * __restrict rb ,
7165 struct lockable_buffer const * __restrict self ) {
72- rb -> vb_ops = _old_rambuffer_ops ( );
73- rb -> vb_format . vf_codec = self -> vb_format . vf_codec ;
74- rb -> vb_format . vf_pal = self -> vb_format . vf_pal ;
75- rb -> vb_xdim = self -> vb_xdim ;
76- rb -> vb_ydim = self -> vb_ydim ;
66+ DBG_memset ( & rb -> vb_domain , 0xcc , sizeof ( rb -> vb_domain ) );
67+ rb -> vb_ops = _rambuffer_ops () ;
68+ rb -> vb_format = self -> vb_format ;
69+ rb -> vb_xdim = self -> vb_xdim ;
70+ rb -> vb_ydim = self -> vb_ydim ;
7771#ifndef NDEBUG
7872 rb -> vb_refcnt = 0 ; /* So someone incref'ing will fault */
7973#endif /* !NDEBUG */
@@ -86,7 +80,7 @@ PRIVATE NONNULL((1)) void FCC
8680lockable_readpixels (struct lockable_buffer const * __restrict self ) {
8781 struct video_gfx srcgfx , * p_srcgfx ;
8882 struct video_gfx dstgfx , * p_dstgfx ;
89- struct old_video_rambuffer dst ;
83+ struct video_rambuffer_base dst ;
9084 lockable_asram (& dst , self );
9185 p_srcgfx = video_buffer_getgfx (self -> lb_base , & srcgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
9286 p_dstgfx = video_buffer_getgfx (& dst , & dstgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
@@ -103,7 +97,7 @@ PRIVATE NONNULL((1)) void FCC
10397lockable_writepixels (struct lockable_buffer const * __restrict self ) {
10498 struct video_gfx srcgfx , * p_srcgfx ;
10599 struct video_gfx dstgfx , * p_dstgfx ;
106- struct old_video_rambuffer src ;
100+ struct video_rambuffer_base src ;
107101 lockable_asram (& src , self );
108102 p_srcgfx = video_buffer_getgfx (& src , & srcgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
109103 p_dstgfx = video_buffer_getgfx (self -> lb_base , & dstgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
@@ -121,7 +115,7 @@ lockable_readpixels_region(struct lockable_buffer const *__restrict self,
121115 struct video_regionlock const * __restrict region ) {
122116 struct video_gfx srcgfx , * p_srcgfx ;
123117 struct video_gfx dstgfx , * p_dstgfx ;
124- struct old_video_rambuffer dst ;
118+ struct video_rambuffer_base dst ;
125119 lockable_asram (& dst , self );
126120 p_srcgfx = video_buffer_getgfx (self -> lb_base , & srcgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
127121 p_dstgfx = video_buffer_getgfx (& dst , & dstgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
@@ -139,7 +133,7 @@ lockable_writepixels_region(struct lockable_buffer const *__restrict self,
139133 struct video_regionlock const * __restrict region ) {
140134 struct video_gfx srcgfx , * p_srcgfx ;
141135 struct video_gfx dstgfx , * p_dstgfx ;
142- struct old_video_rambuffer src ;
136+ struct video_rambuffer_base src ;
143137 lockable_asram (& src , self );
144138 p_srcgfx = video_buffer_getgfx (& src , & srcgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
145139 p_dstgfx = video_buffer_getgfx (self -> lb_base , & dstgfx , GFX_BLENDMODE_OVERRIDE , VIDEO_GFX_F_NORMAL , 0 );
@@ -155,10 +149,8 @@ lockable_writepixels_region(struct lockable_buffer const *__restrict self,
155149PRIVATE NONNULL ((1 )) void FCC
156150lockable_destroy (struct video_buffer * __restrict self ) {
157151 struct lockable_buffer * me = (struct lockable_buffer * )self ;
158- #ifdef LOCKABLE_BUFFER_PALREF
159152 if (me -> vb_format .vf_pal )
160153 video_palette_decref (me -> vb_format .vf_pal );
161- #endif /* LOCKABLE_BUFFER_PALREF */
162154 video_buffer_decref (me -> lb_base );
163155 free (me -> lb_data );
164156 free (me );
@@ -352,19 +344,28 @@ PRIVATE ATTR_PURE WUNUSED ATTR_IN(1) bool CC
352344video_buffer_islockable (struct video_buffer const * __restrict self ) {
353345 if (self -> vb_ops == & lockable_ops )
354346 goto yes ;
355- if (self -> vb_ops == & old_rambuffer_ops )
347+ if (self -> vb_ops == & rambuffer_ops )
348+ goto yes ;
349+ if (self -> vb_ops == & rambuffer_xcodec_ops )
350+ goto yes ;
351+ if (self -> vb_ops == & rambuffer_subregion_ops )
352+ goto yes ;
353+ if (self -> vb_ops == & rambuffer_subsubregion_ops )
356354 goto yes ;
357- if (self -> vb_ops == & old_rambuffer_ops__for_codec )
355+ if (self -> vb_ops == & rambuffer_formem_ops )
358356 goto yes ;
359- if (self -> vb_ops == & old_membuffer_ops )
357+ if (self -> vb_ops == & rambuffer_formem_xcodec_ops )
360358 goto yes ;
361- if (self -> vb_ops == & old_membuffer_ops__for_codec )
359+ if (self -> vb_ops == & rambuffer_formem_subregion_ops )
362360 goto yes ;
363- if (self -> vb_ops == & old_subregion_buffer_ops_norem ) {
364- /* Subregion buffers are locked iff the underlying buffer is */
365- struct old_subregion_buffer const * me ;
366- me = (struct old_subregion_buffer const * )self ;
367- return video_buffer_islockable (me -> srb_base );
361+ if (self -> vb_ops == & region_buffer_subregion_alias_ops ) {
362+ /* Region alias buffers are locked iff the underlying buffer is.
363+ * Note that other region buffers are never lockable, since they
364+ * always contain at least 1 pixel that is out-of-bounds of some
365+ * base buffer (meaning not **all** pixels are lockable) */
366+ struct region_buffer_subregion_alias const * me ;
367+ me = (struct region_buffer_subregion_alias const * )self ;
368+ return video_buffer_islockable (me -> rbf_base );
368369 }
369370 return false;
370371yes :
@@ -379,7 +380,6 @@ video_buffer_islockable(struct video_buffer const *__restrict self) {
379380INTERN WUNUSED ATTR_OUT (1 ) NONNULL ((2 )) struct video_buffer * CC
380381libvideo_buffer_lockable_init (struct lockable_buffer * self ,
381382 struct video_buffer * __restrict buffer ) {
382- self -> lb_data = NULL ;
383383 if (video_buffer_islockable (buffer ))
384384 return buffer ;
385385 self -> vb_ops = _lockable_ops ();
@@ -389,8 +389,9 @@ libvideo_buffer_lockable_init(struct lockable_buffer *self,
389389#ifndef NDEBUG
390390 self -> vb_refcnt = 0 ;
391391#endif /* !NDEBUG */
392- self -> lb_base = buffer ;
393- self -> lb_data = NULL ;
392+ self -> lb_base = buffer ;
393+ self -> lb_data = NULL ;
394+ self -> lb_edata = NULL ;
394395 DBG_memset (& self -> lb_stride , 0xcc , sizeof (self -> lb_stride ));
395396 return self ;
396397}
@@ -439,15 +440,14 @@ libvideo_buffer_lockable(struct video_buffer *__restrict self) {
439440 result -> vb_format = self -> vb_format ;
440441 result -> vb_xdim = self -> vb_xdim ;
441442 result -> vb_ydim = self -> vb_ydim ;
442- result -> vb_domain = video_buffer_domain_for_wrapper ( self );
443+ result -> vb_domain = _libvideo_ramdomain ( );
443444 result -> vb_refcnt = 1 ;
444445 video_buffer_incref (self );
445- result -> lb_base = self ;
446- result -> lb_data = NULL ;
447- #ifdef LOCKABLE_BUFFER_PALREF
446+ result -> lb_base = self ;
447+ result -> lb_data = NULL ;
448+ result -> lb_edata = NULL ;
448449 if (result -> vb_format .vf_pal )
449450 video_palette_incref (result -> vb_format .vf_pal );
450- #endif /* LOCKABLE_BUFFER_PALREF */
451451 DBG_memset (& result -> lb_stride , 0xcc , sizeof (result -> lb_stride ));
452452 return result ;
453453err :
0 commit comments