os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/pixelutil.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef PIXELUTIL_H
sl@0
    17
#define PIXELUTIL_H
sl@0
    18
sl@0
    19
/**
sl@0
    20
@file
sl@0
    21
@internalComponent
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include <e32cmn.h>
sl@0
    25
#include <gdi.h>
sl@0
    26
#include <pixelformats.h>
sl@0
    27
sl@0
    28
/**
sl@0
    29
Provides conversion between TDisplayMode/TUidPixelFormat and other pixel format related functionality.
sl@0
    30
*/
sl@0
    31
NONSHARABLE_STRUCT(PixelFormatUtil)
sl@0
    32
	{
sl@0
    33
	static TUidPixelFormat ConvertToPixelFormat(TDisplayMode aDisplayMode);
sl@0
    34
	static TBool HasAlpha(TUidPixelFormat aPixelFormat);
sl@0
    35
	static TInt BitsPerPixel(TUidPixelFormat aPixelFormat);
sl@0
    36
	static TDisplayMode ConvertToDisplayMode(TUidPixelFormat aPixelFormat);
sl@0
    37
	};
sl@0
    38
sl@0
    39
/**
sl@0
    40
Provides access to the contents of a pixel buffer. Functionality includes copying pixels into 
sl@0
    41
user buffer and perform format conversion or scaling up/down. Copying can be performed 
sl@0
    42
horizontally from left to right  or right to left, and vertically from top to bottom or bottom
sl@0
    43
to up.
sl@0
    44
sl@0
    45
Supported buffer pixel format:
sl@0
    46
-EUidPixelFormatRGB_565
sl@0
    47
-EUidPixelFormatXRGB_8888
sl@0
    48
-EUidPixelFormatARGB_8888
sl@0
    49
-EUidPixelFormatARGB_8888_PRE
sl@0
    50
sl@0
    51
Supported read pixel format:
sl@0
    52
-EUidPixelFormatRGB_565
sl@0
    53
-EUidPixelFormatXRGB_8888
sl@0
    54
-EUidPixelFormatARGB_8888
sl@0
    55
-EUidPixelFormatARGB_8888_PRE
sl@0
    56
*/
sl@0
    57
NONSHARABLE_CLASS(TPixelBufferReader)
sl@0
    58
	{
sl@0
    59
public:
sl@0
    60
	enum TReadDirection
sl@0
    61
		{
sl@0
    62
		EReadHorizontal,
sl@0
    63
		EReadHorizontalReverse,
sl@0
    64
		EReadVertical,
sl@0
    65
		EReadVerticalReverse
sl@0
    66
		};
sl@0
    67
sl@0
    68
	TPixelBufferReader(const TUint32* aPixelBuffer, const TSize& aSize, TInt aStride,TUidPixelFormat aFormat);
sl@0
    69
sl@0
    70
	void GetScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen,
sl@0
    71
			TUidPixelFormat aReadFormat, TReadDirection aReadDir) const;
sl@0
    72
	void GetScaledScanLine(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
sl@0
    73
			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
sl@0
    74
			TReadDirection aReadDir) const;
sl@0
    75
sl@0
    76
	const TUint32* GetPixelAddr(const TPoint& aPos) const;
sl@0
    77
sl@0
    78
private:
sl@0
    79
	TPixelBufferReader(); //declare but not defined
sl@0
    80
	const TUint32* GetScanLineAddr(TInt aRow) const;
sl@0
    81
sl@0
    82
	void GetScanLineRGB_565(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
sl@0
    83
	void GetScanLineXRGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
sl@0
    84
	void GetScanLineARGB_8888(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
sl@0
    85
	void GetScanLineARGB_8888_PRE(TDes8& aReadBuf, const TPoint& aReadPos, TInt aReadLen, TReadDirection aReadDir) const;
sl@0
    86
sl@0
    87
	void CopyFromRGB_565(TUint32* aDestPtr, const TUint16* aSrcPtr, TInt aLen, TInt aAdvance) const;
sl@0
    88
	TInt GetAdvance(TReadDirection aReadDir) const;
sl@0
    89
sl@0
    90
	void GetScaledScanLineH(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
sl@0
    91
			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
sl@0
    92
			TReadDirection aReadDir) const;
sl@0
    93
	void GetScaledScanLineV(TDes8& aReadBuf, const TPoint& aReadPos, TInt aClipDestPos,
sl@0
    94
			TInt aClipDestLen, TInt aDestLen, TInt aSrcLen, TUidPixelFormat aReadFormat,
sl@0
    95
			TReadDirection aReadDir) const;
sl@0
    96
sl@0
    97
private:
sl@0
    98
	const TUint32* iBuffer;
sl@0
    99
	TSize iSize;
sl@0
   100
	TInt iStride;
sl@0
   101
	TUidPixelFormat iFormat;
sl@0
   102
	};
sl@0
   103
sl@0
   104
#endif /*PIXELUTIL_H*/