os/mm/mm_plat/display_posting_api/inc/Posting_Surface.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 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:     Header file for S60 display posting API
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 
    22 #ifndef __POSTING_SURFACE_H__
    23 #define __POSTING_SURFACE_H__
    24 
    25 //- Include Files  ----------------------------------------------------------
    26 
    27 #include <e32base.h>
    28 #include <e32cmn.h>
    29 #include <gdi.h>
    30 
    31 //- Namespace ---------------------------------------------------------------
    32 
    33 //- Constants ---------------------------------------------------------------
    34 
    35 ///Little endian bit mask
    36 const TUint KPostFormatLE    = 0x01000000;
    37 ///Big endian bit mask
    38 const TUint KPostFormatBE    = 0x02000000;
    39 ///Color range 0-255 bit mask
    40 const TUint KPostColorRange0 = 0x00000010;
    41 ///Color range 16-235 bit mask
    42 const TUint KPostColorRange1 = 0x00000020;
    43 ///ITU-R BT.709-5 standard bit mask
    44 const TUint KPost709         = 0x00000100;
    45 ///ITU-R BT.601-5 standard bit mask
    46 const TUint KPost601         = 0x00000200;
    47 ///Posting RGB format RGB565 bit mask
    48 const TUint KPostRGB565      = 0x00000001;
    49 ///Posting RGB format RGB888 (24bit) bit mask
    50 const TUint KPostRGB888      = 0x00000002;
    51 ///Posting RGB format RGBx888 (32bit) bit mask
    52 const TUint KPostRGBx888     = 0x00000004;
    53 ///Posting YUV 420 Planar format
    54 const TUint KPostYUV420Planar= 0x00001000;
    55 ///Platform specific
    56 const TUint KPostPlatformDependent = 0x10000000;
    57 
    58 //- Forward Declarations ----------------------------------------------------
    59 
    60 class CPostingSurface;
    61 class TPostingBuff;
    62 
    63 //- Class Definitions -------------------------------------------------------
    64 /**
    65 *  CPostingSurface
    66 *
    67 *  Contains core data structures and member functions in the display posting API
    68 */
    69 class CPostingSurface : public CBase
    70 {
    71 public:
    72 
    73     /**
    74     *  TPostingFormat
    75     *
    76     *  Specifies the data format. Also sampling pattern, data layout and YUV-RGB conversion coefficients for YUV data.
    77     */
    78     enum TPostingFormat
    79     {
    80             EFormatInvalidValue   = 0x00000000,     //Initialisation value, do not use
    81             ERgb16bit565Le        = KPostRGB565  | KPostFormatLE,
    82             ERgb24bit888Le        = KPostRGB888  | KPostFormatLE,
    83             ERgb32bit888Le        = KPostRGBx888 | KPostFormatLE,
    84             EYuv422LeBt709Range0  = KPost709     | KPostFormatLE | KPostColorRange0,
    85             EYuv422LeBt709Range1  = KPost709     | KPostFormatLE | KPostColorRange1,
    86             EYuv422BeBt709Range0  = KPost709     | KPostFormatBE | KPostColorRange0,
    87             EYuv422BeBt709Range1  = KPost709     | KPostFormatBE | KPostColorRange1,
    88             EYuv422LeBt601Range0  = KPost601     | KPostFormatLE | KPostColorRange0,
    89             EYuv422LeBt601Range1  = KPost601     | KPostFormatLE | KPostColorRange1,
    90             EYuv422BeBt601Range0  = KPost601     | KPostFormatBE | KPostColorRange0,
    91             EYuv422BeBt601Range1  = KPost601     | KPostFormatBE | KPostColorRange1,
    92             EYuv420PlanarBt709Range0 = KPost709     | KPostYUV420Planar | KPostColorRange0,
    93             EYuv420PlanarBt709Range1 = KPost709     | KPostYUV420Planar | KPostColorRange1,
    94             EYuv420PlanarBt601Range0 = KPost601     | KPostYUV420Planar | KPostColorRange0,
    95             EYuv420PlanarBt601Range1 = KPost601     | KPostYUV420Planar | KPostColorRange1,
    96             EYuvPlatformDependent    = KPostPlatformDependent,
    97             };
    98 
    99 
   100     /**
   101     *  TRotationType
   102     *
   103     *  Rotation types as defined in [MDF Video Common Elements]
   104     */
   105     enum TRotationType
   106     {
   107             ENoRotation            = 0x00000000, //0Deg
   108             ERotate90ClockWise     = 0x00000001, //90Deg
   109             ERotate180             = 0x00000002, //180Deg
   110             ERotate90AntiClockWise = 0x00000004, //270Deg
   111             };
   112 
   113 
   114     /**
   115     *  TPostingBuffering
   116     *
   117     *  Bitmask value describing how the display posting is done and how the frames should be handled.
   118     */
   119     enum TPostingBuffering
   120     {
   121             EBufferingInvalid  = 0x00000000,    //Initialisation value, do not use
   122             ESingleBuffering   = 0x00000004,
   123             EDoubleBuffering   = 0x00000001,
   124             ETripleBuffering   = 0x00000002,
   125             EProgressiveFrames = 0x00000010,
   126             EInterlacedFrames  = 0x00000020,
   127             EDisAllowFrameSkip = 0x00000100,
   128             EAllowFrameSkip    = 0x00000200,
   129             EInternalBuffers   = 0x00001000,
   130             EExternalBuffers   = 0x00002000,
   131             };
   132 
   133 
   134     /**
   135     *  TPostageUsageHint
   136     *
   137     *  Tells the intended usage of the posting surface. The display driver uses these hints to prioritize the HW usage and route content.
   138     *  Vendor specific meanings may be added to the end of the enum space.
   139     */
   140     enum TPostingUsageHint
   141     {
   142             EUsageInvalid   = 0x00000000,   //Initialisation value, do not use
   143             EGeneric        = 0x00000001,
   144             E3D             = 0x00000002,
   145             EVideoPlayback  = 0x00000004,
   146             EVideoCapture   = 0x00000008,
   147             EViewfinder     = 0x00000010,
   148             EStillImage     = 0x00000011,
   149             EVendorSpecific = 0x80000000,
   150             };
   151 
   152     /**
   153     *  TPostingCapab
   154     *
   155     *  Describes the Posting buffer size restrictions and posting processing capabilities.
   156     */
   157     class TPostingCapab
   158     {
   159         public:
   160 
   161             inline TPostingCapab();
   162 
   163         public:
   164             /** Maximum buffer size in bytes */
   165             TUint iMaxSourceSize;
   166 
   167             /** Hw limits for source size, normally cannot allocated whole this size */
   168             TSize iMaxPixelSize;
   169 
   170             /** Bit mask of supported rotations */
   171             TUint iSupportedRotations;
   172 
   173             /** ETrue when horizontal mirroring is supported */
   174             TBool iSupportsMirroring;
   175 
   176             /** ETrue when rational scales is supported */
   177             TBool iSupportsScaling;
   178 
   179             /** ETrue when brightness tuning is supported */
   180             TBool iSupportsBrightnessControl;
   181 
   182             /** ETrue when contrast tuning is supported */
   183             TBool iSupportsContrastControl;
   184 
   185             /** Bitmask (TPostingBuffering) */
   186             TUint iSupportedPostingBuffering;
   187 
   188             /** Bitmask (TBufferType) */
   189             TUint iSupportedBufferTypes;
   190     };
   191 
   192     enum TBufferType
   193     {
   194             EBufferTypeInvalid = 0x00000000,    //Initialisation value, do not use
   195             EStandardBuffer    = 0x00000001,    //Direct address
   196             EChunkBuffer       = 0x00000002,//RChunk handle
   197             EExternalBuffer    = 0x00000004,//External buffers
   198     };
   199 
   200     /**
   201     *  TPostingSourceParams
   202     *
   203     *  Describes the source content and buffering parameters. These values are fixed in the initialization phase.
   204     */
   205     class TPostingSourceParams
   206     {
   207         public:
   208                 inline TPostingSourceParams();
   209 
   210         public:
   211             /** Buffering usage mode (TPostingBuffering) */
   212             TUint iPostingBuffering;
   213 
   214             /** Indicates the type of buffer requested */
   215             TBufferType iBufferType;
   216 
   217             /** Purpose of buffer (TPostingUsageHint) */
   218             TUint iPostingUsage;
   219 
   220             /** Source resolution. Values must be even */
   221             TSize iSourceImageSize;
   222 
   223             /** Source's pixel format */
   224             TPostingFormat iPostingFormat;
   225 
   226             /** Source pixel aspect ratio (width), Scaling factor = Numerator/Denominator. Tv out only */
   227             TUint16 iPixelAspectRatioNum;
   228 
   229             /** Source pixel aspect ratio (width) */
   230             TUint16 iPixelAspectRatioDenom;
   231 
   232             /**
   233             *  ETrue when copy protection enabled
   234             *  indicates if the content has copy protection restrictions. true: Restricted
   235             */
   236             TBool iContentCopyRestricted;
   237     };
   238 
   239 
   240     /**
   241     *  TPostingParams
   242     *
   243     *  Speficies window properties and required processing types for the posting buffer before it can be displayed on the screen.
   244     */
   245     class TPostingParams
   246     {
   247         public:
   248 
   249             inline TPostingParams();
   250 
   251         public:
   252             /** Size and position of the rectangle on phone's display. Even. Ui-orientation parameters.
   253             *   Does not affect Tv-out
   254             */
   255             TRect iDisplayedRect;
   256 
   257 			/** Output size in pixels, defines scaling.  Relative to iDisplayedRect and must not
   258 			*   exceed those boundaries
   259 			*/
   260 			TRect iScaleToRect;
   261         
   262             /** Required cropping for the content before applying other processing. Even.
   263             *   This is <= iSourceImageSize. This is Tv-out crop too
   264             */
   265             TRect iInputCrop;
   266 
   267             /** ETrue when horizontal mirroring. Does not affect Tv-out */
   268             TBool iMirror;
   269             /** Orientation of content compared to symbian videobuffer. Does not affect Tv-out */
   270             TRotationType iRotation;
   271 
   272             /** Brightness value on screen, [-100,100]%, may be ignored by the driver */
   273             TInt16 iBrightness;
   274 
   275             /** Contrast value on screen, [-100,100]% */
   276             TInt16 iContrast;
   277 
   278             /** Defined background color. Give in same format what symbian videobuffer currently is */
   279             TRgb iBackGround;
   280     };
   281 
   282 
   283     /**
   284     *  TPostingBuff
   285     *
   286     *  Contains information about the posting buffer.
   287     */
   288     class TPostingBuff
   289     {
   290         public:
   291             /** @return EBufferTypeInvalid or EChunkBuffer (iType) */
   292             IMPORT_C virtual TBufferType GetType();
   293 
   294             /** @return Direct address of buffer (0,0) (iBuffer) */
   295             IMPORT_C virtual TAny* GetBuffer();
   296 
   297             /** @return buffer size in pixels */
   298             IMPORT_C virtual TSize GetSize();
   299 
   300             /** @return scanline length in bytes (width*bytes_per_pixel + some_offset) */
   301             IMPORT_C virtual TUint GetStride();
   302 
   303         protected:
   304             /** Hidden constructor, user should never use this */
   305             IMPORT_C TPostingBuff();
   306 
   307         protected:
   308             /** Type of this TPostingBuff */
   309             TBufferType iType;
   310 
   311             /** Pointer to buffer */
   312             TAny*  iBuffer;
   313 
   314             /** Size of frame in pixels */
   315             TSize  iSize;
   316 
   317             /** Scanline length in bytes (width*bytes_per_pixel + some_offset) */
   318             TUint iStride;
   319     };
   320 
   321     /**
   322 	* TPostingBuffExt
   323 	*
   324     * Extension for TPostingBuff class. Allows external buffers to be set.
   325     */
   326     class TPostingBuffExt : public TPostingBuff
   327         {
   328         public:
   329             ///Set pointer to external buffer
   330             IMPORT_C virtual void SetBuffer(TAny* aBuffer);
   331             ///Set size of buffer in pixels
   332             IMPORT_C virtual void SetSize(TSize aSize);
   333             ///Set scanline length in bytes
   334             IMPORT_C virtual void SetStride(TUint aStride);
   335         protected:
   336             ///Hidden constructor, user should never use this
   337             IMPORT_C TPostingBuffExt();
   338         };
   339 
   340     /**
   341     *  TPostingBufferChunk
   342     *
   343     *  the chunk buffer should be requested by the client if the client application must pass the buffer across a process boundary.
   344     */
   345     class TPostingBufferChunk : public TPostingBuff
   346     {
   347         public:
   348             /** @return Handle to DChunk (iChunk) */
   349             IMPORT_C virtual RChunk GetChunk();
   350 
   351             /** @return buffer start address offset in chunk, (iOffsetInChunk) */
   352             IMPORT_C virtual TUint GetOffsetInChunk();
   353 
   354         protected:
   355             /** Hidden constructor */
   356             IMPORT_C TPostingBufferChunk();
   357 
   358         protected:
   359             /** Handle to DChunk */
   360             RChunk iChunk;
   361 
   362             /** Offset in chunk, to first pixel */
   363             TUint iOffsetInChunk;
   364     };
   365 
   366     public:
   367     /** Object destructor */
   368     virtual ~CPostingSurface(){};
   369 
   370     /**
   371     *   Initialises API for given parameters, and reserving posting for user (limited amount).
   372     *   If all success and aSource&aDest are filled correctly, posting is ready to use.
   373     *   @param  aSource  Source buffer information.
   374     *   @param  aDest    Destination parameters, @see CPostingSurface::SetPostingParameters
   375     *   @return Leaves when failed, with standard symbian error code
   376     */
   377     virtual void InitializeL(const TPostingSourceParams& aSource, const TPostingParams& aDest) = 0;
   378 
   379     /**
   380     *  Returns posting API provided properties to parameter
   381     *  @param aCaps Supported features, filled by driver
   382     *  @return KErrNone if success
   383     */
   384     virtual void GetCapabilities(TPostingCapab& aCaps) = 0;
   385 
   386     /**
   387     *  Queries the underlying implementation about its capability to process proposed input format.
   388     *  @param aFormat Format what to be asked.
   389     *  @return ETrue when aFormat is supported, otherwise EFalse
   390     */
   391     virtual TBool FormatSupported(TPostingFormat aFormat) = 0;
   392 
   393     /**
   394     *  Asynchronous freeing of reservation of posting.
   395     *  @param  aComplete -parameter is status of destroying, driver completes it when complete
   396     */
   397     virtual void  Destroy ( TRequestStatus& aComplete)= 0;
   398 
   399     /**
   400     *  Synchronic version of Destroy(TRequestStatus& aComplete),
   401     *  Note, this method can take same time what previous version takes
   402     */
   403     virtual void Destroy() = 0;
   404 
   405     /**
   406     *  Starts a wait for next free buffer
   407     *  It is allowed for an application to wait and acquire
   408     *  two or more buffers before actually posting the buffers.
   409     *  However, only one wait for next free buffer can be active at the time (!).
   410     *  @param  aComplete  Request to be complete when next buffer is available.
   411     *  @return KErrNone if success
   412     */
   413     virtual TInt WaitForNextBuffer(TRequestStatus& aComplete) = 0;
   414 
   415     /**
   416     *  Gets the next free buffer (must have been waited with WaitForNextBuffer()
   417     *  for before calling this!).
   418     *  @return  Next available buffer settings for user
   419     */
   420     virtual TPostingBuff* NextBuffer() = 0;
   421 
   422     /** Cancels the wait for the next free buffer. Can be ingnored by driver */
   423     virtual TInt CancelBuffer() = 0;
   424 
   425     /**
   426     *  Posts buffer previously got from the API.
   427     *  @param  aBuffer  Buffer object where driver to continues updating
   428     *  @return KErrNone if success
   429     */
   430     virtual TInt PostBuffer(TPostingBuff* aBuffer) = 0;
   431 
   432     /**
   433     *  This function can be used to change window
   434     *  properties and required processing types for the posting
   435     *  buffer before it can be displayed on the screen.
   436     *  Perhaps some limititations of parameter change can exists, then this fails.
   437     *  @param   aParams  New destination settings of Posting
   438     *  @return  KErrNone if success
   439     */
   440     virtual TInt SetPostingParameters(const TPostingParams& aParams) = 0;
   441 
   442     /**
   443     *  This function can be used to directly pass the DSA-region
   444     *  of the internal display down to this API if DSA-region is
   445     *  clipped in some way. Some implementations may support none:
   446     *  some may support only one or few clipping regions.
   447     *  In those cases the return value can be KErrNotSupported.
   448     *  If clipping region is supported, no image will be drawn outside
   449     *  of the clipping region.
   450     *  If iDisplayedRect is set to an empty region, then the posting is not
   451     *  active for the internal display. However, if display posting is still done,
   452     *  external display may get updated. Default: no clipping is done,
   453     *  but internal display is enabled.
   454     *  @param  aClipRegion  Rectangles of current DSA.
   455     *  @return  KErrNone if success
   456     */
   457     virtual TInt SetClipRegion(const TRegion& aClipRegion) = 0;
   458 };
   459 
   460 //- Inline Functions --------------------------------------------------------
   461 
   462 #include "posting_surface.inl"
   463 
   464 #endif //__POSTING_SURFACE_H__
   465 
   466 // End of File