os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/pixelutil.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/pixelutil.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,104 @@
     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 +#ifndef PIXELUTIL_H
    1.20 +#define PIXELUTIL_H
    1.21 +
    1.22 +/**
    1.23 +@file
    1.24 +@internalComponent
    1.25 +*/
    1.26 +
    1.27 +#include <e32cmn.h>
    1.28 +#include <gdi.h>
    1.29 +#include <pixelformats.h>
    1.30 +
    1.31 +/**
    1.32 +Provides conversion between TDisplayMode/TUidPixelFormat and other pixel format related functionality.
    1.33 +*/
    1.34 +NONSHARABLE_STRUCT(PixelFormatUtil)
    1.35 +	{
    1.36 +	static TUidPixelFormat ConvertToPixelFormat(TDisplayMode aDisplayMode);
    1.37 +	static TBool HasAlpha(TUidPixelFormat aPixelFormat);
    1.38 +	static TInt BitsPerPixel(TUidPixelFormat aPixelFormat);
    1.39 +	static TDisplayMode ConvertToDisplayMode(TUidPixelFormat aPixelFormat);
    1.40 +	};
    1.41 +
    1.42 +/**
    1.43 +Provides access to the contents of a pixel buffer. Functionality includes copying pixels into 
    1.44 +user buffer and perform format conversion or scaling up/down. Copying can be performed 
    1.45 +horizontally from left to right  or right to left, and vertically from top to bottom or bottom
    1.46 +to up.
    1.47 +
    1.48 +Supported buffer pixel format:
    1.49 +-EUidPixelFormatRGB_565
    1.50 +-EUidPixelFormatXRGB_8888
    1.51 +-EUidPixelFormatARGB_8888
    1.52 +-EUidPixelFormatARGB_8888_PRE
    1.53 +
    1.54 +Supported read pixel format:
    1.55 +-EUidPixelFormatRGB_565
    1.56 +-EUidPixelFormatXRGB_8888
    1.57 +-EUidPixelFormatARGB_8888
    1.58 +-EUidPixelFormatARGB_8888_PRE
    1.59 +*/
    1.60 +NONSHARABLE_CLASS(TPixelBufferReader)
    1.61 +	{
    1.62 +public:
    1.63 +	enum TReadDirection
    1.64 +		{
    1.65 +		EReadHorizontal,
    1.66 +		EReadHorizontalReverse,
    1.67 +		EReadVertical,
    1.68 +		EReadVerticalReverse
    1.69 +		};
    1.70 +
    1.71 +	TPixelBufferReader(const TUint32* aPixelBuffer, const TSize& aSize, TInt aStride,TUidPixelFormat aFormat);
    1.72 +
    1.73 +	void GetScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen,
    1.74 +			TUidPixelFormat aReadFormat, TReadDirection aReadDir) const;
    1.75 +	void GetScaledScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    1.76 +			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    1.77 +			TReadDirection aReadDir) const;
    1.78 +
    1.79 +	const TUint32* GetPixelAddr(const TPoint& aPos) const;
    1.80 +
    1.81 +private:
    1.82 +	TPixelBufferReader(); //declare but not defined
    1.83 +	const TUint32* GetScanLineAddr(TInt aRow) const;
    1.84 +
    1.85 +	void GetScanLineRGB_565(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    1.86 +	void GetScanLineXRGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    1.87 +	void GetScanLineARGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    1.88 +	void GetScanLineARGB_8888_PRE(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
    1.89 +
    1.90 +	void CopyFromRGB_565(TUint32* aDestPtr, const TUint16* aSrcPtr, TInt aLen, TInt aAdvance) const;
    1.91 +	TInt GetAdvance(TReadDirection aReadDir) const;
    1.92 +
    1.93 +	void GetScaledScanLineH(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    1.94 +			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    1.95 +			TReadDirection aReadDir) const;
    1.96 +	void GetScaledScanLineV(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
    1.97 +			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
    1.98 +			TReadDirection aReadDir) const;
    1.99 +
   1.100 +private:
   1.101 +	const TUint32* iBuffer;
   1.102 +	TSize iSize;
   1.103 +	TInt iStride;
   1.104 +	TUidPixelFormat iFormat;
   1.105 +	};
   1.106 +
   1.107 +#endif /*PIXELUTIL_H*/