uiacceltk/hitchcock/coretoolkit/rendervg10/inc/HuiVg10RenderSurface.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:   OpenVG 1.0 render surface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUIVG10RENDERSURFACE_H__
       
    21 #define __HUIVG10RENDERSURFACE_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include <EGL/egl.h>
       
    27 
       
    28 #include "HuiRenderSurface.h"
       
    29 #include "uiacceltk/HuiSessionObject.h"
       
    30 
       
    31 
       
    32 /* Forward declarations. */
       
    33 class CHuiDisplay;
       
    34 
       
    35 
       
    36 /**
       
    37  * The render surface is a destination where rendered graphics will ultimately
       
    38  * end up. This may be, e.g., the display frame buffer or a bitmap in memory.
       
    39  */
       
    40 NONSHARABLE_CLASS(CHuiVg10RenderSurface) : public CBase, public MHuiRenderSurface,
       
    41                                            public MHuiSessionObject
       
    42     {
       
    43 public:
       
    44 
       
    45     /* Constructors and destructor. */
       
    46 
       
    47     static CHuiVg10RenderSurface* NewL(CHuiDisplay& aDisplay);
       
    48 
       
    49     static CHuiVg10RenderSurface* NewLC(CHuiDisplay& aDisplay);
       
    50 
       
    51     virtual ~CHuiVg10RenderSurface();
       
    52 
       
    53 
       
    54     /* Methods, implemets MHuiRenderSurface interface. */
       
    55 
       
    56     TUint Flags() const;
       
    57     
       
    58     TBool GetScreenOrigin(TPoint& aOrigin) const;
       
    59 
       
    60     TSize Size() const;
       
    61 
       
    62     void SetSizeL(const TSize& aSize);
       
    63 
       
    64     virtual void MakeCurrent();
       
    65 
       
    66     virtual void SwapBuffers();
       
    67 
       
    68     virtual void BindTexture(TInt aTextureUnit,
       
    69                              const MHuiSegmentedTexture& aTexture,
       
    70                              TInt aSegment);
       
    71 
       
    72     /**
       
    73      * Handles change in surface visibility. This method is called if surface is either
       
    74      * hidden or shown. This default implementation ignores visibility events.
       
    75      *
       
    76      * @param aIsVisible ETrue if surface becomes visible. EFalse if surface is hidden.
       
    77      */
       
    78     virtual void HandleVisibilityEvent(TBool aIsVisible);
       
    79 
       
    80     virtual void Release();
       
    81 
       
    82     virtual void RestoreL();
       
    83 
       
    84     virtual void HandleDisplayUsageChangeL();
       
    85     
       
    86     // These methods are not really used, since opengles renderer doesn't
       
    87     // support dirty region handling or symbian graphics context!
       
    88     virtual void SetDirtyRect(const TRect& aRect);
       
    89     virtual MHuiTargetBitmap* BackBuffer();
       
    90     virtual CFbsBitGc* Gc();
       
    91 
       
    92     /**
       
    93      * Provides expandability, helps keeping the binary compatibility. Since virtual
       
    94      * table is now exported and this class is dll derivable and the implementation
       
    95      * is more difficult to change, hence this method, which can provide additional
       
    96      * extension APIs.
       
    97      * 
       
    98      * @param aExtensionUid     UID, which is being used for recognizing the extension
       
    99      * @param aExtensionParams  Return pointer to the extension API, once recognized from the extension uid
       
   100      */
       
   101     virtual void RenderSurfaceExtension(const TUid& aExtensionUid, TAny** aExtensionParams);
       
   102 
       
   103     /**
       
   104      * Static method for returning verbose error message strings according to the given
       
   105      * EGL error value. This can be used to create meaningful error messages in
       
   106      * HUIToolkit environments that use OpenVG rendering.
       
   107      *
       
   108      * @param aErrorCode EGL Error code retrieved by eglGetError - method.
       
   109      * @return Verbose error message as a TDesC reference object.
       
   110      */
       
   111     static const TDesC& EglErrorMessage(TInt aErrorCode);
       
   112 
       
   113     // Implementation of MHuiSessionObject
       
   114     
       
   115     /**
       
   116      * Gets the object type.
       
   117      */
       
   118     TType Type() const;
       
   119 
       
   120     /**
       
   121      * Gets the session id for object.
       
   122      */
       
   123     TInt SessionId() const;
       
   124 
       
   125     /**
       
   126      * Sets the session id for object.
       
   127      */
       
   128     void SetSessionId(TInt aSessionId);
       
   129     
       
   130     /**
       
   131      *  @return the currently bound texture image.
       
   132      */
       
   133     const MHuiSegmentedTexture* BoundTexture() const;
       
   134 
       
   135 protected:
       
   136 
       
   137     /* Constructors. */
       
   138 
       
   139     CHuiVg10RenderSurface(CHuiDisplay& aDisplay);
       
   140 
       
   141     void ConstructL();
       
   142 
       
   143     /**
       
   144      * Determines the display to which this rendering surface is attached.
       
   145      *
       
   146      * @return  Display.
       
   147      */
       
   148     CHuiDisplay& Display() const;
       
   149 
       
   150     /**
       
   151      * Determine config for the owner display.
       
   152      */
       
   153     EGLConfig DetermineConfig();
       
   154 
       
   155     /**
       
   156      * Create an EGL rendering surface.
       
   157      */
       
   158     EGLSurface CreateSurface(EGLConfig aConfig);
       
   159 
       
   160 
       
   161 protected:
       
   162 
       
   163     /** Display that owns the surface. */
       
   164     CHuiDisplay* iDisplay;
       
   165 
       
   166     /** The display. */
       
   167     EGLDisplay iEglDisplay;
       
   168 
       
   169     /** The rendering context. */
       
   170     EGLContext iEglContext;
       
   171 
       
   172     /** The window where the graphics are drawn. */
       
   173     EGLSurface iEglSurface;
       
   174 
       
   175     /** Size of the rendering surface. */
       
   176     TSize iSize;
       
   177     
       
   178     /** The currently bound texture */
       
   179     const MHuiSegmentedTexture* iBoundTexture;
       
   180 
       
   181 private:
       
   182     /** Session id */
       
   183     TInt iSessionId;
       
   184     
       
   185     };
       
   186 
       
   187 
       
   188 #endif // __HUIVG10RENDERSURFACE_H__