os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/pixelutil.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 #ifndef PIXELUTIL_H
    17 #define PIXELUTIL_H
    18 
    19 /**
    20 @file
    21 @internalComponent
    22 */
    23 
    24 #include <e32cmn.h>
    25 #include <gdi.h>
    26 #include <pixelformats.h>
    27 
    28 /**
    29 Provides conversion between TDisplayMode/TUidPixelFormat and other pixel format related functionality.
    30 */
    31 NONSHARABLE_STRUCT(PixelFormatUtil)
    32 	{
    33 	static TUidPixelFormat ConvertToPixelFormat(TDisplayMode aDisplayMode);
    34 	static TBool HasAlpha(TUidPixelFormat aPixelFormat);
    35 	static TInt BitsPerPixel(TUidPixelFormat aPixelFormat);
    36 	static TDisplayMode ConvertToDisplayMode(TUidPixelFormat aPixelFormat);
    37 	};
    38 
    39 /**
    40 Provides access to the contents of a pixel buffer. Functionality includes copying pixels into 
    41 user buffer and perform format conversion or scaling up/down. Copying can be performed 
    42 horizontally from left to right  or right to left, and vertically from top to bottom or bottom
    43 to up.
    44 
    45 Supported buffer pixel format:
    46 -EUidPixelFormatRGB_565
    47 -EUidPixelFormatXRGB_8888
    48 -EUidPixelFormatARGB_8888
    49 -EUidPixelFormatARGB_8888_PRE
    50 
    51 Supported read pixel format:
    52 -EUidPixelFormatRGB_565
    53 -EUidPixelFormatXRGB_8888
    54 -EUidPixelFormatARGB_8888
    55 -EUidPixelFormatARGB_8888_PRE
    56 */
    57 NONSHARABLE_CLASS(TPixelBufferReader)
    58 	{
    59 public:
    60 	enum TReadDirection
    61 		{
    62 		EReadHorizontal,
    63 		EReadHorizontalReverse,
    64 		EReadVertical,
    65 		EReadVerticalReverse
    66 		};
    67 
    68 	TPixelBufferReader(const TUint32* aPixelBuffer, const TSize& aSize, TInt aStride,TUidPixelFormat aFormat);
    69 
    70 	void GetScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen,
    71 			TUidPixelFormat aReadFormat, TReadDirection aReadDir) const;
    72 	void GetScaledScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    73 			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    74 			TReadDirection aReadDir) const;
    75 
    76 	const TUint32* GetPixelAddr(const TPoint& aPos) const;
    77 
    78 private:
    79 	TPixelBufferReader(); //declare but not defined
    80 	const TUint32* GetScanLineAddr(TInt aRow) const;
    81 
    82 	void GetScanLineRGB_565(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    83 	void GetScanLineXRGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    84 	void GetScanLineARGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    85 	void GetScanLineARGB_8888_PRE(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    86 
    87 	void CopyFromRGB_565(TUint32* aDestPtr, const TUint16* aSrcPtr, TInt aLen, TInt aAdvance) const;
    88 	TInt GetAdvance(TReadDirection aReadDir) const;
    89 
    90 	void GetScaledScanLineH(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    91 			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    92 			TReadDirection aReadDir) const;
    93 	void GetScaledScanLineV(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    94 			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    95 			TReadDirection aReadDir) const;
    96 
    97 private:
    98 	const TUint32* iBuffer;
    99 	TSize iSize;
   100 	TInt iStride;
   101 	TUidPixelFormat iFormat;
   102 	};
   103 
   104 #endif /*PIXELUTIL_H*/