#ifndef __DFB_UTIL_H__
#define __DFB_UTIL_H__

#include <directfb.h>
#include "dfb_util_common.h"


class DFBFont;

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      Common Interface
// -------------------------------

class IFSurfaceCommon
{
public:

/*
Retrieving information	 
GetCapabilities         Return the capabilities of this surface.
GetPosition	            Get the surface's position in pixels.
GetSize	                Get the surface's width and height in pixels.
GetVisibleRectangle	    Created sub surfaces might be clipped by their parents, this function returns the resulting rectangle relative to this surface.
GetPixelFormat	        Get the current pixel format.
GetAccelerationMask	    Get a mask of drawing functions that are hardware accelerated with the current settings.

Palette & Alpha Ramp	 
GetPalette	            Get access to the surface's palette.
SetPalette	            Change the surface's palette.
SetAlphaRamp	        Set the alpha ramp for formats with one or two alpha bits.

Buffer operations	 
Lock	                Lock the surface for the access type specified.
GetFramebufferOffset	Obsolete. Returns DFB_FAILURE always.
Unlock	                Unlock the surface after direct access.
Flip	                Flip/Update surface buffers.
SetField	            Set the active field.
Clear	                Clear the surface and its depth buffer if existent.

Drawing/blitting control	 
SetClip	                Set the clipping region used to limit the area for drawing, blitting and text functions.
GetClip	                Get the clipping region used to limit the area for drawing, blitting and text functions.
[done] SetColor	            Set the color used for drawing/text functions or alpha/color modulation (blitting functions).
[done] SetColorIndex	        Set the color like with SetColor() but using an index to the color/alpha lookup table.
[done] SetSrcBlendFunction	    Set the blend function that applies to the source.
[done] SetDstBlendFunction	    Set the blend function that applies to the destination.
SetPorterDuff	        Set the source and destination blend function by specifying a Porter/Duff rule.
SetSrcColorKey	        Set the source color key, i.e. the color that is excluded when blitting FROM this surface TO another that has source color keying enabled.
SetSrcColorKeyIndex	    Set the source color key like with SetSrcColorKey() but using an index to the color/alpha lookup table.
SetDstColorKey	        Set the destination color key, i.e. the only color that gets overwritten by drawing and blitting to this surface when destination color keying is enabled.
SetDstColorKeyIndex	    Set the destination color key like with SetDstColorKey() but using an index to the color/alpha lookup table.

Blitting functions	 
SetBlittingFlags	    Set the flags for all subsequent blitting commands.
Blit	                Blit an area from the source to this surface.
TileBlit	            Blit an area from the source tiled to this surface.
BatchBlit	            Blit a bunch of areas at once.
StretchBlit	            Blit an area scaled from the source to the destination rectangle.
TextureTriangles	    Preliminary texture mapping support.

Drawing functions	 
SetDrawingFlags	        Set the flags for all subsequent drawing commands.
FillRectangle	        Fill the specified rectangle with the given color following the specified flags.
DrawRectangle	        Draw an outline of the specified rectangle with the given color following the specified flags.
DrawLine	            Draw a line from one point to the other with the given color following the drawing flags.
DrawLines	            Draw 'num_lines' lines with the given color following the drawing flags. Each line specified by a DFBRegion.
FillTriangle	        Fill a non-textured triangle.
FillRectangles	        Fill a bunch of rectangles with a single call.
FillSpans	            Fill spans specified by x and width.
FillTriangles	        Fill a bunch of triangles with a single call.

Text functions	 
SetFont	                Set the font used by DrawString() and DrawGlyph(). You can pass NULL here to unset the font.
GetFont	                Get the font associated with a surface.
DrawString	            Draw a string at the specified position with the given color following the specified flags.
DrawGlyph	            Draw a single glyph specified by its character code at the specified position with the given color following the specified flags.
SetEncoding	            Change the encoding used for text rendering.

Lightweight helpers	 
GetSubSurface	        Get an interface to a sub area of this surface.

OpenGL	 
GetGL	                Get a unique OpenGL context for this surface.

Debug	 
Dump	                Dump the contents of the surface to one or two files.
DisableAcceleration	    Disable hardware acceleration.

Resources	 
ReleaseSource	        Release possible reference to source surface.

Blitting control	 
SetIndexTranslation	    Set index translation table.

Rendering	 
SetRenderOptions	    Set options affecting the output of drawing and blitting operations.

Drawing/blitting control	 
SetMatrix	            Set the transformation matrix.
SetSourceMask	        Set the surface to be used as a mask for blitting.

Lightweight helpers	 
MakeSubSurface	        Make this a sub surface or adjust the rectangle of this sub surface.

Direct Write/Read	 
Write	                Write to the surface without the need for (Un)Lock.
Read	                Read from the surface without the need for (Un)Lock.

Drawing/blitting control	 
SetColors	            Sets color values used for drawing/text functions or alpha/color modulation (blitting functions).

Blitting functions	 
BatchBlit2	            Blit a bunch of areas at once using secondary source for reading instead of destination.

Buffer operations	 
GetPhysicalAddress	    Returns the physical address of a locked surface.

Drawing functions	 
FillTrapezoids	        Fill a bunch of trapezoids with a single call.
*/
    virtual ~IFSurfaceCommon () {}

    virtual IDirectFBSurface * GetSurface () = 0;


    void Clear (unsigned char r, unsigned char g, unsigned char b, unsigned char a);

    void Blit (IFSurfaceCommon & source, DFBRectangle * source_rect, int x, int y);

    void Blit (IDirectFBSurface * source, DFBRectangle * source_rect, int x, int y);

    void StretchBlit (IFSurfaceCommon & source, DFBRectangle * source_rect, DFBRectangle * destination_rect);

    void StretchBlit (IDirectFBSurface * source, DFBRectangle * source_rect, DFBRectangle * destination_rect);


    void Flip (const DFBRegion * region, DFBSurfaceFlipFlags flags);

    void SetColor (unsigned char r, unsigned char g, unsigned char b, unsigned char a);

    //  Set the color like with SetColor() but using an index to the color/alpha lookup table.
    void SetColorIndex(unsigned int index);
    //  Set the source and destination blend function by specifying a Porter/Duff rule.
    void SetPorterDuff(DFBSurfacePorterDuffRule rule);
    void FillRectangle (int x, int y, int w, int h);

    void FillRectangles (DFBRectangle * rects, unsigned int num);

    void DrawRectangle (int x, int y, int w, int h);

    void DrawString (const char * text, int bytes, int x, int y, DFBSurfaceTextFlags flags);

    void DrawGlyph (unsigned int character, int x, int y, DFBSurfaceTextFlags flags);


    void SetBlittingFlags (DFBSurfaceBlittingFlags flags);

    void SetSrcBlendFunction (DFBSurfaceBlendFunction function);

    void SetDstBlendFunction (DFBSurfaceBlendFunction function);

    void SetFont (DFBFont& font);

    void SetAlphaCmpMode (DFB_ACmpOp cmpmode);

    void SetBlitNearestMode (bool enable);

    void SetBlitMirror (bool xmirror_enable, bool ymirror_enable);

    void SetRenderOptions (DFBSurfaceRenderOptions	options);


	/** Retrieving information **/

	/*
	* Return the capabilities of this surface.
	*/
	void GetCapabilities (DFBSurfaceCapabilities   *ret_caps	);

	/*
	* Get the surface's position in pixels.
	*/
	void  GetPosition (int *ret_x, int *ret_y);

	/*
	* Get the surface's width and height in pixels.
	*/
	void GetSize (int *ret_width, int *ret_height);

	/*
	* Created sub surfaces might be clipped by their parents,
	* this function returns the resulting rectangle relative
	* to this surface.
	*
	* For non sub surfaces this function returns
	* { 0, 0, width, height }.
	*/
	void GetVisibleRectangle (DFBRectangle *ret_rect);


	/*
	* Get a mask of drawing functions that are hardware
	* accelerated with the current settings.
	*
	* If a source surface is specified the mask will also
	* contain accelerated blitting functions.  Note that there
	* is no guarantee that these will actually be accelerated
	* since the surface storage (video/system) is examined only
	* when something actually gets drawn or blitted.
	*/
	void  GetAccelerationMask (IDirectFBSurface *source, DFBAccelerationMask *ret_mask);


	/** Palette & Alpha Ramp **/

	/*
	* Get access to the surface's palette.
	*
	* Returns an interface that can be used to gain
	* read and/or write access to the surface's palette.
	*/
	void GetPalette (IDirectFBPalette **ret_interface);

	/*
	* Change the surface's palette.
	*/
	void SetPalette (IDirectFBPalette *palette);
		
	/*
	* Set the alpha ramp for formats with one or two alpha bits.
	*
	* Either all four values or the first and the
	* last one are used, depending on the format.
	* Default values are: 0x00, 0x55, 0xaa, 0xff.
	*/
	void SetAlphaRamp (u8 a0, u8 a1, u8 a2, u8 a3);
		
		

};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFB
// -------------------------------

class DFBEnvBase
{
public:

    ~DFBEnvBase ();

    static IDirectFB * GetDFB ();

    static void GetDeviceDescription (DFBGraphicsDeviceDescription * ret_desc);

private:
    DFBEnvBase();

private:
    IDirectFB *m_dfb;
};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBDisplayLayer
// -------------------------------
class DFBLayerPrivate;

class DFBLayer : public IFSurfaceCommon
{
    FORBIDDEN_COPY(DFBLayer);

    DECL_PRIVATE(DFBLayer);

public:

    enum
    {
        BUF_MOD_SINGLE = 0,
        BUF_MOD_DOUBLE,
        BUF_MOD_TRIPLE
    };

public:

    explicit DFBLayer (unsigned int id);

    ~DFBLayer();

    IDirectFBDisplayLayer * GetInstance () const;

    IDirectFBSurface * GetSurface ();

    void SetSize (unsigned int width, unsigned int height);

    void SetBufferMode (int mode);

    void RestoreConfig ();

    void SetAutoRestoreConfig (bool en);

    void SetLevel (int level);

    void GetConfiguration (DFBDisplayLayerConfig * ret_config);

    void SetCooperativeLevel (DFBDisplayLayerCooperativeLevel level);

    void SetConfiguration (const DFBDisplayLayerConfig * config);

    void EnableCursor(int enable);


    /*
    * Get the unique layer ID.
    */
    void GetID (DFBDisplayLayerID *ret_layer_id);

    /*
    * Get a description of this display layer, i.e. the capabilities.
    */
    void GetDescription (DFBDisplayLayerDescription *ret_desc);

    /*
    * Get a description of available sources.
    *
    * All descriptions are written to the array pointed to by
    * <b>ret_descriptions</b>. The number of sources is returned by
    * IDirectFBDisplayLayer::GetDescription().
    */
    void GetSourceDescriptions (DFBDisplayLayerSourceDescription *ret_descriptions);
        
    /*
    * For an interlaced display, this returns the currently inactive
    * field: 0 for the top field, and 1 for the bottom field.
    *
    * 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.
    */
    void GetCurrentOutputField (int *ret_field);


    // API enable force  update window stack to foce hw flip
    void ForceFullUpdateWindowStack (bool enable);

    // API to bind the Shadowlayer
    void BindShadowLayer (IDirectFBDisplayLayer *other);

    // API to unbind Shadowlayer
    void UnbindShadowLayer (IDirectFBDisplayLayer *other);

    // API  dynamic enable GOP Mirro mode
    void SetHVMirrorEnable (bool HEnable, bool VEnable);

    // API enable GOP LBCouple mode
    void SetLBCoupleEnable (bool LBCoupleEnable);

    // API enable GOP Dst ByPass mode
    void SetGOPDstByPassEnable (bool ByPassEnable);

    // API dynamic set GOP scale 
    void SetHVScale (int HScale, int VScale);


    /*
    * Get an interface to the screen to which the layer belongs.
    */
    void GetScreen (IDirectFBScreen **ret_interface);


    /*
    * Set location on screen as normalized values.
    *
    * So the whole screen is 0.0, 0.0, 1.0, 1.0.
    */
    void SetScreenLocation (
        float                               x,
        float                               y,
        float                               width,
        float                               height
        );

    /*
    * Set location on screen in pixels.
    */
    void SetScreenPosition (
        int                                 x,
        int                                 y
        );

    /*
    * Set location on screen in pixels.
    */
    void SetScreenRectangle (
        int                                 x,
        int                                 y,
        int                                 width,
        int                                 height
        );


    /*
    * Returns the x/y coordinates of the layer's mouse cursor.
    */
    void GetCursorPosition (
        int                                *ret_x,
        int                                *ret_y
        );

    /*
    * Move cursor to specified position.
    *
    * Handles movement like a real one, i.e. generates events.
    */
    void WarpCursor (
        int                                 x,
        int                                 y
        );

    /*
    * Set cursor acceleration.
    *
    * Sets the acceleration of cursor movements. The amount
    * beyond the 'threshold' will be multiplied with the
    * acceleration factor. The acceleration factor is
    * 'numerator/denominator'.
    */
    void SetCursorAcceleration (
        int                                 numerator,
        int                                 denominator,
        int                                 threshold
        );

    /*
    * Set the cursor shape and the hotspot.
    */
    void SetCursorShape (
        IDirectFBSurface                   *shape,
        int                                 hot_x,
        int                                 hot_y
        );






    /*
    * Set the cursor opacity.
    *
    * This function is especially useful if you want
    * to hide the cursor but still want windows on this
    * display layer to receive motion events. In this
    * case, simply set the cursor opacity to zero.
    */
    void SetCursorOpacity (
        u8                                  opacity
        );


    /** Synchronization **/

    /*
    * Wait for next vertical retrace.
    */
    void WaitForSync ();


    /** Contexts **/

    /*
    * Switch the layer context.
    *
    * Switches to the shared context unless <b>exclusive</b> is DFB_TRUE
    * and the cooperative level of this interface is DLSCL_EXCLUSIVE.
    */
    void SwitchContext (
        DFBBoolean                          exclusive
        );


    /** Rotation **/

    /*
    * Set the rotation of data within the layer.
    *
    * Only available in exclusive or administrative mode.
    *
    * Any <b>rotation</b> other than 0, 90, 180 or 270 is not supported.
    *
    * No layer hardware feature usage, only rotated blitting is used.
    */
    void SetRotation (
        int                                 rotation
        );

    /*
    * Get the rotation of data within the layer.
    */
    void GetRotation (
        int                                *ret_rotation
        );


    /*
    * Set the alpha mode of displayer
    * two type can be choose DLOP_OPACITY ,DLOP_ALPHACHANNEL
    */

    void SetAlphaMode (
        DFBDisplayLayerOptions             flag
        );

    /*
    *Set the stretch mode of the displayer
    *choose GOP H stretchmode, V stretch mode, color transparent stretch mode
    *
    */
    void SetStretchMode (
        DFBDisplayLayerStretchSetting      stretch_mode
        );

    /*
    *Set the desk top display mode for supporting stereo 3D UI
    *
    */
    void SetDeskDisplayMode (
        DFBDisplayLayerDeskTopDisplayMode  disktop_mode
        );



    /*
    *API to set layer cursor position
    *
    */
    void MoveCursorTo (int x, int y);

    /*
    *API to set get active window num
    *
    */
    void GetActiveWindowNum (int *ret_num);
        
    /*
    *API to set force update HW status
    *
    */
    void ReactiveLayer ();


    /** Color adjustment **/

    /*
    * Get the layers color adjustment.
    */
    void GetColorAdjustment (DFBColorAdjustment *ret_adj);

    /*
    * Set the layers color adjustment.
    *
    * Only available in exclusive or administrative mode.
    *
    * This function only has an effect if the underlying
    * hardware supports this operation. Check the layers
    * capabilities to find out if this is the case.
    */
    void SetColorAdjustment (const DFBColorAdjustment *adj);

};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBWindow
// -------------------------------
class DFBWindowPrivate;

class DFBWindow : public IFSurfaceCommon
{
    FORBIDDEN_COPY(DFBWindow);

    DECL_PRIVATE(DFBWindow);

public:

    explicit DFBWindow (DFBLayer & parent);

    ~DFBWindow();

    IDirectFBWindow * GetInstance ();

    IDirectFBSurface * GetSurface ();

    void SetWindowDescription (DFBWindowDescription desc);

    void Resize (int width, int height);

    void SetOpacity (unsigned char opacity);

    void SetStackingClass (DFBWindowStackingClass stacking_class);

    

    void Move (int dx, int dy);

    void MoveTo (int x, int y);

    void SetColor (unsigned char r, unsigned char g, unsigned char b, unsigned char a);


    /** Retrieving information **/

    /*
    * Get the unique window ID.
    */
    void GetID (DFBWindowID *ret_window_id);

    /*
    * Get the current position of this window.
    */
    void GetPosition (int *ret_x, int *ret_y);

    /*
    * Get the size of the window in pixels.
    */
    void GetSize (int *ret_width, int *ret_height);

    /*
    * Resize the surface of a scalable window.
    *
    * This requires the option DWOP_SCALE.
    * See IDirectFBWindow::SetOptions().
    */
    void ResizeSurface (int width, int height);


	/** Events **/

	/*
	* Create an event buffer for this window and attach it.
	*/
	void CreateEventBuffer (IDirectFBEventBuffer **ret_buffer);

	/*
	* Attach an existing event buffer to this window.
	*
	* NOTE: Attaching multiple times generates multiple events.
	*
	*/
	void AttachEventBuffer (IDirectFBEventBuffer *buffer);

	/*
	* Detach an event buffer from this window.
	*/
	void DetachEventBuffer (IDirectFBEventBuffer *buffer);

	/*
	* Enable specific events to be sent to the window.
	*
	* The argument is a mask of events that will be set in the
	* window's event mask. The default event mask is DWET_ALL.
	*/
	void EnableEvents (DFBWindowEventType mask);




	/*
	* Disable specific events from being sent to the window.
	*
	* The argument is a mask of events that will be cleared in
	* the window's event mask. The default event mask is DWET_ALL.
	*/
	void DisableEvents (DFBWindowEventType mask);


	/** Options **/

	/*
	* Set options controlling appearance and behaviour of the window.
	*/
	void SetOptions (DFBWindowOptions options);

	/*
	* Get options controlling appearance and behaviour of the window.
	*/
	void GetOptions (DFBWindowOptions *ret_options);
		

	/*
	* Set the window color key.
	*
	* If a pixel of the window matches this color the
	* underlying window or the background is visible at this
	* point.
	*/
	void SetColorKey (u8 r, u8 g, u8 a);


	/*
	* Set the window color key (indexed).
	*
	* If a pixel (indexed format) of the window matches this
	* color index the underlying window or the background is
	* visible at this point.
	*/
	void SetColorKeyIndex (unsigned int index);
		

	/*
	* Disable alpha channel blending for one region of the window.
	*
	* If DWOP_ALPHACHANNEL and DWOP_OPAQUE_REGION are set but not DWOP_COLORKEYING
	* and the opacity of the window is 255 the window gets rendered
	* without alpha blending within the specified region.
	*
	* This is extremely useful for alpha blended window decorations while
	* the main content stays opaque and gets rendered faster.
	*/
	void SetOpaqueRegion (int x1, int y1, int x2, int y2);


	/*
	* Get the current opacity factor of this window.
	*/
	void GetOpacity (u8 *ret_opacity);

	/*
	* Bind a cursor shape to this window.
	*
	* This method will set a per-window cursor shape. Everytime
	* the cursor enters this window, the specified shape is set.
	*
	* Passing NULL will unbind a set shape and release its surface.
	*/
	void SetCursorShape(IDirectFBSurface  *shape, int hot_x, int  hot_y);

	/*
	* Set position and size in one step.
	*/
	void SetBounds (int  x, int  y, int  width, int height);


     /*
      * Raise the window by one within the window stack.
      */
     void  Raise ();

     /*
      * Lower the window by one within the window stack.
      */
     void Lower ();

     /*
      * Put the window on the top of the window stack.
      */
     void RaiseToTop ();

     /*
      * Send a window to the bottom of the window stack.
      */
     void LowerToBottom ();

     /*
      * Put a window on top of another window.
      */
     void PutAtop (IDirectFBWindow  *lower);

     /*
      * Put a window below another window.
      */
     void PutBelow (IDirectFBWindow  *upper);


   /** Binding **/

     /*
      * Bind a window at the specified position of this window.
      *
      * After binding, bound window will be automatically moved
      * when this window moves to a new position.<br>
      * Binding the same window to multiple windows is not supported.
      * Subsequent call to Bind() automatically unbounds the bound window
      * before binding it again.<br>
      * To move the bound window to a new position call Bind() again
      * with the new coordinates.
      */
     void Bind (
          IDirectFBWindow               *window,
          int                            x,
          int                            y
     );

     /*
      * Unbind a window from this window.
      */
     void Unbind (
          IDirectFBWindow               *window
     );


   /** Focus handling **/

     /*
      * Pass the focus to this window.
      */
     void RequestFocus ();

     /*
      * Grab the keyboard, i.e. all following keyboard events are
      * sent to this window ignoring the focus.
      */
     void GrabKeyboard ();

     /*
      * Ungrab the keyboard, i.e. switch to standard key event
      * dispatching.
      */
     void UngrabKeyboard ();

     /*
      * Grab the pointer, i.e. all following mouse events are
      * sent to this window ignoring the focus.
      */
     void GrabPointer ();

     /*
      * Ungrab the pointer, i.e. switch to standard mouse event
      * dispatching.
      */
     void UngrabPointer ();

     /*
      * Grab a specific key, i.e. all following events of this key are
      * sent to this window ignoring the focus.
      */
     void GrabKey (
          DFBInputDeviceKeySymbol        symbol,
          DFBInputDeviceModifierMask     modifiers
     );

     /*
      * Ungrab a specific key, i.e. switch to standard key event
      * dispatching.
      */
     void UngrabKey (
          DFBInputDeviceKeySymbol        symbol,
          DFBInputDeviceModifierMask     modifiers
     );


	 /** Key selection **/

	 /*
	 * Selects a mode for filtering keys while being focused.
	 *
	 * The <b>selection</b> defines whether all, none or a specific set (list) of keys is selected.
	 * In case of a specific set, the <b>keys</b> array with <b>num_keys</b> has to be provided.
	 *
	 * Multiple calls to this method are possible. Each overrides all settings from the previous call.
	 */
	 void SetKeySelection (
		 DFBWindowKeySelection          selection,
		 const DFBInputDeviceKeySymbol *keys,
		 unsigned int                   num_keys
		 );

	 /*
	 * Grab all unselected (filtered out) keys.
	 *
	 * Unselected keys are those not selected by the focused window. These keys won't be sent
	 * to that window. Instead one window in the stack can collect them.
	 *
	 * See also IDirectFBWindow::UngrabUnselectedKeys() and IDirectFBWindow::SetKeySelection().
	 */
	 void GrabUnselectedKeys ();

	 /*
	 * Release the grab of unselected (filtered out) keys.
	 *
	 * See also IDirectFBWindow::GrabUnselectedKeys() and IDirectFBWindow::SetKeySelection().
	 */
	 void UngrabUnselectedKeys ();


	 /** Advanced Geometry **/

	 /*
	 * Set area of surface to be shown in window.
	 *
	 * Default and maximum is to show whole surface.
	 */
	 void SetSrcGeometry (const DFBWindowGeometry       *geometry);		 


	 /*
	 * Set destination location of window within its bounds.
	 *
	 * Default and maximum is to fill whole bounds.
	 */
	 void SetDstGeometry (const DFBWindowGeometry       *geometry);


	 /** Properties **/

	 /*
	 * Set property controlling appearance and behaviour of the window.
	 */
	 void SetProperty (
		 const char                    *key,
		 void                          *value,
		 void                         **ret_old_value
		 );

	 /*
	 * Get property controlling appearance and behaviour of the window.
	 */
	 void GetProperty (
		 const char                    *key,
		 void                         **ret_value
		 );

	 /*
	 * Remove property controlling appearance and behaviour of the window.
	 */
	 void RemoveProperty (
		 const char                    *key,
		 void                         **ret_value
		 );

	 /*
	 * Set window rotation.
	 */
	 void SetRotation (
		 int                            rotation
		 );

	 /** Association **/

	 /*
	 * Change the window association.
	 *
	 * If <b>window_id</b> is 0, the window will be dissociated.
	 */
	 void SetAssociation (
		 DFBWindowID                    window_id
		 );

	 /** Application ID **/

	 /*
	 * Set application ID.
	 *
	 * The usage of the application ID is not imposed by DirectFB
	 * and can be used at will by the application. Any change will
	 * be notified, and as such, an application manager using SaWMan
	 * can be used to act on any change.
	 */
	 void SetApplicationID (
		 unsigned long                  application_id
		 );

	 /*
	 * Get current application ID.
	 */
	 void GetApplicationID (
		 unsigned long                 *ret_application_id
		 );
};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBSurface
// -------------------------------
class DFBSurfacePrivate;

class DFBSurface : public IFSurfaceCommon
{
    FORBIDDEN_COPY(DFBSurface);

    DECL_PRIVATE(DFBSurface);

public:

    explicit DFBSurface (IDirectFBSurface * surface);

    DFBSurface ();

    ~DFBSurface();

    IDirectFBSurface * GetSurface ();

    void SetSurfaceDescription (DFBSurfaceDescription desc);

};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBImageProvider
// -------------------------------

class DFBImageProvider
{
    FORBIDDEN_COPY(DFBImageProvider);

public:

    explicit DFBImageProvider (const char * filename);

    ~DFBImageProvider();

    IDirectFBImageProvider * GetInstance ();

    void GetSurfaceDescription (DFBSurfaceDescription * ret_dsc);

    void GetImageDescription (DFBImageDescription * ret_dsc);

    void RenderTo (IFSurfaceCommon & destination, const DFBRectangle * destination_rect);

    void RenderTo (IDirectFBSurface * destination, const DFBRectangle * destination_rect);

private:
    IDirectFBImageProvider * m_provider;
};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBVideoProvider
// -------------------------------

class DFBVideoProvider
{
    FORBIDDEN_COPY(DFBVideoProvider);

public:

    explicit DFBVideoProvider (const char * filename);

    ~DFBVideoProvider();

    IDirectFBVideoProvider * GetInstance ();

    void GetSurfaceDescription (DFBSurfaceDescription * ret_dsc);

    void PlayTo (IDirectFBSurface * destination, const DFBRectangle * destination_rect, DVFrameCallback callback, void * ctx);

    void PlayTo (IFSurfaceCommon & destination, const DFBRectangle * destination_rect, DVFrameCallback callback, void * ctx);

private:
    IDirectFBVideoProvider * m_provider;

};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      IDirectFBFont
// -------------------------------

class DFBFont
{
    FORBIDDEN_COPY(DFBFont);

public:
    DFBFont(const char * filename, const  DFBFontDescription * desc);

    ~DFBFont();

    IDirectFBFont * GetInstance ();

    void GetHeight (int * ret_height);

private:
    IDirectFBFont * m_font;
};

//////////////////////////////////////////////////////////////////////////

// -------------------------------
//      Count FPS
// -------------------------------

class PProbePrivate;

class PProbe
{
    DECL_PRIVATE(PProbe);
    FORBIDDEN_COPY(PProbe);

    static const int MAX_PARAMETER_SIZE = 128; // in chars

public:

    explicit PProbe(const char * loginfo = 0, ...);
    ~PProbe();

    void start ();
    void stop ();
    void setRepeatInterval (unsigned int interval = 1);

    float getDuration (); // in second
    float getFPS ();

    const char* getStringFPS ();
};

#endif