sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "../inc/BMDRAW.H" sl@0: #include sl@0: sl@0: // Current plan is to depreciate 16MA targets so we have removed acceleration of these. sl@0: // To re-enable put the __SUPPORT_16MA_TARGET__ back in sl@0: //#define __SUPPORT_16MA_TARGET__ sl@0: sl@0: // Enabling __CHECK_ALPHA01__ causes checks for alpha values of 0 and 1 to be made to attempt to sl@0: // accelerate handling of these cases. This may not always work as branching the execution path sl@0: // can potentially lose more time than is gained. sl@0: sl@0: #define __CHECK_ALPHA01__ sl@0: sl@0: #define WRITE_RUN \ sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 7: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 6: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 5: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 4: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 3: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 2: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 1: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN2ROT \ sl@0: FORCEINLINE static void write2rot(const TUint8* aSrc, TUint8* aDst, TInt aLen, TInt aSrcStep, TInt aDstStep) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 7: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 6: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 5: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 4: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 3: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 2: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: case 1: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN2H \ sl@0: static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen); sl@0: sl@0: #define WRITE_RUN2C(class3232) \ sl@0: void class3232::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 7: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 6: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 5: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 4: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 3: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 2: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: case 1: write(aSrc, aDst);aSrc+=4;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN2416 \ sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 7: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 6: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 5: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 4: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 3: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 2: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 1: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN3216 \ sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 7: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 6: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 5: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 4: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 3: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 2: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 1: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN3216C2(class3216) \ sl@0: void class3216::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 7: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 6: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 5: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 4: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 3: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 2: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: case 1: write(aSrc, aDst);aSrc+=4;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN2416C2(class2416) \ sl@0: void class2416::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 7: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 6: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 5: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 4: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 3: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 2: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: case 1: write(aSrc, aDst);aSrc+=3;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_RUN1632 \ sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 7: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 6: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 5: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 4: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 3: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 2: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: case 1: write(aSrc, aDst);aSrc+=2;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: // Using non-inline versions can make better usage of registers, need to experiment to find fastest mix sl@0: sl@0: #define WRITE_RUN1632C(class1632) \ sl@0: void class1632::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)\ sl@0: { \ sl@0: const TUint16* lowAdd = Convert16to32bppLow();\ sl@0: const TUint32* highAdd = Convert16to32bppHigh();\ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 7: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 6: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 5: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 4: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 3: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 2: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: case 1: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN \ sl@0: FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN3216 \ sl@0: FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN2416 \ sl@0: FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN1632 \ sl@0: FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN1632H \ sl@0: static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen); sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN1632C(class1632) \ sl@0: void class1632::writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: const TUint8* srcPtr=aSrc;\ sl@0: TUint8* dstPtr=aDst;\ sl@0: const TUint8* alphaPtr=aAlpha;\ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 7: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 6: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 5: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 4: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 3: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 2: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: case 1: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: aSrc=srcPtr;\ sl@0: aDst=dstPtr;\ sl@0: aAlpha=alphaPtr;\ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN1616 \ sl@0: FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN_ROT32 \ sl@0: FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define WRITE_ALPHA_MASK_RUN_ROT16 \ sl@0: FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\ sl@0: { \ sl@0: switch (aLen % 8) /* aLen > 0 assumed */ \ sl@0: { \ sl@0: case 0: do { writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 7: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 6: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 5: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 4: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 3: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 2: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: case 1: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \ sl@0: } while ((aLen -= 8) > 0); \ sl@0: } \ sl@0: } sl@0: sl@0: #define MultAlphaWithSrcAlpha(aAlpha, aSrc)\ sl@0: {\ sl@0: const TUint32 src=*(TUint32*)aSrc;\ sl@0: TUint32 srcAlpha=src>>24;\ sl@0: aAlpha=(aAlpha*srcAlpha);\ sl@0: aAlpha+=srcAlpha;\ sl@0: aAlpha>>=8;\ sl@0: } sl@0: sl@0: // Takes a pre-multipled alpha source and additionally multiplies it by the alpha sl@0: // value so the source is effectively now pre-multiplied by both it's own alpha sl@0: // and the specified alpha. sl@0: // No aAlpha==0xFF or ==0 checks as should never come here in those situations sl@0: #define MultMapSrcByAlpha(aAlpha, aSrc)\ sl@0: {\ sl@0: TUint32 d1 = (aSrc>>8)&0x00FF00FF;\ sl@0: d1=d1*aAlpha+d1;\ sl@0: TUint32 d2=aSrc&0x00FF00FF;\ sl@0: d2=d2*aAlpha+d2;\ sl@0: aSrc=(d1&0xFF00FF00)|((d2&0xFF00FF00)>>8);\ sl@0: } sl@0: sl@0: #define Write16MTo64K(aSrc, aDst)\ sl@0: {\ sl@0: TInt color64K=(aSrc & 0x0000f8) >> 3;\ sl@0: color64K|=(aSrc & 0x00fc00) >> 5;\ sl@0: color64K|=(aSrc & 0xf80000) >> 8;\ sl@0: *(TUint16*)aDst = color64K;\ sl@0: } sl@0: sl@0: // Calc new alpha as src+(1-src)*dst; sl@0: #define CalcDestMultAlpha(aDestMultAlpha, aDA, aSrcAlpha, aDstAlpha)\ sl@0: {\ sl@0: const TUint32 srcAlpha=aSrcAlpha;\ sl@0: const TUint32 dstAlpha=aDstAlpha;\ sl@0: aDA=dstAlpha<<16;\ sl@0: aDA=aDA*(0x100-srcAlpha);\ sl@0: aDA+=srcAlpha<<24;\ sl@0: aDestMultAlpha=(((0x100-srcAlpha)*dstAlpha)>>8)+1;\ sl@0: } sl@0: sl@0: // Note: This function assumes incoming rgb's are shifted up by an extra 8 bits as that's the sl@0: // most efficient way of processing the preceding functions with this final write to 64K handling sl@0: // the extra shift down. sl@0: #define WriteRedBlueAndGreenTo64K(aRedBlue, aGreen, aDst)\ sl@0: {\ sl@0: TInt targ64K=(aRedBlue&0x00f800) >> 11;\ sl@0: targ64K|=(aRedBlue&0xf8000000) >> 16;\ sl@0: targ64K|=(aGreen&0xfc0000) >> 13;\ sl@0: *(TUint16*)aDst = targ64K;\ sl@0: } sl@0: sl@0: sl@0: // Used for calculating blending from a MAP source to any of 16M dest formats. sl@0: #define CalcMapToMxRGBA(aSrcPixel, aDst, aDestMult, aDestAG, aDestRB)\ sl@0: {\ sl@0: const TUint32 dstPixel=*(TUint32*)aDst;\ sl@0: aDestAG=(dstPixel&0xFF00FF00)>>8;\ sl@0: aDestAG=aDestAG*aDestMult;\ sl@0: aDestAG+=aSrcPixel&0xFF00FF00;\ sl@0: aDestRB=dstPixel&0x00FF00FF;\ sl@0: aDestRB=(aDestRB*aDestMult)>>8;\ sl@0: aDestRB+=aSrcPixel&0x00FF00FF;\ sl@0: } sl@0: sl@0: // Used For non MAP source blending using dest=src*alpha+dest*destAlpha sl@0: // aDestMultAlpha is typically (1-aAlpha) or (srcAlpha+(1-srcAlpha)*destAlpha) sl@0: #define CalcMxToMxRGBA2A(aMxMxSrcPixel, aMxMxDestPixel, aMxMxAlpha, aMxMxDestMultAlpha, aMxMxDestAG, aMxMxDestRB)\ sl@0: {\ sl@0: aMxMxDestAG=(aMxMxDestPixel & 0xFF00FF00)>>8;\ sl@0: aMxMxDestAG=aMxMxDestAG*aMxMxDestMultAlpha;\ sl@0: TUint32 srcAG=(aMxMxSrcPixel&0xFF00FF00)>>8;\ sl@0: aMxMxDestAG&=0xFF00FF00;\ sl@0: TUint32 alphaPlus1=aMxMxAlpha+1;\ sl@0: aMxMxDestAG+=srcAG*alphaPlus1;\ sl@0: aMxMxDestRB=aMxMxDestPixel&0x00FF00FF;\ sl@0: aMxMxDestRB=aMxMxDestRB*aMxMxDestMultAlpha;\ sl@0: aMxMxDestRB&=0xFF00FF00;\ sl@0: TUint32 srcRB=(aMxMxSrcPixel&0x00FF00FF);\ sl@0: aMxMxDestRB+=srcRB*alphaPlus1;\ sl@0: aMxMxDestRB>>=8;\ sl@0: } sl@0: sl@0: // Used For non MAP source blending using dest=src*alpha+dest*(1-alpha) sl@0: #define CalcMxToMxRGBA(aSrc, aDest, aAlpha, aDestAG, aDestRB)\ sl@0: {\ sl@0: const TUint32 srcPixel=*(TUint32*)aSrc;\ sl@0: const TUint32 dstPixel=*(TUint32*)aDst;\ sl@0: const TUint32 oneMinusAlpha = 0x100 - aAlpha;\ sl@0: CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, oneMinusAlpha , aDestAG, aDestRB);\ sl@0: } sl@0: sl@0: #define WriteMu(aDestAG, aDestRB, aDst)\ sl@0: *(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF)|0xFF000000 sl@0: sl@0: #define WriteMxA(aDestG, aDestRB, aDestA, aDst)\ sl@0: *(TUint32*)aDst=(aDestG&0x0000FF00)|(aDestRB&0x00FF00FF)|(aDestA&0xFF000000) sl@0: sl@0: #define WriteMx(aDestAG, aDestRB, aDst)\ sl@0: *(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF) sl@0: sl@0: struct TMapToMu sl@0: { sl@0: #define writeMapMu(aSrc, aDst)\ sl@0: {\ sl@0: const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\ sl@0: WriteMu(d1,d2,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: *(TUint32*)aDst = src; sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: writeMapMu(src, aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src>0x00FFFFFF) sl@0: #endif sl@0: { sl@0: MultMapSrcByAlpha(aAlpha,src); sl@0: // No aAlpha==0xFF check as should never come here in that situation sl@0: writeMapMu(src, aDst); sl@0: } sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMapToMa sl@0: { sl@0: #define writeMapMa(aSrc, aDst)\ sl@0: {\ sl@0: const TUint32 d=*(TUint32*)aDst;\ sl@0: TUint32 da;\ sl@0: TUint32 destMultAlpha;\ sl@0: CalcDestMultAlpha(destMultAlpha,da,aSrc>>24,d>>24);\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: CalcMapToMxRGBA(aSrc,aDst,destMultAlpha,d1,d2);\ sl@0: WriteMxA(d1,d2,da,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src>0x00FFFFFF) sl@0: { sl@0: if (src >= 0xFF000000) sl@0: *(TUint32*)aDst=src; sl@0: else sl@0: writeMapMa(src,aDst); sl@0: } sl@0: #else sl@0: writeMapMa(src,aDst); sl@0: #endif sl@0: } sl@0: WRITE_RUN sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src>0x00FFFFFF) sl@0: #endif sl@0: { sl@0: MultMapSrcByAlpha(aAlpha,src); sl@0: // No aAlpha==0xFF check as should never come here in that situation sl@0: writeMapMa(src,aDst); sl@0: } sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMapToMap sl@0: { sl@0: #define writeMapMap(aSrc, aDst)\ sl@0: {\ sl@0: const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\ sl@0: WriteMx(d1,d2,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: *(TUint32*)aDst = src; sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: writeMapMap(src,aDst); sl@0: } sl@0: WRITE_RUN sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src<=0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: MultMapSrcByAlpha(aAlpha,src); sl@0: // No aAlpha==0xFF check as should never come here in that situation sl@0: writeMapMap(src,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMaToMu sl@0: { sl@0: #define writeMaMu(aSrc, aAlpha, aDst)\ sl@0: {\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\ sl@0: WriteMu(d1,d2,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: *(TUint32*)aDst = src; sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: const TUint32 alpha=src>>24; sl@0: writeMaMu(aSrc,alpha,aDst); sl@0: } sl@0: WRITE_RUN sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: MultAlphaWithSrcAlpha(aAlpha,aSrc); sl@0: writeMaMu(aSrc,aAlpha,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMuToMu sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: *(TUint32*)aDst = *(TUint32*)aSrc; sl@0: } sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: aSrc+=aLen*4; sl@0: aDst+=aLen*4; sl@0: } sl@0: FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 d1; sl@0: TUint32 d2; sl@0: CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2); sl@0: WriteMu(d1,d2,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMuToMa sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: *(TUint32*)aDst = (*(TUint32*)aSrc); sl@0: } sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: aSrc+=aLen*4; sl@0: aDst+=aLen*4; sl@0: } sl@0: FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: } sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 da; sl@0: TUint32 d1; sl@0: TUint32 d2; sl@0: TUint32 destMultAlpha; sl@0: const TUint32 d = *(TUint32*)aDst; sl@0: CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24); sl@0: const TUint32 srcPixel=*(TUint32*)aSrc; sl@0: const TUint32 dstPixel=*(TUint32*)aDst; sl@0: CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2); sl@0: WriteMxA(d1,d2,da,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMaToMa sl@0: { sl@0: #define writeMaMa(aSrc, aAlpha, aDst)\ sl@0: {\ sl@0: TUint32 da;\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: TUint32 destMultAlpha;\ sl@0: const TUint32 d = *(TUint32*)aDst;\ sl@0: CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24);\ sl@0: const TUint32 srcPixel=*(TUint32*)aSrc;\ sl@0: const TUint32 dstPixel=*(TUint32*)aDst;\ sl@0: CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2);\ sl@0: WriteMxA(d1,d2,da,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: *(TUint32*)aDst = src; sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: const TUint32 alpha=src>>24; sl@0: writeMaMa(aSrc,alpha,aDst); sl@0: } sl@0: WRITE_RUN sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: MultAlphaWithSrcAlpha(aAlpha,aSrc); sl@0: writeMaMa(aSrc,aAlpha,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMaToMap sl@0: { sl@0: #define writeMaToMap(aSrc, aAlpha, aDst)\ sl@0: {\ sl@0: const TUint32 d = *(TUint32*)aDst;\ sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha;\ sl@0: TUint32 da=(d&0xFF000000)>>8;\ sl@0: da=da*oneMinusAlpha;\ sl@0: da+=aAlpha<<24;\ sl@0: TUint32 d1;\ sl@0: TUint32 d2;\ sl@0: CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\ sl@0: WriteMxA(d1,d2,da,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: *(TUint32*)aDst = src; sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: const TUint32 alpha=src>>24; sl@0: writeMaToMap(aSrc,alpha,aDst); sl@0: } sl@0: WRITE_RUN sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: MultAlphaWithSrcAlpha(aAlpha,aSrc); sl@0: writeMaToMap(aSrc,aAlpha,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct TMuToMap sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: *(TUint32*)aDst = (*(TUint32*)aSrc); sl@0: } sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: aSrc+=aLen*4; sl@0: aDst+=aLen*4; sl@0: } sl@0: FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) sl@0: { sl@0: Mem::Move(aDst,aSrc,aLen*sizeof(TUint32)); sl@0: } sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 d1; sl@0: TUint32 d2; sl@0: CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2); sl@0: WriteMx(d1,d2,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN_ROT32 sl@0: WRITE_RUN2ROT sl@0: WRITE_ALPHA_MASK_RUN sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: WRITE_RUN2C(TMapToMap) sl@0: WRITE_RUN2C(TMapToMa) sl@0: WRITE_RUN2C(TMapToMu) sl@0: WRITE_RUN2C(TMaToMap) sl@0: WRITE_RUN2C(TMaToMa) sl@0: WRITE_RUN2C(TMaToMu) sl@0: sl@0: // reads green value from 64K source, or's it with 0xFF alpha channel, and leaves sl@0: // it shifted down by 8 ready for multiplying by alpha value. sl@0: #define ReadGreen64K(aRG64KGreen, aRG64KSrc)\ sl@0: aRG64KGreen=(aRG64KSrc&0x07E0)>>3;\ sl@0: aRG64KGreen=((aRG64KGreen+(aRG64KGreen>>6))&0x000000FF)|0x00FF0000; sl@0: sl@0: // Reads the red and blue values from a 64K source into their RGBA values. sl@0: #define ReadRedBlue64K(aRedBlue,aColor64K)\ sl@0: {\ sl@0: aRedBlue=(aColor64K&0xF800)<<8;\ sl@0: aRedBlue|=(aColor64K&0x001F)<<3;\ sl@0: aRedBlue+=aRedBlue>>5;\ sl@0: aRedBlue&=0x00FF00FF;\ sl@0: } sl@0: sl@0: // reads green value from 64K source into aGreen and red and blue into aRedBlue sl@0: // All left in correct place for 16M operations sl@0: #define Read64KColors(aGreen,aRedBlue,aPtr)\ sl@0: {\ sl@0: const TUint32 r64Kcolor64K=*(TUint16*)aPtr;\ sl@0: aGreen=(r64Kcolor64K&0x07E0)<<5;\ sl@0: aGreen+=aGreen>>6;\ sl@0: aGreen&=0x0000FF00;\ sl@0: ReadRedBlue64K(aRedBlue,r64Kcolor64K);\ sl@0: } sl@0: sl@0: struct TMapTo64K sl@0: { sl@0: #define writeMap64K(aSrc, aDst)\ sl@0: {\ sl@0: TUint32 green;\ sl@0: TUint32 redBlue;\ sl@0: Read64KColors(green,redBlue,aDst);\ sl@0: const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\ sl@0: green=green*oneMinusAlpha;\ sl@0: green+=(aSrc<<8)&0x00FF00FF;\ sl@0: redBlue=redBlue*oneMinusAlpha;\ sl@0: redBlue+=(aSrc&0x00FF00FF)<<8;\ sl@0: WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\ sl@0: } sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: Write16MTo64K(src,aDst); sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: writeMap64K(src,aDst); sl@0: } sl@0: WRITE_RUN2H sl@0: WRITE_RUN3216 sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src<=0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: MultMapSrcByAlpha(aAlpha,src); sl@0: // No aAlpha==0xFF check as should never come here in that situation sl@0: writeMap64K(src,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN3216 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));}; sl@0: }; sl@0: sl@0: // Calculates green and redBlue shifted up by 8, that will be sorted in WriteRedBlueAndGreenTo64K sl@0: // this works out the most efficient way of getting the end result sl@0: // sl@0: // Note +++ sl@0: // Having the extra +greenSrc and +redBlueSrc (as in lines shown below) gives a better result, but sl@0: // is inconsistent with old code and causes test code failures, so it has been removed. sl@0: // greenSrc=greenSrc*aAlpha+greenSrc; sl@0: // redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: #define WriteMaOrMuTo64K(aSrc, aDst, aAlpha)\ sl@0: {\ sl@0: const TUint32 src=*(TUint32*)aSrc;\ sl@0: TUint32 green;\ sl@0: TUint32 redBlue;\ sl@0: Read64KColors(green,redBlue,aDst);\ sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha;\ sl@0: green=green*oneMinusAlpha;\ sl@0: TUint32 greenSrc=src&0x0000FF00;\ sl@0: greenSrc=greenSrc*aAlpha;\ sl@0: green+=greenSrc;\ sl@0: redBlue=redBlue*oneMinusAlpha;\ sl@0: TUint32 redBlueSrc=src&0x00FF00FF;\ sl@0: redBlueSrc=redBlueSrc*aAlpha;\ sl@0: redBlue+=redBlueSrc;\ sl@0: WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\ sl@0: } sl@0: sl@0: struct TMTo64K sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16); sl@0: Write16MTo64K(src,aDst); sl@0: } sl@0: WRITE_RUN2416 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16); sl@0: TUint32 green; sl@0: TUint32 redBlue; sl@0: Read64KColors(green,redBlue,aDst); sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha; sl@0: green=green*oneMinusAlpha; sl@0: TUint32 greenSrc=src&0x0000FF00; sl@0: greenSrc=greenSrc*aAlpha+greenSrc; sl@0: green+=greenSrc; sl@0: redBlue=redBlue*oneMinusAlpha; sl@0: TUint32 redBlueSrc=src&0x00FF00FF; sl@0: redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: redBlue+=redBlueSrc; sl@0: WriteRedBlueAndGreenTo64K(redBlue,green,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN2416 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(3);}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));}; sl@0: }; sl@0: sl@0: struct TMuTo64K sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: Write16MTo64K(src,aDst); sl@0: } sl@0: WRITE_RUN3216 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: WriteMaOrMuTo64K(aSrc,aDst,aAlpha); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN3216 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));}; sl@0: }; sl@0: sl@0: struct TMaTo64K sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: const TUint32 src=*(TUint32*)aSrc; sl@0: #if defined(__CHECK_ALPHA01__) sl@0: if (src >= 0xFF000000) sl@0: { sl@0: Write16MTo64K(src,aDst); sl@0: return; sl@0: } sl@0: if (src <= 0x00FFFFFF) sl@0: return; sl@0: #endif sl@0: const TUint32 alpha=src>>24; sl@0: WriteMaOrMuTo64K(aSrc,aDst,alpha); sl@0: } sl@0: WRITE_RUN3216 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: MultAlphaWithSrcAlpha(aAlpha,aSrc); sl@0: WriteMaOrMuTo64K(aSrc,aDst,aAlpha); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN3216 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));}; sl@0: }; sl@0: sl@0: struct T64KTo64K sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: *(TUint16*)aDst=*(const TUint16 *)aSrc; sl@0: } sl@0: FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) sl@0: { sl@0: Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16)); sl@0: aSrc+=aLen*2; sl@0: aDst+=aLen*2; sl@0: } sl@0: FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) sl@0: { sl@0: Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16)); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN_ROT16 sl@0: WRITE_RUN2ROT sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha; sl@0: // sl@0: TUint32 green; sl@0: TUint32 redBlue; sl@0: Read64KColors(green,redBlue,aDst); sl@0: green=green*oneMinusAlpha; sl@0: TUint32 greenSrc; sl@0: TUint32 redBlueSrc; sl@0: Read64KColors(greenSrc,redBlueSrc,aSrc); sl@0: // See note +++ sl@0: // greenSrc=greenSrc*aAlpha+greenSrc; sl@0: greenSrc=greenSrc*aAlpha; sl@0: green+=greenSrc; // needs shift down by 8, but do that when going to 64K sl@0: // sl@0: redBlue=redBlue*oneMinusAlpha; sl@0: // See note +++ sl@0: // redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: redBlueSrc=redBlueSrc*aAlpha; sl@0: redBlue+=redBlueSrc; // needs shift down by 8, but do that when going to 64K sl@0: WriteRedBlueAndGreenTo64K(redBlue,green,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN1616 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));}; sl@0: }; sl@0: sl@0: #define Write64KTo16M(aSrc, aDst)\ sl@0: TUint32 w6216Mgreen;\ sl@0: TUint32 w6216MredBlue;\ sl@0: Read64KColors(w6216Mgreen,w6216MredBlue, aSrc);\ sl@0: WriteMu(w6216Mgreen,w6216MredBlue,aDst); sl@0: sl@0: #define Write64KTo16MLookup(aSrc, aDst, aLowAdd, aHighAdd)\ sl@0: {\ sl@0: const TUint32 srcData=*(TUint16*)aSrc;\ sl@0: *(TUint32*)aDst = aHighAdd[srcData>>8] | aLowAdd[srcData&0xff];\ sl@0: } sl@0: sl@0: struct T64KToMu sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: Write64KTo16M(aSrc,aDst); sl@0: } sl@0: WRITE_RUN1632 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha; sl@0: const TUint32 d = *(TUint32*)aDst; sl@0: TUint32 src=*(TUint16*)aSrc; sl@0: // sl@0: TUint32 green = (d&0x0000FF00)>>8; sl@0: green=green*oneMinusAlpha; sl@0: TUint32 greenSrc; sl@0: ReadGreen64K(greenSrc,src); sl@0: // See note +++ sl@0: // greenSrc=greenSrc*aAlpha+greenSrc; sl@0: greenSrc=greenSrc*aAlpha; sl@0: green+=greenSrc; sl@0: // sl@0: TUint32 redBlue = d&0x00FF00FF; sl@0: redBlue=redBlue*oneMinusAlpha; sl@0: TUint32 redBlueSrc; sl@0: ReadRedBlue64K(redBlueSrc,src); sl@0: // See note +++ sl@0: // redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: redBlueSrc=redBlueSrc*aAlpha; sl@0: redBlue+=redBlueSrc; sl@0: // sl@0: redBlue>>=8; sl@0: WriteMu(green,redBlue,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN1632 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: struct T64KToMa sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: Write64KTo16M(aSrc,aDst); sl@0: } sl@0: WRITE_RUN1632 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: const TUint32 destSrc = *(TUint32*)aDst; sl@0: TUint32 destAlpha=destSrc>>24; sl@0: // Calc new alpha as src+(1-src)*dst; sl@0: destAlpha=(0x100-aAlpha)*destAlpha; sl@0: TUint32 targDestPixel=(destAlpha>>8)<<24; sl@0: targDestPixel+=aAlpha<<24; sl@0: // sl@0: TUint32 greenAlpha=(destSrc>>8)&0x000000FF; sl@0: const TUint32 destMultAlpha = (destAlpha>>8)+1; sl@0: greenAlpha=greenAlpha*destMultAlpha; sl@0: TUint32 redBlue = destSrc&0x00FF00FF; sl@0: redBlue=redBlue*destMultAlpha; sl@0: // sl@0: TUint32 src=*(TUint16*)aSrc; sl@0: TUint32 greenSrc; sl@0: ReadGreen64K(greenSrc,src); sl@0: greenSrc=greenSrc*aAlpha+greenSrc; sl@0: greenAlpha+=greenSrc; sl@0: targDestPixel|=greenAlpha&0x0000FF00; sl@0: // sl@0: TUint32 redBlueSrc; sl@0: ReadRedBlue64K(redBlueSrc,src); sl@0: redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: redBlue+=redBlueSrc; sl@0: // sl@0: targDestPixel|=(redBlue>>8)&0x00FF00FF; sl@0: *(TUint32*)aDst=targDestPixel; sl@0: } sl@0: WRITE_ALPHA_MASK_RUN1632H sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: WRITE_ALPHA_MASK_RUN1632C(T64KToMa) sl@0: sl@0: struct T64KToMap sl@0: { sl@0: FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst) sl@0: { sl@0: Write64KTo16M(aSrc,aDst); sl@0: } sl@0: WRITE_RUN1632 sl@0: WRITE_RUN2H sl@0: FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha) sl@0: { sl@0: const TUint32 oneMinusAlpha = 0x100-aAlpha; sl@0: const TUint32 d = *(TUint32*)aDst; sl@0: TUint32 src=*(TUint16*)aSrc; sl@0: // sl@0: TUint32 greenAlpha = (d&0xFF00FF00)>>8; sl@0: greenAlpha=greenAlpha*oneMinusAlpha; sl@0: TUint32 greenSrc; sl@0: ReadGreen64K(greenSrc,src); sl@0: greenSrc=greenSrc*aAlpha+greenSrc; sl@0: greenAlpha&=0xFF00FF00; // Needed to stop adding rounding errors together in next step sl@0: greenAlpha+=greenSrc; sl@0: // sl@0: TUint32 redBlue = d&0x00FF00FF; sl@0: redBlue=redBlue*oneMinusAlpha; sl@0: TUint32 redBlueSrc; sl@0: ReadRedBlue64K(redBlueSrc,src); sl@0: redBlueSrc=redBlueSrc*aAlpha+redBlueSrc; sl@0: redBlue&=0xFF00FF00; // Needed to stop adding rounding errors together in next step sl@0: redBlue+=redBlueSrc; // needs shift down by 8, but do that when writing to dest sl@0: // sl@0: redBlue>>=8; sl@0: WriteMx(greenAlpha,redBlue,aDst); sl@0: } sl@0: WRITE_ALPHA_MASK_RUN1632 sl@0: FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));}; sl@0: FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));}; sl@0: }; sl@0: sl@0: WRITE_RUN1632C(T64KToMap) sl@0: WRITE_RUN1632C(T64KToMa) sl@0: WRITE_RUN1632C(T64KToMu) sl@0: WRITE_RUN3216C2(TMapTo64K) sl@0: WRITE_RUN3216C2(TMaTo64K) sl@0: WRITE_RUN3216C2(TMuTo64K) sl@0: WRITE_RUN2416C2(TMTo64K) sl@0: sl@0: inline TInt InitDda(TInt &aDdaCount, TBool &aStretching, TInt aSrcValue, TInt aDstValue, TInt aSkipSteps) sl@0: { sl@0: aDdaCount=0; sl@0: aStretching=aDstValue>aSrcValue; sl@0: TInt skip=0; sl@0: if (aStretching) sl@0: { sl@0: aDdaCount=aDstValue-1; sl@0: while(aSkipSteps--) sl@0: { sl@0: aDdaCount-=aSrcValue; sl@0: if (aDdaCount<0) sl@0: { sl@0: skip++; sl@0: aDdaCount+=aDstValue; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: aDdaCount=aSrcValue-1; sl@0: while(aSkipSteps) sl@0: { sl@0: aDdaCount-=aDstValue; sl@0: if (aDdaCount<0) sl@0: { sl@0: aSkipSteps--; sl@0: aDdaCount+=aSrcValue; sl@0: } sl@0: skip++; sl@0: } sl@0: } sl@0: return(skip); sl@0: } sl@0: sl@0: inline void DdaStep(TInt &aDdaCount, TBool aStretching, TInt aSrcValue, TInt aDstValue, TInt &aSkipCount) sl@0: { sl@0: if (aStretching) sl@0: { sl@0: aDdaCount-=aSrcValue; sl@0: if (aDdaCount<0) sl@0: { sl@0: aSkipCount++; sl@0: aDdaCount+=aDstValue; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: do sl@0: { sl@0: aSkipCount++; sl@0: aDdaCount-=aDstValue; sl@0: } while(aDdaCount>=0); sl@0: aDdaCount+=aSrcValue; sl@0: } sl@0: } sl@0: sl@0: template sl@0: static void ScaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, TRect& aDstRect, const TRect &aClipRect) sl@0: { sl@0: TInt srcWidth = aSrcRect.Width(); sl@0: TInt srcHeight = aSrcRect.Height(); sl@0: TInt dstWidth = aDstRect.Width(); sl@0: TInt dstHeight = aDstRect.Height(); sl@0: // sl@0: TInt yDdaCount; sl@0: TBool yStretching; sl@0: TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY); sl@0: // sl@0: TInt xDdaCountBase; sl@0: TBool xStretching; sl@0: TInt sxOffset=aSrcRect.iTl.iX+InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX); sl@0: sxOffset*=op::SrcPixelBytes(); sl@0: // sl@0: const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY; sl@0: const TInt xCount=aClipRect.Width(); sl@0: TUint8* dstPixelBase = aDataAddress + aDstStride*aClipRect.iTl.iY + aClipRect.iTl.iX*op::DestPixelBytes(); sl@0: for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y) sl@0: { sl@0: const TUint8* srcPixel = aSrcBase + aSrcStride*ySrcOffset + sxOffset; sl@0: TUint8* dstPixel = dstPixelBase; sl@0: TInt xCountDown=xCount; sl@0: TInt ddaCount = xDdaCountBase; sl@0: if (xStretching) sl@0: { sl@0: do sl@0: { sl@0: op::write(srcPixel, dstPixel); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: ddaCount-=srcWidth; sl@0: if (ddaCount<0) sl@0: { sl@0: srcPixel+=op::SrcPixelBytes(); sl@0: ddaCount+=dstWidth; sl@0: } sl@0: } while(--xCountDown); sl@0: } sl@0: else sl@0: { sl@0: do sl@0: { sl@0: op::write(srcPixel, dstPixel); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: do sl@0: { sl@0: srcPixel+=op::SrcPixelBytes(); sl@0: ddaCount-=dstWidth; sl@0: } while(ddaCount>=0); sl@0: ddaCount+=srcWidth; sl@0: } while(--xCountDown); sl@0: } sl@0: dstPixelBase+=aDstStride; sl@0: DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset); sl@0: } sl@0: } sl@0: sl@0: template sl@0: static void UnscaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos) sl@0: { sl@0: const TInt blitWidth = aSrcRect.Width(); sl@0: const TUint8* srcPixel = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes(); sl@0: TUint8* dstPixel = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes(); sl@0: const TUint8* dstPixelEnd = dstPixel+aSrcRect.Height()*aDstStride; sl@0: do sl@0: { sl@0: op::write2(srcPixel,dstPixel,blitWidth); sl@0: srcPixel+=aSrcStride; sl@0: dstPixel+=aDstStride; sl@0: } while(dstPixel(aSrcBase) + srcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX; sl@0: TUint32* dstPixel = ((TUint32*)aDataAddress) + dstStride*aDstPos.iY + dx; sl@0: const TInt copyLen=dstWidth*4; sl@0: for (TInt linesToGo=aSrcRect.Height();linesToGo;--linesToGo) sl@0: { sl@0: // Andy - not convinced that this function is any good atall sl@0: // try stdlib memcpy instead. sl@0: Mem::Move(dstPixel, srcPixel, copyLen); sl@0: srcPixel+=srcStride; sl@0: dstPixel+=dstStride; sl@0: } sl@0: } sl@0: sl@0: template sl@0: static void UnscaledFastBlitRot(const TUint8* aSrcBase, CFbsDrawDevice::TOrientation aOrientation, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TSize &aDestSize, TUint32* aScanLineBuffer) sl@0: { sl@0: TInt srcStep=op::SrcPixelBytes(); sl@0: TInt dstStep=op::DestPixelBytes(); sl@0: TInt dstStride=aDstStride; sl@0: TInt blitWidth = aSrcRect.Width(); sl@0: TInt blitHeight = aSrcRect.Height(); sl@0: const TUint8* srcPixel = aSrcBase + aSrcRect.iTl.iY*aSrcStride + aSrcRect.iTl.iX*srcStep; sl@0: const TUint8* srcPixelEnd = srcPixel + blitHeight*aSrcStride; sl@0: TUint8* dstPixel = aDataAddress; sl@0: sl@0: sl@0: switch(aOrientation) sl@0: { sl@0: case CFbsDrawDevice::EOrientationRotated90: sl@0: dstPixel += (aDstPos.iX*aDstStride + (aDestSize.iWidth-aDstPos.iY-1)*op::DestPixelBytes()); sl@0: dstStep = aDstStride; sl@0: dstStride = - op::DestPixelBytes(); sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated180: sl@0: dstPixel += ( (aDestSize.iHeight - aDstPos.iY -1 )*aDstStride +(aDestSize.iWidth - aDstPos.iX -1)*op::DestPixelBytes() ) ; sl@0: dstStep = -dstStep; sl@0: dstStride = -aDstStride; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated270: sl@0: dstPixel += ( (aDestSize.iHeight- aDstPos.iX - 1 )*aDstStride + aDstPos.iY*op::DestPixelBytes() ) ; sl@0: dstStep = -aDstStride; sl@0: dstStride = op::DestPixelBytes(); sl@0: break; sl@0: } sl@0: do sl@0: { sl@0: Mem::Copy(aScanLineBuffer, srcPixel, blitWidth*srcStep); sl@0: op::write2rot((TUint8*)aScanLineBuffer, dstPixel, blitWidth, srcStep, dstStep); sl@0: srcPixel+=aSrcStride; sl@0: dstPixel+=dstStride; sl@0: } sl@0: while(srcPixel sl@0: static void ScaledFastBlitMaskedG2(const TUint8* aSrcBase, TInt aSrcStride, const TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TBool aInvertMask, TUint8 *aDataAddress, TInt aDstStride, const TRect& aDstRect, const TRect &aClipRect) sl@0: { sl@0: TInt sx = aSrcRect.iTl.iX; sl@0: TInt sxOffset=sx*op::SrcPixelBytes(); sl@0: sl@0: TInt srcWidth = aSrcRect.Width(); sl@0: TInt srcHeight = aSrcRect.Height(); sl@0: TInt dstWidth = aDstRect.Width(); sl@0: TInt dstHeight = aDstRect.Height(); sl@0: // sl@0: TInt yDdaCount; sl@0: TBool yStretching; sl@0: TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY); sl@0: // sl@0: TInt xDdaCountBase; sl@0: TBool xStretching; sl@0: TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX); sl@0: // sl@0: const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY; sl@0: const TInt xCount=aClipRect.Width(); sl@0: TUint8* dstPixelBase = aDataAddress+aDstStride*aClipRect.iTl.iY+aClipRect.iTl.iX*op::DestPixelBytes(); sl@0: for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y) sl@0: { sl@0: const TUint8* srcPixel = aSrcBase+aSrcStride*ySrcOffset+sxOffset; sl@0: const TUint32* mskRowBase = (const TUint32*)(aMaskBase+aMaskStride*ySrcOffset); sl@0: TUint8* dstPixel = dstPixelBase; sl@0: TInt xCountDown=xCount; sl@0: TInt curMaskOffset=-1; sl@0: TUint32 maskbits=0; sl@0: TInt xOffset=xOffsetBase; sl@0: TInt ddaCount = xDdaCountBase; sl@0: if (xStretching) sl@0: { sl@0: do sl@0: { sl@0: const TInt maskOffset=xOffset+sx; sl@0: TInt maskBitOffset=maskOffset>>5; sl@0: if (curMaskOffset==maskBitOffset) sl@0: { sl@0: blitIt1: const TInt mask=1<<(maskOffset%32); sl@0: if (maskbits&mask) sl@0: op::write(srcPixel, dstPixel); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: ddaCount-=srcWidth; sl@0: if (ddaCount<0) sl@0: { sl@0: xOffset++; sl@0: srcPixel+=op::SrcPixelBytes(); sl@0: ddaCount+=dstWidth; sl@0: } sl@0: continue; sl@0: } sl@0: maskbits=*(mskRowBase+maskBitOffset); sl@0: if (aInvertMask) sl@0: maskbits=~maskbits; sl@0: curMaskOffset=maskBitOffset; sl@0: goto blitIt1; sl@0: } while(--xCountDown); sl@0: } sl@0: else sl@0: { sl@0: do sl@0: { sl@0: const TInt maskOffset=xOffset+sx; sl@0: TInt maskBitOffset=maskOffset>>5; sl@0: if (curMaskOffset==maskBitOffset) sl@0: { sl@0: blitIt2: const TInt mask=1<<(maskOffset%32); sl@0: if (maskbits&mask) sl@0: op::write(srcPixel, dstPixel); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: do sl@0: { sl@0: xOffset++; sl@0: srcPixel+=op::SrcPixelBytes(); sl@0: ddaCount-=dstWidth; sl@0: } while(ddaCount>=0); sl@0: ddaCount+=srcWidth; sl@0: continue; sl@0: } sl@0: maskbits=*(mskRowBase+maskBitOffset); sl@0: if (aInvertMask) sl@0: maskbits=~maskbits; sl@0: curMaskOffset=maskBitOffset; sl@0: goto blitIt2; sl@0: } while(--xCountDown); sl@0: } sl@0: dstPixelBase+=aDstStride; sl@0: DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset); sl@0: } sl@0: } sl@0: sl@0: template sl@0: static void UnscaledFastBlitMaskedG2(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TBool aInvertMask, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TPoint& aMaskSrcPos, const TSize &aMaskSize) sl@0: { sl@0: TInt sx = aSrcRect.iTl.iX; sl@0: TInt sy = aSrcRect.iTl.iY; sl@0: TInt dx = aDstPos.iX; sl@0: TInt dy = aDstPos.iY; sl@0: sl@0: TInt dstWidth = aSrcRect.Width(); sl@0: TInt dstHeight = aSrcRect.Height(); sl@0: TInt maskWidth=aMaskSize.iWidth; sl@0: TInt maskHeight=aMaskSize.iHeight; sl@0: TInt maskXStart=aMaskSrcPos.iX%maskWidth; sl@0: TInt maskStartShift=maskXStart&0x1F; sl@0: TInt xMaskLoopCount=1+(dstWidth-1)/maskWidth; sl@0: const TUint8* mskBasePtr=aMaskBase + (maskXStart/32)*4; sl@0: for(TInt xMaskLoop=0;xMaskLoop sl@0: static void ScaledFastBlitMaskedG256(const TUint8* aSrcBase, TInt aSrcStride, const TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TUint8 *aDataAddress, TInt aDstStride, const TRect& aDstRect, const TRect &aClipRect) sl@0: { sl@0: TInt sx = aSrcRect.iTl.iX; sl@0: TInt sxOffset=sx*op::SrcPixelBytes(); sl@0: sl@0: TInt srcWidth = aSrcRect.Width(); sl@0: TInt srcHeight = aSrcRect.Height(); sl@0: TInt dstWidth = aDstRect.Width(); sl@0: TInt dstHeight = aDstRect.Height(); sl@0: // sl@0: TInt yDdaCount; sl@0: TBool yStretching; sl@0: TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY); sl@0: // sl@0: TInt xDdaCountBase; sl@0: TBool xStretching; sl@0: TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX); sl@0: // sl@0: const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY; sl@0: const TInt xCount=aClipRect.Width(); sl@0: TUint8* dstPixelBase = aDataAddress+aClipRect.iTl.iY*aDstStride+aClipRect.iTl.iX*op::DestPixelBytes(); sl@0: for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y) sl@0: { sl@0: const TUint8* srcRowBase = aSrcBase+aSrcStride*ySrcOffset+sxOffset; sl@0: const TUint8* mskRowBase = aMaskBase+aMaskStride*ySrcOffset+sx; sl@0: TUint8* dstPixel = dstPixelBase; sl@0: TInt xCountDown=xCount; sl@0: TInt xOffset=xOffsetBase; sl@0: // sl@0: TInt ddaCount = xDdaCountBase; sl@0: if (xStretching) sl@0: { sl@0: do sl@0: { sl@0: TUint mask=*(mskRowBase+xOffset); sl@0: if (mask==0xFF) sl@0: op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel); sl@0: else if (mask!=0) sl@0: op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: // sl@0: ddaCount-=srcWidth; sl@0: if (ddaCount<0) sl@0: { sl@0: xOffset++; sl@0: ddaCount+=dstWidth; sl@0: } sl@0: } while(--xCountDown); sl@0: } sl@0: else sl@0: { sl@0: do sl@0: { sl@0: TUint mask=*(mskRowBase+xOffset); sl@0: if (mask==0xFF) sl@0: op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel); sl@0: else if (mask!=0) sl@0: op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask); sl@0: dstPixel+=op::DestPixelBytes(); sl@0: // sl@0: do sl@0: { sl@0: xOffset++; sl@0: ddaCount-=dstWidth; sl@0: } while(ddaCount>=0); sl@0: ddaCount+=srcWidth; sl@0: } while(--xCountDown); sl@0: } sl@0: dstPixelBase+=aDstStride; sl@0: DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset); sl@0: } sl@0: } sl@0: sl@0: template sl@0: static void UnscaledFastBlitMaskedG256(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TPoint& aMaskSrcPos, const TSize &aMaskSize) sl@0: { sl@0: TInt dstWidth = aSrcRect.Width(); sl@0: const TInt dstHeight = aSrcRect.Height(); sl@0: const TUint8* srcPixelStart = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes(); sl@0: TUint8* dstPixelStart = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes(); sl@0: TInt yPos=0; sl@0: const TInt maskWidth=aMaskSize.iWidth; sl@0: const TInt maskHeight=aMaskSize.iHeight; sl@0: const TInt maskStartOffset=aMaskSrcPos.iX%maskWidth; sl@0: FOREVER sl@0: { sl@0: const TUint8* srcPixel=srcPixelStart; sl@0: const TUint8* maskBase=aMaskBase + (aMaskStride*((aMaskSrcPos.iY+yPos)%maskHeight)); sl@0: const TUint8* mskPixel=maskBase + maskStartOffset; sl@0: const TUint8* mskEnd=maskBase + maskWidth; sl@0: if (dstWidth<(mskEnd-mskPixel)) sl@0: mskEnd=mskPixel+dstWidth; sl@0: TUint8* dstPixel=dstPixelStart; sl@0: const TUint8* runStart=mskPixel; sl@0: TInt toGo=dstWidth; sl@0: FOREVER sl@0: { sl@0: // Into skip loop first, assume start of scanline more likely to be masked out than set sl@0: TInt runLen1=0; sl@0: skipPixels: sl@0: while(mskPixel sl@0: static void UnscaledFastBlitMaskedRotG256(const TUint8* aSrcBase, CFbsDrawDevice::TOrientation aOrientation, sl@0: TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, sl@0: TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TSize &aDestSize, sl@0: const TPoint& aMaskSrcPos, const TSize &aMaskSize) sl@0: { sl@0: TPoint dstPos(aDstPos); sl@0: TInt srcStep=op::SrcPixelBytes(); sl@0: TInt maskStep=1; sl@0: TRect srcRect(aSrcRect); sl@0: TSize maskSize(aMaskSize); sl@0: TPoint maskSrcPos(aMaskSrcPos); sl@0: switch(aOrientation) sl@0: { sl@0: case CFbsDrawDevice::EOrientationRotated90: sl@0: srcStep=-aSrcStride; sl@0: aSrcStride=op::SrcPixelBytes(); sl@0: maskStep=-aMaskStride; sl@0: aMaskStride=1; sl@0: dstPos.iX=aDestSize.iWidth-aDstPos.iY-aSrcRect.Height(); sl@0: dstPos.iY=aDstPos.iX; sl@0: srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX); sl@0: maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth); sl@0: maskSrcPos.iX=aMaskSrcPos.iY; sl@0: maskSrcPos.iY=aMaskSrcPos.iX; sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated180: sl@0: srcStep=-op::SrcPixelBytes(); sl@0: maskStep=-1; sl@0: aSrcStride=-aSrcStride; sl@0: aMaskStride=-aMaskStride; sl@0: dstPos.iX=aDestSize.iWidth-aDstPos.iX-aSrcRect.Width(); sl@0: dstPos.iY=aDestSize.iHeight-aDstPos.iY-aSrcRect.Height(); sl@0: break; sl@0: case CFbsDrawDevice::EOrientationRotated270: sl@0: srcStep=aSrcStride; sl@0: aSrcStride=-op::SrcPixelBytes(); sl@0: maskStep=aMaskStride; sl@0: aMaskStride=-1; sl@0: dstPos.iX=aDstPos.iY; sl@0: dstPos.iY=aDestSize.iHeight-aDstPos.iX-aSrcRect.Width(); sl@0: srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX); sl@0: maskSrcPos.iX=aMaskSrcPos.iY; sl@0: maskSrcPos.iY=aMaskSrcPos.iX; sl@0: maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth); sl@0: break; sl@0: } sl@0: const TUint8* srcPixelStart = aSrcBase; sl@0: if (srcStep>0) sl@0: srcPixelStart+=srcRect.iTl.iX*srcStep; sl@0: else sl@0: srcPixelStart-=(srcRect.iBr.iX-1)*srcStep; sl@0: if (aSrcStride>0) sl@0: srcPixelStart+=srcRect.iTl.iY*aSrcStride; sl@0: else sl@0: srcPixelStart-=(srcRect.iBr.iY-1)*aSrcStride; sl@0: // sl@0: const TInt dstWidth = srcRect.Width(); sl@0: const TInt dstHeight = srcRect.Height(); sl@0: TUint8* dstPixelStart = aDataAddress + aDstStride*dstPos.iY + dstPos.iX*op::DestPixelBytes(); sl@0: TInt yPos=0; sl@0: const TInt maskWidth=dstWidth0?maskSrcPos.iX:srcRect.iBr.iX-1)%maskSize.iWidth; sl@0: FOREVER sl@0: { sl@0: const TUint8* srcPixel=srcPixelStart; sl@0: const TUint8* maskBase=aMaskBase; sl@0: TInt maskYpos=(maskSrcPos.iY+yPos)%maskHeight; sl@0: if (aMaskStride>0) sl@0: maskBase+=maskYpos*aMaskStride; sl@0: else sl@0: { sl@0: TInt maskEndPos=(maskSrcPos.iY+dstHeight-1-yPos)%maskHeight; sl@0: maskBase-=maskEndPos*aMaskStride; sl@0: } sl@0: const TUint8* mskPixel=maskBase; sl@0: const TUint8* mskEnd=maskBase; sl@0: if (maskStep>0) sl@0: { sl@0: mskPixel+=maskStartOffset*maskStep; sl@0: mskEnd+=maskSize.iWidth*maskStep; sl@0: } sl@0: else sl@0: { sl@0: maskBase-=(maskSize.iWidth-1)*maskStep; sl@0: mskPixel-=maskStartOffset*maskStep; sl@0: mskEnd+=maskStep; sl@0: } sl@0: const TInt maskToGo=(mskEnd-mskPixel)/maskStep; sl@0: if (maskToGo>dstWidth) sl@0: mskEnd=mskPixel+dstWidth*maskStep; sl@0: TUint8* dstPixel=dstPixelStart; sl@0: const TUint8* runStart=mskPixel; sl@0: TInt toGo=dstWidth; sl@0: FOREVER sl@0: { sl@0: // Into skip loop first, assume start of scanline more likely to be masked out than set sl@0: TInt runLen1=0; sl@0: skipPixels: sl@0: while(mskPixel!=mskEnd && *mskPixel==0) sl@0: mskPixel+=maskStep; sl@0: const TInt runSubLen1=(mskPixel-runStart)/maskStep; sl@0: runLen1+=runSubLen1; sl@0: toGo-=runSubLen1; sl@0: if (mskPixel==mskEnd && toGo!=0) sl@0: { sl@0: mskPixel=maskBase; sl@0: runStart=maskBase; sl@0: if (toGo=aSrcSize.iWidth) sl@0: aSrcRect.Move(-(aSrcRect.iTl.iX/aSrcSize.iWidth)*aSrcSize.iWidth,0); sl@0: if (aSrcRect.iTl.iY<0) sl@0: { sl@0: TInt negOffset=1-(aSrcRect.iTl.iY+1)/aSrcSize.iHeight; sl@0: aSrcRect.Move(0,negOffset*aSrcSize.iHeight); sl@0: } sl@0: else if (aSrcRect.iTl.iY>=aSrcSize.iHeight) sl@0: aSrcRect.Move(0,-(aSrcRect.iTl.iY/aSrcSize.iHeight)*aSrcSize.iHeight); sl@0: if (aSrcRect.iBr.iY>aSrcSize.iHeight) sl@0: aSrcRect.iBr.iY=aSrcSize.iHeight; sl@0: if (aSrcRect.iBr.iX>aSrcSize.iWidth) sl@0: aSrcRect.iBr.iX=aSrcSize.iWidth; sl@0: } sl@0: sl@0: void CDrawBitmap::GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDstRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize) sl@0: { sl@0: aDstRect=aDstRectIn; sl@0: aSrcRect=aSrcRectIn; sl@0: if (aSrcRect.iTl.iX<0) sl@0: aSrcRect.iTl.iX=0; sl@0: if (aSrcRect.iTl.iY<0) sl@0: aSrcRect.iTl.iY=0; sl@0: TInt extraWidth=aSrcRect.iBr.iX-aSrcSize.iWidth; sl@0: if (extraWidth>0) sl@0: aSrcRect.iBr.iX-=extraWidth; sl@0: TInt extraHeight=aSrcRect.iBr.iY-aSrcSize.iHeight; sl@0: if (extraHeight>0) sl@0: aSrcRect.iBr.iY-=extraHeight; sl@0: } sl@0: sl@0: TInt CDrawBitmap::FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest, sl@0: const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch, sl@0: TDisplayMode aSrcDisplayMode, const TSize &aSrcSize, sl@0: const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask, sl@0: CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) sl@0: { sl@0: if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch) || sl@0: !FastBlendMaskSupported(aMaskDisplayMode, aMaskStride) || sl@0: iOrientation!=EOrientationNormal) sl@0: return(KErrNotSupported); sl@0: TRect srcRect; sl@0: TRect dstRect; sl@0: GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize); sl@0: const TInt KDestModeShift=8; sl@0: const TInt KMaskModeShift=16; sl@0: #define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<aMaskSize.iWidth || srcRect.iBr.iY>aMaskSize.iHeight) sl@0: return(KErrNotSupported); sl@0: TUint8 *dstBits=reinterpret_cast(iBits); sl@0: TInt dstStride=iScanLineWords*4; sl@0: const TUint8* srcBase=reinterpret_cast(aSrcBase); sl@0: const TUint8 *maskBits=reinterpret_cast(aMaskBase); sl@0: if (!dstRect.IsEmpty() && !srcRect.IsEmpty()) sl@0: { sl@0: switch (switchValue) sl@0: { sl@0: // 16MA source sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 16MU source sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 16MAP source sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 64K source sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: #if defined(__SUPPORT_16MA_TARGET__) sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2): sl@0: ScaledFastBlitMaskedG2(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256): sl@0: ScaledFastBlitMaskedG256(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: #endif sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: return(KErrNone); sl@0: } sl@0: sl@0: TInt CDrawBitmap::FastBlendBitmapScaled(const TRect &aClipRect, const TRect& aDest, const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) sl@0: { sl@0: if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch)) sl@0: return(KErrNotSupported); sl@0: TRect srcRect; sl@0: TRect dstRect; sl@0: GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize); sl@0: const TInt KDestModeShift=8; sl@0: #define MODE_SWITCH(src,dest) case src|(dest<(iBits); sl@0: TInt dstStride=iScanLineWords*4; sl@0: const TUint8* srcBase=reinterpret_cast(aSrcBase); sl@0: if (!dstRect.IsEmpty() && !srcRect.IsEmpty()) sl@0: { sl@0: switch (switchValue) sl@0: { sl@0: // 16MA Source sl@0: MODE_SWITCH(EColor16MA,EColor16MU): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MA,EColor16MAP): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MA,EColor64K): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 16MAP Source sl@0: MODE_SWITCH(EColor16MAP,EColor16MU): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor16MAP): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor64K): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 16MU Source sl@0: MODE_SWITCH(EColor16MU,EColor16MU): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MU,EColor64K): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // No EColor16MU to EColor16MAP fast blit performed because it sl@0: // cannot be guaranteed that the alpha channel of the EColor16MU sl@0: // source is 0xFF, which any fast blit would require. sl@0: // 64K Source sl@0: MODE_SWITCH(EColor64K,EColor16MU): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor16MAP): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor64K): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // 16M source sl@0: MODE_SWITCH(EColor16M,EColor64K): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: #if defined(__SUPPORT_16MA_TARGET__) sl@0: MODE_SWITCH(EColor16MA,EColor16MA): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor16MA): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor16MA): sl@0: ScaledFastBlit(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect); sl@0: break; sl@0: // No EColor16MU to EColor16MA fast blit performed because it sl@0: // cannot be guaranteed that the alpha channel of the EColor16MU sl@0: // source is 0xFF, which any fast blit would require. sl@0: #endif sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt CDrawBitmap::DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize) sl@0: { sl@0: const TInt KDestModeShift=8; sl@0: TInt dstStride=iScanLineWords*4; sl@0: TUint8 *dstBits=(TUint8*)iBits; sl@0: #define MODE_SWITCH(src,dest) case src|(dest<(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MA,EColor16MAP): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MA,EColor64K): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: // 16MAP Source sl@0: MODE_SWITCH(EColor16MAP,EColor16MU): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor16MAP): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor64K): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: // 16MU Source sl@0: MODE_SWITCH(EColor16MU,EColor16MU): sl@0: ReplaceBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MU,EColor64K): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: // No EColor16MU to EColor16MAP fast blit performed because it sl@0: // cannot be guaranteed that the alpha channel of the EColor16MU sl@0: // source is 0xFF, which any fast blit would require. sl@0: // 64K Source sl@0: MODE_SWITCH(EColor64K,EColor16MU): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor16MAP): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor64K): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: // 16M Source sl@0: MODE_SWITCH(EColor16M,EColor64K): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: #if defined(__SUPPORT_16MA_TARGET__) sl@0: MODE_SWITCH(EColor16MA,EColor16MA): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor16MA): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: MODE_SWITCH(EColor64K,EColor16MA): sl@0: UnscaledFastBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos); sl@0: break; sl@0: // No EColor16MU to EColor16MA fast blit performed because it sl@0: // cannot be guaranteed that the alpha channel of the EColor16MU sl@0: // source is 0xFF, which any fast blit would require. sl@0: #endif sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: switch (switchValue) sl@0: { sl@0: // 16MA Source sl@0: MODE_SWITCH(EColor16MA,EColor16MU): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: MODE_SWITCH(EColor16MA,EColor16MAP): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: // 16MAP Source sl@0: MODE_SWITCH(EColor16MAP,EColor16MU): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: MODE_SWITCH(EColor16MAP,EColor16MAP): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: // 16MU Source sl@0: MODE_SWITCH(EColor16MU,EColor16MU): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: MODE_SWITCH(EColor16MU,EColor16MAP): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: // 64K Source sl@0: MODE_SWITCH(EColor64K,EColor64K): sl@0: UnscaledFastBlitRot(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer); sl@0: break; sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: dstPos.iX+=srcRect.Width(); sl@0: } sl@0: dstPos.iY+=srcRect.Height(); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: TBool CDrawBitmap::FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch) sl@0: { sl@0: // FastBlend supports all combinations of EColor16Mxx and EColor64K, and when User Display Mode is ENone. sl@0: if ((iUserDispMode != EColor64K && iUserDispMode != EColor16M && sl@0: iUserDispMode != EColor16MU && iUserDispMode != EColor16MA && sl@0: iUserDispMode != EColor16MAP && iUserDispMode != ENone)) sl@0: { sl@0: return (EFalse); sl@0: } sl@0: if (!IsScalingOff() || sl@0: !iOriginIsZero) sl@0: { sl@0: return(EFalse); sl@0: } sl@0: return((aDrawMode==CGraphicsContext::EDrawModePEN || (aDrawMode==CGraphicsContext::EDrawModeWriteAlpha && !IsAlphaChannel(aSrcDisplayMode))) && sl@0: aShadowMode==CFbsDrawDevice::ENoShadow && aSrcLinePitch>0); sl@0: } sl@0: sl@0: TBool CDrawBitmap::FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride) sl@0: { sl@0: return((aMaskDisplayMode==EGray2 || aMaskDisplayMode==EGray256) && aMaskStride>0); sl@0: } sl@0: sl@0: /** sl@0: CDrawBitmap::BlendBitmap() implementation. sl@0: @internalTechnology sl@0: */ sl@0: TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) sl@0: { sl@0: TInt srcPitch=aSrcDrawDevice->ScanLineBytes(); sl@0: if (!FastBlendSupported(aSrcDrawDevice->DisplayMode(), aDrawMode, aShadowMode, srcPitch)) sl@0: return(KErrNotSupported); sl@0: MScalingSettings* scalingSettings=NULL; sl@0: if (aSrcDrawDevice->GetInterface(KScalingSettingsInterfaceID, sl@0: reinterpret_cast(scalingSettings))==KErrNone) sl@0: { sl@0: if (!scalingSettings->IsScalingOff()) sl@0: return(KErrNotSupported); sl@0: } sl@0: MDrawDeviceOrigin* originInterface = NULL; sl@0: if(aSrcDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, sl@0: reinterpret_cast (originInterface)) == KErrNone) sl@0: { sl@0: TPoint origin; sl@0: originInterface->Get(origin); sl@0: if (origin.iX!=0 || origin.iY!=0) sl@0: return(KErrNotSupported); sl@0: } sl@0: MDrawDeviceOrientation* orientationInterface=NULL; sl@0: if(aSrcDrawDevice->GetInterface(KOrientationInterfaceID, sl@0: reinterpret_cast (orientationInterface))!=KErrNone || (orientationInterface && orientationInterface->Orientation() != 0)) sl@0: { sl@0: return KErrNotSupported; sl@0: } sl@0: TAny* interface=NULL; sl@0: TInt ret=aSrcDrawDevice->GetInterface(KFastBlit2InterfaceID, interface); sl@0: if (ret!=KErrNone) sl@0: return(ret); sl@0: MFastBlit2 *fb2=reinterpret_cast(interface); sl@0: const TUint8* srcBase = reinterpret_cast(fb2->Bits()); sl@0: return(DoFastBlendBitmap(aDest, aSrcRect, srcBase, srcPitch, aSrcDrawDevice->DisplayMode(), aSrcDrawDevice->SizeInPixels())); sl@0: } sl@0: sl@0: TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) sl@0: { sl@0: if (!FastBlendSupported(aDisplayMode, aDrawMode, aShadowMode, aSrcStride)) sl@0: return(KErrNotSupported); sl@0: return(DoFastBlendBitmap(aDest, aSrcRect, reinterpret_cast(aSrcBase), aSrcStride, aDisplayMode, aSrcSize)); sl@0: } sl@0: sl@0: TInt CDrawBitmap::FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode, const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize, const TPoint &aMaskSrcPos, TBool aInvertMask, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode) sl@0: { sl@0: if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcStride) || sl@0: !FastBlendMaskSupported(aMaskDisplayMode, aMaskStride)) sl@0: return(KErrNotSupported); sl@0: TRect srcRect; sl@0: GetBlendPosAndRect(srcRect,aSrcRect,aSrcSize,TPoint(0,0)); sl@0: const TInt KDestModeShift=8; sl@0: const TInt KMaskModeShift=16; sl@0: TInt dstStride=iScanLineWords*4; sl@0: #define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<(aSrcBase); sl@0: TUint8 *dstBits=(TUint8*)iBits; sl@0: const TUint8 *maskBits=reinterpret_cast(aMaskBase); sl@0: if (iOrientation==EOrientationNormal) sl@0: { sl@0: switch (switchValue) sl@0: { sl@0: // 16MA source sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 16MU source sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 16MAP source sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 64K source sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: #if defined(__SUPPORT_16MA_TARGET__) sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2): sl@0: UnscaledFastBlitMaskedG2(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256): sl@0: UnscaledFastBlitMaskedG256(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: #endif sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: switch (switchValue) sl@0: { sl@0: // 16MA Source sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 16MAP Source sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 16MU Source sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: // 64K Source sl@0: MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256): sl@0: UnscaledFastBlitMaskedRotG256(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize); sl@0: break; sl@0: default: sl@0: return KErrNotSupported; sl@0: } sl@0: } sl@0: return KErrNone; sl@0: }