uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10PBufferSurface.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Definition of CHuiVg10PBufferSurface class. 
       
    15 *                CHuiVg10PBufferSurface is an OpenVG PBuffer surface 
       
    16 *                object that implements the MHuiRenderSurface interface.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __HUIVG10PBUFFERSURFACE_H__
       
    23 #define __HUIVG10PBUFFERSURFACE_H__
       
    24 
       
    25 
       
    26 #include "HuiVg10RenderSurface.h"
       
    27 
       
    28 class CHuiVg10RenderPlugin;
       
    29 class CFbsBitmap;
       
    30 
       
    31 /**
       
    32  * Off-screen rendering surface for OpenGL ES content. A pbuffer (pixel buffer)
       
    33  * surface can be used for instance for rendering temporary graphical content 
       
    34  * onto. This content can then be reused in the current application. Because 
       
    35  * the class has been inherited from MHuiRenderSurface, it can also be used 
       
    36  * for rendering from displays. Doesn't output rendered content on the 
       
    37  * framebuffer.
       
    38  *
       
    39  * @lib hitchcock.lib
       
    40  */
       
    41 NONSHARABLE_CLASS(CHuiVg10PBufferSurface) : public CBase, public MHuiRenderSurface
       
    42     {
       
    43 public: // Constructors and destructor
       
    44 
       
    45     /**
       
    46 	 * \todo     
       
    47 	 */
       
    48     static CHuiVg10PBufferSurface* NewLC(CHuiVg10RenderPlugin& aRenderer, const TSize& aSize, TInt aAlphaBits, TInt aEglBufferType, TInt aBufferColorMode);
       
    49 
       
    50     /**
       
    51      * Constructs a new example CHuiVg10PBufferSurface instance. A static factory method that
       
    52      * leaves the object to the cleanup stack.
       
    53      * @param aRenderer CHuiVg10RenderPlugin object that is used to access the shared context
       
    54      * and determine surface configurations.
       
    55      * @param aSize Size in pixels of the created PBuffer surface object.
       
    56      * @return Newly created instance of CHuiVg10PBufferSurface.
       
    57      */
       
    58     static CHuiVg10PBufferSurface* NewLC(CHuiVg10RenderPlugin& aRenderer, const TSize& aSize, TInt aAlphaBits = 0);
       
    59 
       
    60     /**
       
    61      * Constructs a new example CHuiVg10PBufferSurface instance. A static factory method.
       
    62      * @param aSize Size in pixels of the created PBuffer surface object.
       
    63      * @return Newly created instance of CHuiVg10PBufferSurface.
       
    64      */
       
    65     static CHuiVg10PBufferSurface* NewL(const TSize& aSize, TInt aAlphaBits = 0);
       
    66 
       
    67     /**
       
    68      * Constructs a new CHuiVg10PBufferSurface class instance and leaves it
       
    69      * on the cleanup stack.
       
    70      * @param aSize Size in pixels of the created PBuffer surface object.
       
    71      * @return Newly created instance of CHuiVg10PBufferSurface.
       
    72      */
       
    73     static CHuiVg10PBufferSurface* NewLC(const TSize& aSize, TInt aAlphaBits = 0);
       
    74 
       
    75     /**
       
    76      * Destructor.
       
    77      */
       
    78     virtual ~CHuiVg10PBufferSurface();
       
    79 
       
    80 public: // From MHuiRenderSurface
       
    81 
       
    82     TUint Flags() const;
       
    83     
       
    84     /**
       
    85      * Determines the location of the rendering surface on the screen. But since
       
    86      * this is an off-screen surface, will return EFalse and will not set the
       
    87      * origin.
       
    88      *
       
    89      * @return  If location successfully determined, returns <code>ETrue</code>.
       
    90      *          If the surface is an off-screen surface, returns <code>EFalse</code>.
       
    91      */
       
    92     TBool GetScreenOrigin(TPoint& aOrigin) const;
       
    93 
       
    94     /**
       
    95      * Determines the size of the surface.
       
    96      *
       
    97      * @return  Size of the surface in pixels.
       
    98      */
       
    99     TSize Size() const;
       
   100 
       
   101     /**
       
   102      * Changes the size of the surface.
       
   103      *
       
   104      * @param aSize  Size of surface in pixels.
       
   105      */
       
   106     void SetSizeL(const TSize& aSize);
       
   107 
       
   108     /**
       
   109      * Makes this the current rendering surface for any drawing operations.
       
   110      * Call CHuiStatic::SetCurrentRenderSurface().
       
   111      */
       
   112     void MakeCurrent();
       
   113 
       
   114     /**
       
   115      * Swaps the front and back buffers of the surface.
       
   116      * Pbuffers consist of a single buffer only, so swapping has no effect.
       
   117      */
       
   118     void SwapBuffers();
       
   119 
       
   120     /**
       
   121      * Binds a texture to the surface to be used during subsequent drawing
       
   122      * operations.
       
   123      */
       
   124     void BindTexture(TInt aTextureUnit,
       
   125                              const MHuiSegmentedTexture& aTexture,
       
   126                              TInt activeTextureSegment);
       
   127 
       
   128     /**
       
   129      * Handles change in surface visibility. This method is called if surface is either
       
   130      * hidden or shown.
       
   131      *
       
   132      * @param aIsVisible ETrue if surface becomes visible. EFalse if surface is hidden.
       
   133      */
       
   134     void HandleVisibilityEvent(TBool aIsVisible);
       
   135 
       
   136     void Release();
       
   137     
       
   138     void RestoreL();
       
   139     
       
   140     void HandleDisplayUsageChangeL();    
       
   141 
       
   142     // These methods are not really used, since opengles renderer doesn't
       
   143     // support dirty region handling or symbian graphics context!
       
   144     virtual void SetDirtyRect(const TRect& aRect);
       
   145     virtual MHuiTargetBitmap* BackBuffer();
       
   146     virtual CFbsBitGc* Gc();
       
   147 
       
   148     /**
       
   149      * Provides expandability, helps keeping the binary compatibility. Since virtual
       
   150      * table is now exported and this class is dll derivable and the implementation
       
   151      * is more difficult to change, hence this method, which can provide additional
       
   152      * extension APIs.
       
   153      * 
       
   154      * @param aExtensionUid     UID, which is being used for recognizing the extension
       
   155      * @param aExtensionParams  Return pointer to the extension API, once recognized from the extension uid
       
   156      */
       
   157     virtual void RenderSurfaceExtension(const TUid& aExtensionUid, TAny** aExtensionParams);
       
   158 
       
   159 public: // New methods
       
   160 
       
   161     /**
       
   162      * Returns the associated EGL surface object.
       
   163      */
       
   164     EGLSurface EglSurface();
       
   165     
       
   166 	void BindToM3G();
       
   167 	
       
   168 	void ReleaseFromM3G();
       
   169     
       
   170     /**
       
   171      * \todo
       
   172      */
       
   173     CFbsBitmap* Buffer();
       
   174     
       
   175     /**
       
   176      * \todo
       
   177      */
       
   178     TInt BufferColorMode() const;
       
   179 
       
   180 
       
   181 protected:
       
   182 
       
   183     /**
       
   184      * Creates a new PBuffer surface object.
       
   185      */
       
   186     EGLSurface CreateSurface(EGLConfig aConfig);
       
   187 
       
   188     /**
       
   189      * Determine config for the owner display.
       
   190      */
       
   191     EGLConfig DetermineConfig();
       
   192 
       
   193 
       
   194 private:
       
   195 
       
   196     /* Constructors. */
       
   197 
       
   198     /**
       
   199      * Constructs an instance of CHuiClassName.
       
   200      * @param aRenderer    CHuiVg10RenderPlugin object that is used to access 
       
   201      *                     the shared context and determine surface configurations.
       
   202      * @param aSize        Size of the created PBuffer surface.
       
   203      * @note               Protected because this constructor only needs to be 
       
   204      *                     called by derived classes. Use the provided static 
       
   205      *                     factory methods instead.
       
   206      * @see NewL()
       
   207      * @see NewLC()
       
   208      */
       
   209     CHuiVg10PBufferSurface(CHuiVg10RenderPlugin& aRenderer, const TSize& aSize, TInt aAlphaBits, TInt aEglBufferType, TInt aBufferColorMode);
       
   210 
       
   211     /**
       
   212      * Second-phase constructor.
       
   213      */
       
   214     void ConstructL();
       
   215 
       
   216 
       
   217 private:
       
   218 
       
   219     /** The display. */
       
   220     EGLDisplay iEglDisplay;
       
   221 
       
   222     /** The rendering context. */
       
   223     EGLContext iEglContext;
       
   224 
       
   225     /** The pbuffer surface where the graphics are drawn. */
       
   226     EGLSurface iEglSurface;
       
   227 
       
   228     /** Current surface size. */
       
   229     TSize iSize;
       
   230 
       
   231     /** \todo */
       
   232 	TInt iEglBufferType;
       
   233 	
       
   234     /** \todo */
       
   235 	TInt iBufferColorMode;
       
   236 	
       
   237     /** Alpha channel bits to allocate. */
       
   238     TInt iAlphaBits;
       
   239     
       
   240     CFbsBitmap* iBuffer;
       
   241     
       
   242     /** OpenGL ES Render plugin that provides the display configurations and the display
       
   243     for this pbuffer surface. */
       
   244     CHuiVg10RenderPlugin& iRenderer;
       
   245 
       
   246     TBool iIsHardwareAccelerated;
       
   247     };
       
   248 
       
   249 
       
   250 #endif // __HUIVG10PBUFFERSURFACE_H__
       
   251