os/graphics/egl/egltest/endpointtestsuite/automated/tinc/egltest_surface.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/endpointtestsuite/automated/tinc/egltest_surface.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,250 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#ifndef __EGLTEST_SURFACE_H__
    1.26 +#define __EGLTEST_SURFACE_H__
    1.27 +
    1.28 +
    1.29 +#include <e32base.h>
    1.30 +#include <w32std.h>
    1.31 +#include <graphics/surface.h>
    1.32 +#include <graphics/surfacemanager.h>
    1.33 +#include <graphics/surfaceupdateclient.h>
    1.34 +#include <graphics/suerror.h>
    1.35 +#include <EGL/egl.h>
    1.36 +
    1.37 +enum TSurfaceType
    1.38 +    {
    1.39 +    ESurfTypeRaw,
    1.40 +    ESurfTypeEglWindow,
    1.41 +    ESurfTypeRawSingleBuffered,
    1.42 +    ESurfTypePBuffer,
    1.43 +    ESurfTypeMaxTypes  // Should be the last enum.
    1.44 +    };
    1.45 +
    1.46 +// Index to Surface Parameters.
    1.47 +enum TSurfaceIndex
    1.48 +    {
    1.49 +    EStandardSurface,
    1.50 +    EBadAttribSurface,
    1.51 +    EEmptyAttribSurface,
    1.52 +    EStandard128sqSurface,
    1.53 +    EUnusualStrideSurface,
    1.54 +    EUnalignedPixelSizeSurface,
    1.55 +    ELargeSurface,
    1.56 +    ELargestPossibleSurface,
    1.57 +    ESmallSurface,
    1.58 +    ETinySurface
    1.59 +    };
    1.60 +
    1.61 +// Notification enums - allows us to use one function to request several notifications.
    1.62 +enum TNotification
    1.63 +    {
    1.64 +    ENotifyWhenAvailable,
    1.65 +    ENotifyWhenDisplayed,
    1.66 +    ENotifyWhenDispXTimes,
    1.67 +    };
    1.68 +
    1.69 +const TInt KNumAttribs = 3;
    1.70 +
    1.71 +// Common between local and remote
    1.72 +struct TSurfaceParamsCommon
    1.73 +    {
    1.74 +    TSurfaceIndex iIndex;   // Check that it matches - or we've got the table wrong.
    1.75 +    TInt iXSize, iYSize;
    1.76 +    TInt iBuffers;
    1.77 +    TInt iAlignment;
    1.78 +    TInt iStrideInBytes;
    1.79 +    TInt iOffsetToFirstBuffer;
    1.80 +    TUidPixelFormat iPixelFormat;
    1.81 +    TBool iUseAttribList; //when false use NULL in at attribute parameter
    1.82 +    EGLint iAttribs[KNumAttribs];
    1.83 +    // Window info.
    1.84 +    TInt iXPos, iYPos;
    1.85 +    TDisplayMode iDisplayMode;
    1.86 +    };
    1.87 +
    1.88 +struct TSurfaceParamsRemote
    1.89 +    {
    1.90 +    TSurfaceId           iSurfaceId;
    1.91 +    TSurfaceParamsCommon iCommonParams;
    1.92 +    TSurfaceType         iSurfaceType;
    1.93 +    };
    1.94 +
    1.95 +
    1.96 +
    1.97 +//Interface for creating, drawing to and submitting content for a surface
    1.98 +//Derived classes can implement different types of surface, that can be
    1.99 +//used in the same test code. Ie surface manager surface (raw), egl window
   1.100 +//surface, video surface, viewfinder surface.
   1.101 +class CSurface: public CBase
   1.102 +    {
   1.103 +public:
   1.104 +    // This function is kept for compatibility - new code should use offset
   1.105 +    // form of CreateL... 
   1.106 +    virtual void CreateL(TInt aIndex);
   1.107 +    // Allow an offset for the top left corner of the surface on screen. 
   1.108 +    virtual void CreateL(TInt aIndex, const TPoint& aOffset) = 0;
   1.109 +    virtual void DrawContentL(TInt aImageIndex) = 0;
   1.110 +    virtual void DrawContentL(const TRgb& aColour) = 0;
   1.111 +    virtual void DrawComplexL(const TRgb& aColour) = 0;
   1.112 +    virtual TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0) = 0;
   1.113 +    virtual TSurfaceId SurfaceId() const = 0;
   1.114 +    virtual void GetSurfaceParamsL(TSurfaceParamsRemote &aParams) = 0;
   1.115 +    virtual const TText *GetSurfaceTypeStr() const = 0;
   1.116 +    virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes) = 0;
   1.117 +    virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp) = 0;
   1.118 +    virtual TInt SizeInBytes() const;
   1.119 +   
   1.120 +    
   1.121 +    TSize Size();
   1.122 +
   1.123 +public:
   1.124 +    // Factory function to create a surface of aSurfType.
   1.125 +    static CSurface *SurfaceFactoryL(TSurfaceType aSurfType);
   1.126 +protected:
   1.127 +    TInt  iParamIndex;
   1.128 +    TSize iActualSize;
   1.129 +    };
   1.130 +
   1.131 +
   1.132 +//Raw surface implements CSurface for basic surface manager surface.
   1.133 +class CRawSurface : public CSurface
   1.134 +    {
   1.135 +public:
   1.136 +    static CRawSurface* NewL();
   1.137 +    ~CRawSurface();
   1.138 +
   1.139 +    // From CSurface
   1.140 +    virtual void CreateL(TInt aIndex, const TPoint& aOffset);
   1.141 +    void DrawContentL(TInt aIndex);
   1.142 +    void DrawContentL(const TRgb& aColour);
   1.143 +    void DrawComplexL(const TRgb& aColour);
   1.144 +    TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0);
   1.145 +    TSurfaceId SurfaceId() const;
   1.146 +    void GetSurfaceParamsL(TSurfaceParamsRemote &aParams);
   1.147 +    virtual const TText *GetSurfaceTypeStr() const;
   1.148 +    virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes);
   1.149 +    virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp);
   1.150 +
   1.151 +protected:
   1.152 +    CRawSurface();
   1.153 +    void ConstructL();
   1.154 +    TUint8* MapSurfaceAndGetInfoLC(RSurfaceManager::TSurfaceInfoV01& aInfo);
   1.155 +    void GetSurfAttribs(RSurfaceManager::TSurfaceCreationAttributesBuf &aSurfaceAttribs, TInt aIndex, TInt aSizeIndex);
   1.156 +
   1.157 +private:
   1.158 +    static TInt PixelSize(TUidPixelFormat aPixelFormat);
   1.159 +    static TRequestStatus *GetRequestPtr(TNotification aWhen);
   1.160 +
   1.161 +private:
   1.162 +    RSurfaceUpdateSession  iSurfaceUpdate;
   1.163 +    TRequestStatus         iAvailable;
   1.164 +    TRequestStatus         iDisplayed;
   1.165 +    TRequestStatus         iDisplayedXTimes;
   1.166 +    TTimeStamp             iTimeStamp;
   1.167 +    TInt                   iDrawBuffer;
   1.168 +    RChunk                 iSurfaceChunk;
   1.169 +
   1.170 +protected:
   1.171 +    TInt                   iBuffers;
   1.172 +    RSurfaceManager        iSurfaceManager;
   1.173 +    TSurfaceId             iSurfaceId;
   1.174 +    };
   1.175 +
   1.176 +// Simple wrapper to enable a list of "singlebuffer" in the list of buffer types.
   1.177 +class CRawSingleBufferSurface : public CRawSurface
   1.178 +    {
   1.179 +public:
   1.180 +    static CRawSingleBufferSurface* NewL();
   1.181 +    ~CRawSingleBufferSurface();
   1.182 +
   1.183 +    virtual void CreateL(TInt aIndex, const TPoint& aOffset);
   1.184 +    virtual const TText *GetSurfaceTypeStr() const;
   1.185 +    };
   1.186 +
   1.187 +// Forward declare classes that we do not need to know the content of.
   1.188 +class CWindow;
   1.189 +class CTestVgImage;
   1.190 +
   1.191 +class CEglSurfaceBase : public CSurface
   1.192 +    {
   1.193 +public:
   1.194 +    void CreateL(TInt aIndex, const TPoint& aOffset);
   1.195 +    void DrawContentL(TInt aImageIndex);
   1.196 +    void DrawContentL(const TRgb& aColour);
   1.197 +    void DrawComplexL(const TRgb& aColour);
   1.198 +    TInt SubmitContent(TBool aShouldWaitForDisplay, TInt aRectIndex = 0);
   1.199 +    TInt Activate();
   1.200 +    void ActivateL();
   1.201 +    void GetSurfaceParamsL(TSurfaceParamsRemote &aParams);
   1.202 +    virtual TInt Notify(TNotification aWhen, TRequestStatus &aStatus, TUint32 aXTimes);
   1.203 +    virtual TInt WaitFor(TNotification aWhen, TRequestStatus &aStatus, TInt aTimeoutInMicroseconds, TUint32& aTimeStamp);
   1.204 +
   1.205 +protected:
   1.206 +    void BaseCreateL(TInt aIndex, EGLint aSurfaceType);
   1.207 +    virtual void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex) = 0;
   1.208 +    void Destroy();
   1.209 +
   1.210 +protected:
   1.211 +    EGLContext iContext;
   1.212 +    EGLSurface iSurface;
   1.213 +    EGLDisplay iDisplay;
   1.214 +    EGLConfig  iConfig;
   1.215 +    };
   1.216 +
   1.217 +class CEglWindowSurface : public CEglSurfaceBase
   1.218 +    {
   1.219 +public:
   1.220 +    static CEglWindowSurface* NewL();
   1.221 +    ~CEglWindowSurface();
   1.222 +
   1.223 +    TSurfaceId SurfaceId() const;
   1.224 +    virtual const TText *GetSurfaceTypeStr() const;
   1.225 +
   1.226 +private:
   1.227 +    CEglWindowSurface();
   1.228 +    void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex);
   1.229 +    void ConstructL();
   1.230 +
   1.231 +private:
   1.232 +    CWindow*   iWindow;
   1.233 +    };
   1.234 +
   1.235 +class CEglPBufferSurface : public CEglSurfaceBase
   1.236 +    {
   1.237 +public:
   1.238 +    static CEglPBufferSurface* NewL();
   1.239 +    ~CEglPBufferSurface();
   1.240 +    TSurfaceId SurfaceId() const;
   1.241 +
   1.242 +    virtual const TText *GetSurfaceTypeStr() const;
   1.243 +
   1.244 +    TInt SizeInBytes() const;
   1.245 +
   1.246 +private:
   1.247 +    CEglPBufferSurface();
   1.248 +    void ConstructL();
   1.249 +    void DoCreateL(TInt aIndex, const TPoint& aOffset, TInt aSizeIndex);
   1.250 +    };
   1.251 +
   1.252 +
   1.253 +#endif