1.1 --- a/epoc32/include/graphics/blendingalgorithms.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,130 +0,0 @@
1.4 -// Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.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 __BLENDINGALGORITHMS_H__
1.20 -#define __BLENDINGALGORITHMS_H__
1.21 -
1.22 -#include <e32def.h>
1.23 -/**
1.24 -@file
1.25 -@internalTechnology
1.26 -*/
1.27 -
1.28 -/** Premultiplied Alpha (PMA) Blending algorithm.
1.29 -Assumes src and target pixels are in PMA format (i.e., the color channels are already multiplied
1.30 -with the alpha channel.
1.31 -Blending Equations:
1.32 -Cd' = Cs + ((255 - As) * Cd)/255
1.33 -Ad' = As + ((255 - As) * Ad)/255
1.34 -where Cd' and Ad' are destination values for color and alpha channels respectively, after blending,
1.35 -Cd and Ad are destination values before blending, and Cs and As are source values (color and
1.36 -alpha values respectively).
1.37 -Optimisations:
1.38 -Use of 256 instead of 255 converts the division to shift (faster).
1.39 -Red and Blue channels are calculated together in one 32 bit operation.
1.40 -Alpha and Green channels are calculated in the same way. However, due the
1.41 -position of these channels within the pixel format, an extra shift is required.
1.42 -The equations used are:
1.43 -Cd' = Cs + (((0x100 - As) * Cd)>>8)
1.44 -Ad' = As + (((0x100 - As) * Ad)>>8)
1.45 -For the results to not overflow, it is required that the value of any of the color channels
1.46 -is no greater than the alpha channel, which is what is exepected of pma format.
1.47 -It is also assumed that the aMask is equal to source alpha.
1.48 -@param aDestPixel The destination pixel value.
1.49 -@param aSrcPixel The source pixel value.
1.50 -@param aMask The source alpha. It is assumed to be same as source alpha.
1.51 -@return the alpha-blended pixel (within the PMA space).
1.52 -@internalTechnology
1.53 -@released
1.54 -*/
1.55 -inline TUint32 PMAPixelBlend(TUint32 aDestPixel, TUint32 aSrcPixel, TUint8 aMask);
1.56 -
1.57 -/** Same as inline TUint32 PMAPixelBlend(TUint32 aDestPixel, TUint32 aSrcPixel, TUint8 aMask)
1.58 -Calls inline TUint32 PMAPixelBlend(TUint32 aDestPixel, TUint32 aSrcPixel, TUint8 aMask), with aMask
1.59 -extracted from the source pixel.
1.60 -@see PMAPixelBlend(TUint32 aDestPixel, TUint32 aSrcPixel, TUint8 aMask)
1.61 -@internalTechnology
1.62 -@released
1.63 -*/
1.64 -inline TUint32 PMAPixelBlend(TUint32 aDestPixel, TUint32 aSrcPixel);
1.65 -
1.66 -/**
1.67 -Does the premultiplied alpha blend, but does not check for any pre/post conditions.
1.68 -Please DO NOT Add any optimisations to check for these conditions in this code!
1.69 -@internalTechnology
1.70 -@released
1.71 -*/
1.72 -inline TUint32 PMABlend_noChecks(TUint32 aDestPixel, TUint32 aSrcPixel, TUint8 aMaskingFactor);
1.73 -
1.74 -/**
1.75 -The version of PMABlend_noChecks which does the blending in place.
1.76 -@internalTechnology
1.77 -@released
1.78 -*/
1.79 -inline void PMABlend_noChecksInplace(TUint32& aDest_io, TUint32& aSrcPixel,TUint8& aMaskingFactor);
1.80 -
1.81 -/**
1.82 -The in-place version of the PMAPixelBlend algorithm
1.83 -@internalTechnology
1.84 -@released
1.85 -*/
1.86 -inline void PMAInplaceBlend(TUint32& aDest_io, TUint32& aSrc_in);
1.87 -/**
1.88 -Premultiplies the color channel values with the Alpha channel value.
1.89 -Alpha value remains unchanged. An approximation is used in the operation where the division
1.90 -by 255 is approximated by a shift-by-8-bits operation (i.e. division by 256).
1.91 -@param aPixel The 32 bit pixel value to be pre-multiplied.
1.92 -@return The PMA value.
1.93 -@internalTechnology
1.94 -@released
1.95 -*/
1.96 -inline TUint32 NonPMA2PMAPixel(TUint32 aPixel);
1.97 -
1.98 -/**
1.99 -Divives the PMA pixel color channels with the Alpha value, to convert them to non-PMA format.
1.100 -Alpha value remains unchanged.
1.101 -@param aPixel the premultiplied 32 bit pixel value.
1.102 -@param aNormTable The lookup table used to do the normalisation (the table converts the division
1.103 - to multiplication operation).
1.104 - The table is usually obtainable by a call to the method:
1.105 - PtrTo16BitNormalisationTable, which is defined in lookuptable.dll(.lib).
1.106 - The lookup table for normalised alpha is compluted using this equation:
1.107 - Table[index] = (255*256) / index (where index is an 8 bit value).
1.108 -@return The NON-PMA 32 bit pixel value.
1.109 -@internalTechnology
1.110 -@released
1.111 -*/
1.112 -inline TUint32 PMA2NonPMAPixel(TUint32 aPixel, const TUint16* aNormTable);
1.113 -
1.114 -/**
1.115 -In-place version of NonPMA2PMAPixel.
1.116 -@see NonPMA2PMAPixel
1.117 -@internalTechnology
1.118 -@released
1.119 -*/
1.120 -inline void Convert2PMA(TUint32& aInOutValue);
1.121 -
1.122 -/**
1.123 -In-place version of PMA2NonPMAPixel
1.124 -@see PMA2NonPMAPixel
1.125 -@internalTechnology
1.126 -@released
1.127 -*/
1.128 -inline void Convert2NonPMA(TUint32& aInOutValue, const TUint16* aNormTable);
1.129 -
1.130 -
1.131 -#include <graphics/blendingalgorithms.inl>
1.132 -
1.133 -#endif //__BLENDINGALGORITHMS_H__