To reply to my own email, here is a patch for the first item on my
todo list:
> 1. I need to know which field is currently being displayed on the
> DisplayLayer so that I don't draw to it (and tear). I think this
> should go as part of IDirectFBDisplayLayer. I will add it using
> SetOpacity as my example. I don't think it makes sense as part of
> IDirectFBSurface since for a non-output surface, it could be, say,
> displaying its even field but being blit into the odd field of the
> output. I think it would be confusing.
I put the call as part of IDirectFBDisplayLayer since I heard no other
suggestions from this list. ;-) More patches to follow until you stop
me, I guess...
--
Billy Biggs
[EMAIL PROTECTED]
Index: gfxdrivers/matrox/matrox_crtc2.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_crtc2.c,v
retrieving revision 1.1
diff -p -u -p -u -r1.1 matrox_crtc2.c
--- gfxdrivers/matrox/matrox_crtc2.c 5 Sep 2002 11:36:23 -0000 1.1
+++ gfxdrivers/matrox/matrox_crtc2.c 26 Sep 2002 00:33:19 -0000
@@ -364,6 +364,23 @@ crtc2SetOpacity( DisplayLayer *layer,
return DFB_OK;
}
+static DFBResult
+crtc2GetCurrentOutputField( DisplayLayer *layer,
+ void *driver_data,
+ void *layer_data,
+ int *field )
+{
+ MatroxDriverData *mdrv = (MatroxDriverData*) driver_data;
+ int mga_field = ( mga_in32( mdrv->mmio_base, C2VCOUNT ) >> 24 ) & 1;
+
+ if( field ) {
+ *field = mga_field;
+ return DFB_OK;
+ } else {
+ return DFB_INVARG;
+ }
+}
+
DisplayLayerFuncs matroxCrtc2Funcs = {
LayerDataSize: crtc2LayerDataSize,
InitLayer: crtc2InitLayer,
@@ -373,7 +390,8 @@ DisplayLayerFuncs matroxCrtc2Funcs = {
SetConfiguration: crtc2SetConfiguration,
FlipBuffers: crtc2FlipBuffers,
SetColorAdjustment: crtc2SetColorAdjustment,
- SetOpacity: crtc2SetOpacity
+ SetOpacity: crtc2SetOpacity,
+ GetCurrentOutputField: crtc2GetCurrentOutputField
};
/* internal */
Index: include/directfb.h
===================================================================
RCS file: /cvs/directfb/DirectFB/include/directfb.h,v
retrieving revision 1.149
diff -p -u -p -u -r1.149 directfb.h
--- include/directfb.h 10 Sep 2002 21:42:04 -0000 1.149
+++ include/directfb.h 26 Sep 2002 00:33:20 -0000
@@ -1470,6 +1470,23 @@ DEFINE_INTERFACE( IDirectFBDisplayLaye
int level
);
+ /*
+ * For an interlaced display, this Returns the currently inactive
+ * field: 0 for an even field (the even scanlines starting at 0),
+ * and 1 for an odd field (the odd scanlines starting at 1).
+ *
+ * The inactive field is the one you should draw to next to avoid
+ * tearing, the active field is the one currently being displayed.
+ *
+ * For a progressive output, this should always return 0. We should
+ * also have some other call to indicate whether the display layer
+ * is interlaced or progressive, but this is a start.
+ */
+ DFBResult (*GetCurrentOutputField) (
+ IDirectFBDisplayLayer *thiz,
+ int *field
+ );
+
/** Configuration handling **/
Index: src/core/layers.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/layers.c,v
retrieving revision 1.67
diff -p -u -p -u -r1.67 layers.c
--- src/core/layers.c 11 Sep 2002 10:47:07 -0000 1.67
+++ src/core/layers.c 26 Sep 2002 00:33:20 -0000
@@ -1084,6 +1084,22 @@ dfb_layer_set_opacity (DisplayLayer *lay
return DFB_OK;
}
+DFBResult dfb_layer_get_current_output_field( DisplayLayer *layer, int *field )
+{
+ DFBResult ret;
+ DisplayLayerShared *shared = layer->shared;
+
+ if (!layer->funcs->GetCurrentOutputField)
+ return DFB_UNSUPPORTED;
+
+ ret = layer->funcs->GetCurrentOutputField( layer, layer->driver_data,
+ layer->layer_data, field );
+ if (ret)
+ return ret;
+
+ return DFB_OK;
+}
+
DFBResult
dfb_layer_set_coloradjustment (DisplayLayer *layer,
DFBColorAdjustment *adj)
Index: src/core/layers.h
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/layers.h,v
retrieving revision 1.38
diff -p -u -p -u -r1.38 layers.h
--- src/core/layers.h 11 Sep 2002 10:47:07 -0000 1.38
+++ src/core/layers.h 26 Sep 2002 00:33:20 -0000
@@ -83,6 +83,11 @@ typedef struct {
void *driver_data,
void *layer_data,
__u8 opacity );
+
+ DFBResult (*GetCurrentOutputField) ( DisplayLayer *layer,
+ void *driver_data,
+ void *layer_data,
+ int *field );
DFBResult (*SetScreenLocation) ( DisplayLayer *layer,
void *driver_data,
@@ -308,6 +313,8 @@ DFBResult dfb_layer_set_screenlocation(
float width, float height );
DFBResult dfb_layer_set_opacity (DisplayLayer *layer, __u8 opacity);
+
+DFBResult dfb_layer_get_current_output_field( DisplayLayer *layer, int *field );
DFBResult dfb_layer_set_coloradjustment (DisplayLayer *layer,
DFBColorAdjustment *adj);
Index: src/display/idirectfbdisplaylayer.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/display/idirectfbdisplaylayer.c,v
retrieving revision 1.40
diff -p -u -p -u -r1.40 idirectfbdisplaylayer.c
--- src/display/idirectfbdisplaylayer.c 10 Sep 2002 16:35:54 -0000 1.40
+++ src/display/idirectfbdisplaylayer.c 26 Sep 2002 00:33:20 -0000
@@ -218,6 +218,14 @@ IDirectFBDisplayLayer_SetOpacity( IDirec
}
static DFBResult
+IDirectFBDisplayLayer_GetCurrentOutputField( IDirectFBDisplayLayer *thiz, int *field )
+{
+ INTERFACE_GET_DATA(IDirectFBDisplayLayer)
+
+ return dfb_layer_get_current_output_field( data->layer, field );
+}
+
+static DFBResult
IDirectFBDisplayLayer_SetScreenLocation( IDirectFBDisplayLayer *thiz,
float x,
float y,
@@ -591,6 +599,7 @@ IDirectFBDisplayLayer_Construct( IDirect
thiz->GetSurface = IDirectFBDisplayLayer_GetSurface;
thiz->SetCooperativeLevel = IDirectFBDisplayLayer_SetCooperativeLevel;
thiz->SetOpacity = IDirectFBDisplayLayer_SetOpacity;
+ thiz->GetCurrentOutputField = IDirectFBDisplayLayer_GetCurrentOutputField;
thiz->SetScreenLocation = IDirectFBDisplayLayer_SetScreenLocation;
thiz->SetSrcColorKey = IDirectFBDisplayLayer_SetSrcColorKey;
thiz->SetDstColorKey = IDirectFBDisplayLayer_SetDstColorKey;