On Sonntag 07 Mai 2006 19:47, Denis Oliver Kropp wrote:
> Stefan Lucke wrote:
> > On Sonntag 07 Mai 2006 11:24, Denis Oliver Kropp wrote:
> >> Anyways, all places must be corrected. I'm still not sure what looks
> >> better, "(expr) ? true : false" or "!!(expr)", or even a macro.
> > 
> > A macro would make it a bit more clean.
> 
> But also looks more "heavy". Something very short might clash easily,
> e.g. the underscore is already taken :)
> 
> With stdbool.h you don't have to take care of that IIRC.
> 
> What about using an enum again, but not using the reserved name
> for it? What about b00l, DBool, dbool, Dbool, DirectBool or boolean?
> 

That leads to general programming styles/guides.
Why redefining standard types ?

As I'm an old fashioned C programmer, 0 evaluates to " false" and any other
value to "true". So any local or somewhere else defined type of bool(EAN)
may lead to troubles (typedef int MyBool; ).
But if space sizeof(char) vs. sizeof(int) makes a difference .. .

> > What do you think of the original intention: adding the capability
> > of doing a field based stretchblit (DSBLIT_INTERLACED) ?
> 
> That's a nice feature :)
> 
> If you have the latest patch, I can integrate it.

Ok, here is the latest one (done against DirectFB cvs from 2006-04-14).
But I'd like to have a comment from Ville, as I count him as _the_
reference of matrox programming.

-- 
Stefan Lucke
? gfxdrivers/interlaced_blit_01.diff
? gfxdrivers/interlaced_blit_02.diff
? gfxdrivers/ville_03.diff
? tools/dfbpenmount
Index: gfxdrivers/matrox/matrox.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.c,v
retrieving revision 1.95
diff -U3 -r1.95 matrox.c
--- gfxdrivers/matrox/matrox.c	8 Dec 2005 20:33:04 -0000	1.95
+++ gfxdrivers/matrox/matrox.c	7 May 2006 19:22:46 -0000
@@ -165,6 +165,7 @@
                                              DSBLIT_BLEND_COLORALPHA | \
                                              DSBLIT_COLORIZE | \
                                              DSBLIT_DEINTERLACE | \
+                                             DSBLIT_INTERLACED  | \
                                              DSBLIT_SRC_PREMULTIPLY | \
                                              DSBLIT_SRC_PREMULTCOLOR)
 
@@ -183,6 +184,7 @@
                                 DSBLIT_BLEND_COLORALPHA   |              \
                                 DSBLIT_COLORIZE           |              \
                                 DSBLIT_DEINTERLACE        |              \
+                                DSBLIT_INTERLACED         |              \
                                 DSBLIT_SRC_PREMULTIPLY    |              \
                                 DSBLIT_SRC_PREMULTCOLOR)       ||        \
       ((state)->destination->format != (state)->source->format &&        \
@@ -444,7 +446,7 @@
           case DSPF_YUY2:
                if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
                    (accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
-                    !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+                    !(state->blittingflags & ~(DSBLIT_DEINTERLACE | DSBLIT_INTERLACED)) &&
                     state->source->format == state->destination->format))
                     break;
                return;
@@ -545,7 +547,7 @@
           case DSPF_YV12:
                if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
                    (accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
-                    !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+                    !(state->blittingflags & ~(DSBLIT_DEINTERLACE | DSBLIT_INTERLACED)) &&
                     (state->source->format == DSPF_I420 || state->source->format == DSPF_YV12)))
                     break;
                return;
@@ -555,7 +557,7 @@
           case DSPF_UYVY:
                if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
                    (accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
-                    !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+                    !(state->blittingflags & ~(DSBLIT_DEINTERLACE| DSBLIT_INTERLACED)) &&
                     state->source->format == state->destination->format))
                     break;
                return;
@@ -736,6 +738,7 @@
 
                mdev->blit_src_colorkey = flags & DSBLIT_SRC_COLORKEY;
                mdev->blit_deinterlace  = flags & DSBLIT_DEINTERLACE;
+               mdev->blit_interlaced   = (flags & DSBLIT_INTERLACED) != 0;
 
                if (MATROX_USE_TMU( state, accel )) {
                     if (flags & (DSBLIT_BLEND_COLORALPHA |
@@ -1438,6 +1441,70 @@
 }
 
 static inline void
+matroxBlitTMU_interlaced( MatroxDriverData *mdrv,
+                          MatroxDeviceData *mdev,
+                          DFBRectangle *srect,
+                          DFBRectangle *drect,
+                          bool filter )
+{
+     volatile __u8 *mmio = mdrv->mmio_base;
+     __u32          texctl;
+
+     texctl  = mdev->texctl & ~TPITCHEXT;
+     texctl |= ((mdev->src_pitch*2) << 9) & TPITCHEXT;
+
+     /* field 0 */
+     mga_waitfifo( mdrv, mdev, 5 );
+     mga_out32( mmio, texctl, TEXCTL );
+     mga_out32( mmio, ( (((__u32)(mdev->h/2 - 1) & 0x7ff) << 18) |
+                        (((__u32)(4 - (mdev->h2 - 1)) & 0x3f) <<  9) |
+                        (((__u32)((mdev->h2 - 1) + 4) & 0x3f)      )  ), TEXHEIGHT );
+
+     mga_out32( mmio, mdev->src_offset[0], TEXORG );
+     mga_out32( mmio, mdev->dst_pitch*2, PITCH );
+     mga_out32( mmio, mdev->dst_offset[0], DSTORG );
+
+     matroxDoBlitTMU( mdrv, mdev,
+                      srect->x, srect->y / 2,
+                      drect->x, drect->y / 2,
+                      srect->w, srect->h / 2,
+                      drect->w, drect->h / 2,
+                      mdev->w2, mdev->h2 - 1,
+                      filter );
+     
+     texctl  = mdev->texctl & ~TPITCHEXT;
+     texctl |= ((mdev->src_pitch*2) << 9) & TPITCHEXT;
+
+     /* field 1 */
+     mga_waitfifo( mdrv, mdev, 2 );
+     mga_out32( mmio, mdev->src_offset[0]+mdev->src_stride, TEXORG );
+     mga_out32( mmio, mdev->dst_offset[0]+mdev->dst_stride, DSTORG );
+
+     matroxDoBlitTMU( mdrv, mdev,
+                      srect->x, srect->y / 2,
+                      drect->x, drect->y / 2,
+                      srect->w, srect->h / 2,
+                      drect->w, drect->h / 2,
+                      mdev->w2, mdev->h2 - 1,
+                      filter );
+
+     /* Restore registers */
+     mga_waitfifo( mdrv, mdev, 6 );
+     mga_out32( mmio, mdev->texctl, TEXCTL );
+     mga_out32( mmio, ( (((__u32)(mdev->w - 1) & 0x7ff) << 18) |
+                        (((__u32)(4 - mdev->w2) & 0x3f) <<  9) |
+                        (((__u32)(mdev->w2 + 4) & 0x3f)      )  ), TEXWIDTH );
+     mga_out32( mmio, ( (((__u32)(mdev->h - 1) & 0x7ff) << 18) |
+                        (((__u32)(4 - mdev->h2) & 0x3f) <<  9) |
+                        (((__u32)(mdev->h2 + 4) & 0x3f)      )  ), TEXHEIGHT );
+     mga_out32( mmio, mdev->src_offset[0], TEXORG );
+
+     mga_out32( mmio, mdev->dst_pitch, PITCH );
+     mga_out32( mmio, mdev->dst_offset[0], DSTORG );
+
+}
+
+static inline void
 matroxBlitTMU_2P( MatroxDriverData *mdrv,
                   MatroxDeviceData *mdev,
                   DFBRectangle *srect,
@@ -1607,8 +1674,10 @@
      MatroxDriverData *mdrv = (MatroxDriverData*) drv;
      MatroxDeviceData *mdev = (MatroxDeviceData*) dev;
 
-     matroxBlitTMU( mdrv, mdev, srect, drect, true );
-
+     if (mdev->blit_interlaced && !mdev->blit_deinterlace)
+     	matroxBlitTMU_interlaced( mdrv, mdev, srect, drect, true );
+     else 
+     	matroxBlitTMU( mdrv, mdev, srect, drect, true );
      return true;
 }
 
Index: gfxdrivers/matrox/matrox.h
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.h,v
retrieving revision 1.39
diff -U3 -r1.39 matrox.h
--- gfxdrivers/matrox/matrox.h	8 Dec 2005 20:13:27 -0000	1.39
+++ gfxdrivers/matrox/matrox.h	7 May 2006 19:22:46 -0000
@@ -89,8 +89,10 @@
 
      /* Stored values */
      int dst_pitch;
+     int dst_stride;
      int dst_offset[3];
      int src_pitch;
+     int src_stride;
      int src_offset[3];
      int w, h, w2, h2;
      __u32 color[3];
@@ -99,6 +101,7 @@
      bool blit_src_colorkey;
 
      bool blit_deinterlace;
+     bool blit_interlaced;
      int field;
 
      bool depth_buffer;
Index: gfxdrivers/matrox/matrox_state.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_state.c,v
retrieving revision 1.59
diff -U3 -r1.59 matrox_state.c
--- gfxdrivers/matrox/matrox_state.c	8 Dec 2005 20:33:04 -0000	1.59
+++ gfxdrivers/matrox/matrox_state.c	7 May 2006 19:22:51 -0000
@@ -58,7 +58,8 @@
      SurfaceBuffer *depth_buffer    = destination->depth_buffer;
      int            bytes_per_pixel = DFB_BYTES_PER_PIXEL(buffer->format);
 
-     mdev->dst_pitch = buffer->video.pitch / bytes_per_pixel;
+     mdev->dst_pitch  = buffer->video.pitch / bytes_per_pixel;
+     mdev->dst_stride = buffer->video.pitch;
 
      D_ASSERT( mdev->dst_pitch % 32 == 0 );
 
@@ -510,8 +511,9 @@
      if (MGA_IS_VALID( m_Source ))
           return;
 
-     mdev->src_pitch = buffer->video.pitch / bytes_per_pixel;
-     mdev->field     = surface->field;
+     mdev->src_pitch  = buffer->video.pitch / bytes_per_pixel;
+     mdev->src_stride = buffer->video.pitch;
+     mdev->field      = surface->field;
 
      D_ASSERT( mdev->src_pitch % 32 == 0 );
 
Index: include/directfb.h
===================================================================
RCS file: /cvs/directfb/DirectFB/include/directfb.h,v
retrieving revision 1.285
diff -U3 -r1.285 directfb.h
--- include/directfb.h	6 Apr 2006 12:00:34 -0000	1.285
+++ include/directfb.h	7 May 2006 19:23:02 -0000
@@ -666,8 +666,10 @@
                                                 only one field (every second line of full
                                                 image) scaling it vertically by factor two */
      DSBLIT_SRC_PREMULTCOLOR   = 0x00000200, /* modulates the source color with the color alpha */
-     DSBLIT_XOR                = 0x00000400  /* bitwise xor the destination pixels with the
+     DSBLIT_XOR                = 0x00000400, /* bitwise xor the destination pixels with the
                                                 source pixels after premultiplication */
+     DSBLIT_INTERLACED         = 0x00000800  /* strechblit fields separate when surface
+						is allocated DSCAPS_INTERLACED */
 } DFBSurfaceBlittingFlags;
 
 /*
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to