hostsupport/inc/VGInterface.h
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 24 a3f46bb01be2
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and /or associated documentation files
       
     5  * (the "Materials "), to deal in the Materials without restriction,
       
     6  * including without limitation the rights to use, copy, modify, merge,
       
     7  * publish, distribute, sublicense, and/or sell copies of the Materials,
       
     8  * and to permit persons to whom the Materials are furnished to do so,
       
     9  * subject to the following conditions:
       
    10  *
       
    11  * The above copyright notice and this permission notice shall be included
       
    12  * in all copies or substantial portions of the Materials.
       
    13  *
       
    14  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
       
    18  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
       
    19  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
       
    20  * THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21  *
       
    22  * Initial Contributors:
       
    23  * Nokia Corporation - initial contribution.
       
    24  *
       
    25  * Contributors:
       
    26  *
       
    27  * Description:
       
    28  *
       
    29  */
       
    30 
       
    31 #ifndef _VGINTERFACE_H_
       
    32 #define _VGINTERFACE_H_
       
    33 
       
    34 #include "ImageTarget.h"
       
    35 
       
    36 struct SurfaceDescriptor;
       
    37 struct BufferContainer;
       
    38 class CColorDescriptor;
       
    39 
       
    40 typedef void (*fpVGProc)(void);
       
    41 
       
    42 // EGL services for VG
       
    43 class IVGtoEGLInterface
       
    44     {
       
    45 public:
       
    46     // \todo Descriptions
       
    47     virtual void* GetVGContext() = 0;
       
    48     virtual bool IsImageInUse( void* image ) = 0;
       
    49     virtual bool LockVGSurface( bool read, bool write ) = 0;
       
    50     virtual bool UnlockVGSurface() = 0;
       
    51     virtual void GetDescForImage( void* image, SurfaceDescriptor& ImageDesc ) = 0;
       
    52     virtual void* GetDataForImage( void* image ) = 0;
       
    53 	virtual void RegisterImageTarget( void* image, EImageTarget target, void* buffer ) = 0;
       
    54 	virtual void UnregisterImageTarget( void* image, EImageTarget target, void* buffer ) = 0;
       
    55     };
       
    56 
       
    57 // VG services for EGL
       
    58 class IEGLtoVGInterface
       
    59     {
       
    60 public:
       
    61     /* \brief Sets interface for EGL services to VG
       
    62      *
       
    63      * \param egl Pointer to IVGtoEGLInterface implementation.
       
    64      */
       
    65     virtual void SetEGLInterface( IVGtoEGLInterface* egl ) = 0;
       
    66 
       
    67     /* \brief Used to create internal VG context
       
    68      * 
       
    69      * \param shareContext  Context to be shared with created context
       
    70      *
       
    71      * \return  Handle to created context
       
    72      */
       
    73     virtual void* CreateContext( void* shareContext ) = 0;
       
    74 
       
    75     /* \brief Releases internal VG context
       
    76      * 
       
    77      * \param context   Context to be released
       
    78      *
       
    79      * \return  true if release succeeded false otherwise
       
    80      */
       
    81     virtual bool ReleaseContext( void* context ) = 0;
       
    82 
       
    83     /* \brief Creates internal VG surface
       
    84      * 
       
    85      * \param desc      Descriptor describing surface pixel format, size, stride etc.
       
    86      * \param buffers   Container for buffers. VG should fill in handle for surface, color buffer and mask buffer.
       
    87      * \param image     VG image handle used in surface creation (eglCreatePbufferFromClientBuffer()).
       
    88      *
       
    89      * \return true if surface creation succeeded false otherwise
       
    90      */
       
    91     virtual bool CreateSurface( const SurfaceDescriptor* desc, BufferContainer* buffers, void* image ) = 0;
       
    92 
       
    93     /* \brief Releases internal VG surface
       
    94      * 
       
    95      * \param surface   Surface to be released
       
    96      *
       
    97      * \return  true if surface release succeeded false otherwise
       
    98      */
       
    99     virtual bool ReleaseSurface( void* surface ) = 0; 
       
   100 
       
   101     /* \brief Sets current surface for internal VG context
       
   102      * 
       
   103      * \param context   Handle to internal VG context
       
   104      * \param surface   Handle to internal VG surface to be set current to context.
       
   105      *
       
   106      * \return  true if succeeded false otherwise
       
   107      */
       
   108     virtual bool SetCurrentSurface( void* context, void* surface ) = 0;
       
   109 
       
   110      /* \brief Resizes internal VG surface
       
   111      * 
       
   112      * \param context   Handle to internal VG context
       
   113      * \param surface   Handle to internal VG surface
       
   114      * \param width     New width
       
   115      * \param height    New height
       
   116      * \param buffers   Container for buffers. VG should fill in handle for surface, color buffer and mask buffer.
       
   117      *
       
   118      * \return  true if resize succeeded false otherwise
       
   119      */
       
   120     virtual bool ResizeSurface( void* context, void* surface, int width, int height, BufferContainer* buffers ) =0;
       
   121 
       
   122     /* \brief Checks if image handle is valid VGImage
       
   123      * 
       
   124      * \param image     Handle to VG image
       
   125      * \param colorDesc Color descriptor. VG should fill in descriptor describing image.
       
   126      * \param width     On return should contain widht of the VG image
       
   127      * \param height    On return should contain height of the VG image
       
   128      *
       
   129      * \return  true if image is valid false otherwise
       
   130      */
       
   131     virtual bool IsValidImage( void* image, CColorDescriptor* colorDesc, int* width, int* height ) = 0;
       
   132 
       
   133     /* \brief Checks if image handle is in use by VG
       
   134      *
       
   135      * param image      Handle to VG image
       
   136 
       
   137      * return true if image is in use false otherwise
       
   138      */
       
   139     virtual bool IsImageInUse( void* image ) = 0;
       
   140 
       
   141     /* \brief Flushes current vg context. Same operation as vgFlush().
       
   142      */
       
   143     virtual void Flush() = 0;
       
   144 
       
   145     /* \brief Finishes VG drawing. Same operation as vgFinish().
       
   146      */
       
   147     virtual void Finish() = 0;
       
   148 
       
   149     /* \brief Used to get address of vg extension function. Called by eglGetProcAddress().
       
   150      *
       
   151      * \param procname Name of the vg extension function
       
   152      *
       
   153      * \return  Address of the vg extension function or NULL if extension is not found.
       
   154      */
       
   155     virtual fpVGProc GetVGProcAddress( const char *procname ) = 0;
       
   156 
       
   157     /* \brief Copy VG color buffer into buffer.
       
   158      * 
       
   159      * \param buffer Buffer to copy data from VG color buffer
       
   160      * \param stride Buffer stride
       
   161      * \param surface Handle to VG internal surface to copy color buffer from.
       
   162      * 
       
   163      * \return void
       
   164      */
       
   165     virtual void CopyBuffers( void* buffer, int stride, void* surface ) = 0;
       
   166 
       
   167     /* \brief Updates VG color buffer
       
   168      *
       
   169      * \param buffer Buffer to copy data from
       
   170      * \param stride Stride of buffer
       
   171      * \param desc   Surface descriptor describing buffer.
       
   172      *
       
   173      * \return void
       
   174      */
       
   175     virtual void UpdateBuffers( void* buffer, int stride, const SurfaceDescriptor* desc ) = 0;
       
   176 
       
   177     /* \brief Checks if VG image is root image
       
   178      *
       
   179      * \param image Handle to VG image
       
   180      *
       
   181      * \return True if image is root, false otherwise
       
   182      */
       
   183     virtual bool IsRootImage( void* image ) = 0;
       
   184 
       
   185     /* \brief Copies data from VG image
       
   186      * 
       
   187      * \param image Handle to VG image
       
   188      * \param desc  Descriptor describing VG image. Function should fill descriptor.
       
   189      * \param data  Pointer to copy data to.
       
   190      * 
       
   191      * \return void
       
   192      */
       
   193     virtual void GetImageData( void* image, SurfaceDescriptor& desc, void* data ) = 0;
       
   194 
       
   195     /* \brief Add(+1) VG image reference count when EGLimage is created from VGImage
       
   196      * 
       
   197      * \param image Handle to VG image
       
   198      * 
       
   199      * \return void
       
   200      */
       
   201     virtual void AddRef( void* image ) = 0;
       
   202 
       
   203     /* \brief Remove(-1) VG image reference count when EGLimage deleted
       
   204      * 
       
   205      * \param image Handle to VG image
       
   206      * 
       
   207      * \return void
       
   208      */
       
   209     virtual void RemoveRef( void* image ) = 0;
       
   210     };
       
   211 
       
   212 typedef IEGLtoVGInterface* (*fpGetVGInterface)(void);
       
   213 IEGLtoVGInterface* LoadVGInterface( void*& libraryHandle );
       
   214 
       
   215 #endif // _VGINTERFACE_H_
       
   216