openvg/openvgrefimplementation/sfopenvg/test/inc/tiger.h
changeset 43 7579f232bae7
equal deleted inserted replaced
36:01a6848ebfd7 43:7579f232bae7
       
     1 /*
       
     2 * Copyright (c) 2009 Symbian Foundation Ltd
       
     3 * This component and the accompanying materials are made available
       
     4 * under the terms of the License "Eclipse Public License v1.0"
       
     5 * which accompanies this distribution, and is available
       
     6 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 *
       
     8 * Initial Contributors:
       
     9 * Symbian Foundation Ltd - initial contribution.
       
    10 * 
       
    11 * Contributors:
       
    12 *
       
    13 * Description:
       
    14 * CTiger class declaration to render OpenVG tiger image
       
    15 */
       
    16 
       
    17 #ifndef TIGER_H
       
    18 #define TIGER_H
       
    19 
       
    20 //  INCLUDES
       
    21 #include <e32base.h> // for CBase definition
       
    22 #include <egl.h>
       
    23 #include <openvg.h>
       
    24 //#include <vgu.h>
       
    25 #include <eglosnativewindowtype.h>
       
    26 
       
    27 ////////////////////////////////////////////
       
    28 //Copied from ri_package_11\samples\tiger\tiger.h
       
    29 extern const int KtigerCommandCount;
       
    30 extern const char KtigerCommands[];
       
    31 extern const float KtigerMinX;
       
    32 extern const float KtigerMaxX;
       
    33 extern const float KtigerMinY;
       
    34 extern const float KtigerMaxY;
       
    35 extern const int KtigerPointCount;
       
    36 extern const float KtigerPoints[];
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  * Class that does the actual OpenGL ES rendering.
       
    42  */
       
    43 typedef struct
       
    44 {
       
    45 	VGFillRule		m_fillRule;
       
    46 	VGPaintMode		m_paintMode;
       
    47 	VGCapStyle		m_capStyle;
       
    48 	VGJoinStyle		m_joinStyle;
       
    49 	float			m_miterLimit;
       
    50 	float			m_strokeWidth;
       
    51 	VGPaint			m_fillPaint;
       
    52 	VGPaint			m_strokePaint;
       
    53 	VGPath			m_path;
       
    54 } PathData;
       
    55 
       
    56 typedef struct
       
    57 {
       
    58 	PathData*			m_paths;
       
    59 	int					m_numPaths;
       
    60 } PS;
       
    61 
       
    62 /////////////////////////////////////////////////////////////
       
    63 
       
    64 class RWindow;
       
    65 
       
    66 class CTiger : public CBase
       
    67     {
       
    68     public:  // Constructors and destructor
       
    69 
       
    70         /**
       
    71          * Factory method for creating a new CTiger object.
       
    72          */
       
    73         static CTiger* NewL( TUint aWidth, TUint aHeight);
       
    74 
       
    75         /**
       
    76          * Destructor. Does nothing.
       
    77          */
       
    78         virtual ~CTiger();
       
    79 
       
    80     public: // New functions
       
    81 
       
    82         /**
       
    83          * Initializes OpenGL ES, sets the vertex and color
       
    84          * arrays and pointers. Also selects the shading mode.
       
    85          */
       
    86         void AppInit( RWindow& aWindow, CFbsBitmap* aBitmapToDraw=NULL );
       
    87         
       
    88         /**
       
    89          * Called upon application exit. Does nothing.
       
    90          */
       
    91         void AppExit( void );
       
    92 
       
    93         /**
       
    94          * Notifies that the screen size has dynamically changed during execution of
       
    95          * this program. Resets the viewport to this new size.
       
    96          * @param aWidth New width of the screen.
       
    97          * @param aHeight New height of the screen.
       
    98          */
       
    99         void SetScreenSize( TUint aWidth, TUint aHeight );
       
   100         
       
   101         void AppRender( const TRect& aRect, CFbsBitmap* aDst=NULL);
       
   102 
       
   103     protected: // New functions
       
   104 
       
   105         /**
       
   106          * Standard constructor that must never Leave.
       
   107          * Stores the given screen width and height.
       
   108          * @param aWidth Width of the screen.
       
   109          * @param aHeight Height of the screen.
       
   110          */
       
   111         CTiger(TUint aWidth, TUint aHeight);
       
   112 
       
   113         /**
       
   114          * Second phase contructor. Does nothing.
       
   115          */
       
   116         void ConstructL( void );
       
   117         
       
   118         //fucntions copied from ri_package_11\samples\tiger\main.c - no attempt to Symbianise!!
       
   119         void PS_destruct(PS* ps);
       
   120         void render(int w, int h);
       
   121         void PS_render(PS* ps);
       
   122         PS* PS_construct(const char* commands, int commandCount, const float* points, int pointCount);
       
   123         void init(NativeWindowType window, CFbsBitmap* aBitmapToDraw=NULL);
       
   124         void CreateImage(CFbsBitmap* aBitmapToDraw);
       
   125         void renderFromBitmap(int w, int h);
       
   126         
       
   127 
       
   128     private: // Data
       
   129 
       
   130         /** Width of the screen */
       
   131         TUint           iScreenWidth;
       
   132 
       
   133         /** Height of the screen */
       
   134         TUint           iScreenHeight;
       
   135 
       
   136     private: //OpenVG structures
       
   137     	
       
   138     	//copied from ri_package_11\samples\tiger\main.c - no attempt to symbianise
       
   139     	PS* 				iTiger;
       
   140     	int					iRenderWidth;
       
   141     	int					iRenderHeight;
       
   142     	EGLDisplay			iEgldisplay;
       
   143     	EGLConfig			iEglconfig;
       
   144     	EGLSurface			iEglsurface;
       
   145     	EGLContext			iEglcontext;
       
   146     	TNativeWindowType iNativeWindowType;
       
   147     	VGImage iImage;
       
   148     	CFbsBitmap* iBitmapToDraw;
       
   149    	
       
   150     };
       
   151 #endif // TIGER_H
       
   152 
       
   153 // End of File