egl/egltest/endpointtestsuite/automated/tinc/egltest_surface.h
changeset 98 bf7481649c98
child 136 62bb7c97884c
equal deleted inserted replaced
85:cdf2f6e5c390 98:bf7481649c98
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "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 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #ifndef __EGLTEST_SURFACE_H__
       
    23 #define __EGLTEST_SURFACE_H__
       
    24 
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <w32std.h>
       
    28 #include <graphics/surface.h>
       
    29 #include <graphics/surfacemanager.h>
       
    30 #include <graphics/surfaceupdateclient.h>
       
    31 #include <graphics/suerror.h>
       
    32 #include <EGL/egl.h>
       
    33 
       
    34 enum TSurfaceType
       
    35     {
       
    36     ESurfTypeRaw,
       
    37     ESurfTypeEglWindow,
       
    38     ESurfTypeRawSingleBuffered,
       
    39     ESurfTypeMaxTypes  // Should be the last enum.
       
    40     };
       
    41 
       
    42 // Index to Surface Parameters.
       
    43 enum TSurfaceIndex
       
    44     {
       
    45     EStandardSurface,
       
    46     EBadAttribSurface,
       
    47     EEmptyAttribSurface,
       
    48     EStandard128sqSurface,
       
    49     EUnusualStrideSurface,
       
    50     EUnalignedPixelSizeSurface,
       
    51     ELargeSurface,
       
    52     };
       
    53 
       
    54 // Notification enums - allows us to use one function to request several notifications.
       
    55 enum TNotification
       
    56     {
       
    57     ENotifyWhenAvailable,
       
    58     ENotifyWhenDisplayed,
       
    59     ENotifyWhenDispXTimes,
       
    60     };
       
    61 
       
    62 const TInt KNumAttribs = 3;
       
    63 
       
    64 // Common between local and remote
       
    65 struct TSurfaceParamsCommon
       
    66     {
       
    67     TSurfaceIndex iIndex;   // Check that it matches - or we've got the table wrong.
       
    68     TInt iXSize, iYSize;
       
    69     TInt iBuffers;
       
    70     TInt iAlignment;
       
    71     TInt iStrideInBytes;
       
    72     TInt iOffsetToFirstBuffer;
       
    73     TUidPixelFormat iPixelFormat;
       
    74     TBool iUseAttribList; //when false use NULL in at attribute parameter
       
    75     EGLint iAttribs[KNumAttribs];
       
    76     // Window info.
       
    77     TInt iXPos, iYPos;
       
    78     TDisplayMode iDisplayMode;
       
    79     };
       
    80 
       
    81 struct TSurfaceParamsRemote
       
    82     {
       
    83     TSurfaceId           iSurfaceId;
       
    84     TSurfaceParamsCommon iCommonParams;
       
    85     TSurfaceType         iSurfaceType;
       
    86     };
       
    87 
       
    88 
       
    89 //Interface for creating, drawing to and submitting content for a surface
       
    90 //Derived classes can implement different types of surface, that can be
       
    91 //used in the same test code. Ie surface manager surface (raw), egl window
       
    92 //surface, video surface, viewfinder surface.
       
    93 class CSurface: public CBase
       
    94     {
       
    95 public:
       
    96     virtual void CreateL(TInt aIndex) = 0;
       
    97     virtual void DrawContentL(TInt aImageIndex) = 0;
       
    98     virtual void DrawContentL(const TRgb& aColour) = 0;
       
    99     virtual void SubmitContentL(TBool aShouldWaitForDisplay, TInt aRectIndex = 0) = 0;
       
   100     virtual TSurfaceId SurfaceId() const = 0;
       
   101     virtual void GetSurfaceParamsL(TSurfaceParamsRemote &aParams) = 0;
       
   102     virtual const TText *GetSurfaceTypeStr() const = 0;
       
   103     virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes) = 0;
       
   104     virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp) = 0;
       
   105 
       
   106 public:
       
   107     // Factory function to create a surface of aSurfType.
       
   108     static CSurface *SurfaceFactoryL(TSurfaceType aSurfType);
       
   109 protected:
       
   110     TInt iParamIndex;
       
   111     };
       
   112 
       
   113 
       
   114 //Raw surface implements CSurface for basic surface manager surface.
       
   115 class CRawSurface : public CSurface
       
   116     {
       
   117 public:
       
   118     static CRawSurface* NewL();
       
   119     ~CRawSurface();
       
   120 
       
   121     //From CSurface.
       
   122     void CreateL(TInt aIndex);
       
   123     void GetSurfAttribs(RSurfaceManager::TSurfaceCreationAttributesBuf &aSurfaceAttribs, TInt aIndex);
       
   124     void DrawContentL(TInt aIndex);
       
   125     void DrawContentL(const TRgb& aColour);
       
   126     void SubmitContentL(TBool aShouldWaitForDisplay, TInt aRectIndex = 0);
       
   127     TSurfaceId SurfaceId() const;
       
   128     void GetSurfaceParamsL(TSurfaceParamsRemote &aParams);
       
   129     virtual const TText *GetSurfaceTypeStr() const;
       
   130     virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes);
       
   131     virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp);
       
   132 
       
   133 protected:
       
   134     CRawSurface();
       
   135     void ConstructL();
       
   136     TUint8* MapSurfaceAndGetInfoLC(RSurfaceManager::TSurfaceInfoV01& aInfo);
       
   137 
       
   138 private:
       
   139     static TInt PixelSize(TUidPixelFormat aPixelFormat);
       
   140     static TRequestStatus *GetRequestPtr(TNotification aWhen);
       
   141 
       
   142 private:
       
   143     RSurfaceUpdateSession iSurfaceUpdate;
       
   144     TRequestStatus        iAvailable;
       
   145     TRequestStatus        iDisplayed;
       
   146     TRequestStatus        iDisplayedXTimes;
       
   147     TTimeStamp            iTimeStamp;
       
   148     TInt                  iDrawBuffer;
       
   149     RChunk                iSurfaceChunk;
       
   150 
       
   151 protected:
       
   152     TInt                  iBuffers;
       
   153     RSurfaceManager       iSurfaceManager;
       
   154     TSurfaceId            iSurfaceId;
       
   155     };
       
   156 
       
   157 // Simple wrapper to enable a list of "singlebuffer" in the list of buffer types.
       
   158 class CRawSingleBufferSurface : public CRawSurface
       
   159     {
       
   160 public:
       
   161     static CRawSingleBufferSurface* NewL();
       
   162     ~CRawSingleBufferSurface();
       
   163 
       
   164     //From CSurface.
       
   165     void CreateL(TInt aIndex);
       
   166     virtual const TText *GetSurfaceTypeStr() const;
       
   167     };
       
   168 
       
   169 // Forward declare classes that we do not need to know the content of.
       
   170 class CWindow;
       
   171 class CTestVgImage;
       
   172 
       
   173 class CEglWindowSurface : public CSurface
       
   174     {
       
   175 public:
       
   176     static CEglWindowSurface* NewL();
       
   177     ~CEglWindowSurface();
       
   178 
       
   179     void CreateL(TInt aIndex);
       
   180     void DrawContentL(TInt aImageIndex);
       
   181     void DrawContentL(const TRgb& aColour);
       
   182     void SubmitContentL(TBool aShouldWaitForDisplay, TInt aRectIndex = 0);
       
   183     void ActivateL();
       
   184     TSurfaceId SurfaceId() const;
       
   185     void GetSurfaceParamsL(TSurfaceParamsRemote &aParams);
       
   186     virtual const TText *GetSurfaceTypeStr() const;
       
   187     virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes);
       
   188     virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp);
       
   189 
       
   190 private:
       
   191     CEglWindowSurface();
       
   192     void ConstructL();
       
   193 
       
   194 private:
       
   195     EGLContext iContext;
       
   196     EGLSurface iSurface;
       
   197     EGLDisplay iDisplay;
       
   198     CWindow*   iWindow;
       
   199     };
       
   200 
       
   201 
       
   202 
       
   203 #endif