1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/sbit/FastBlend.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2583 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <bitstd.h>
1.20 +#include <graphics/lookuptable.h>
1.21 +#include <bitdrawinterfaceid.h>
1.22 +#include "../inc/BMDRAW.H"
1.23 +#include <graphics/gdi/gdiinline.inl>
1.24 +
1.25 +// Current plan is to depreciate 16MA targets so we have removed acceleration of these.
1.26 +// To re-enable put the __SUPPORT_16MA_TARGET__ back in
1.27 +//#define __SUPPORT_16MA_TARGET__
1.28 +
1.29 +// Enabling __CHECK_ALPHA01__ causes checks for alpha values of 0 and 1 to be made to attempt to
1.30 +// accelerate handling of these cases. This may not always work as branching the execution path
1.31 +// can potentially lose more time than is gained.
1.32 +
1.33 +#define __CHECK_ALPHA01__
1.34 +
1.35 +#define WRITE_RUN \
1.36 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
1.37 + { \
1.38 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.39 + { \
1.40 + case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.41 + case 7: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.42 + case 6: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.43 + case 5: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.44 + case 4: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.45 + case 3: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.46 + case 2: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.47 + case 1: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.48 + } while ((aLen -= 8) > 0); \
1.49 + } \
1.50 + }
1.51 +
1.52 +#define WRITE_RUN2ROT \
1.53 + FORCEINLINE static void write2rot(const TUint8* aSrc, TUint8* aDst, TInt aLen, TInt aSrcStep, TInt aDstStep) \
1.54 + { \
1.55 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.56 + { \
1.57 + case 0: do { write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.58 + case 7: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.59 + case 6: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.60 + case 5: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.61 + case 4: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.62 + case 3: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.63 + case 2: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.64 + case 1: write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
1.65 + } while ((aLen -= 8) > 0); \
1.66 + } \
1.67 + }
1.68 +
1.69 +#define WRITE_RUN2H \
1.70 + static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen);
1.71 +
1.72 +#define WRITE_RUN2C(class3232) \
1.73 + void class3232::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
1.74 + { \
1.75 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.76 + { \
1.77 + case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.78 + case 7: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.79 + case 6: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.80 + case 5: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.81 + case 4: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.82 + case 3: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.83 + case 2: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.84 + case 1: write(aSrc, aDst);aSrc+=4;aDst+=4; \
1.85 + } while ((aLen -= 8) > 0); \
1.86 + } \
1.87 + }
1.88 +
1.89 +#define WRITE_RUN2416 \
1.90 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
1.91 + { \
1.92 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.93 + { \
1.94 + case 0: do { write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.95 + case 7: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.96 + case 6: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.97 + case 5: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.98 + case 4: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.99 + case 3: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.100 + case 2: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.101 + case 1: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.102 + } while ((aLen -= 8) > 0); \
1.103 + } \
1.104 + }
1.105 +
1.106 +#define WRITE_RUN3216 \
1.107 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
1.108 + { \
1.109 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.110 + { \
1.111 + case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.112 + case 7: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.113 + case 6: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.114 + case 5: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.115 + case 4: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.116 + case 3: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.117 + case 2: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.118 + case 1: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.119 + } while ((aLen -= 8) > 0); \
1.120 + } \
1.121 + }
1.122 +
1.123 +#define WRITE_RUN3216C2(class3216) \
1.124 + void class3216::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
1.125 + { \
1.126 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.127 + { \
1.128 + case 0: do { write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.129 + case 7: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.130 + case 6: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.131 + case 5: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.132 + case 4: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.133 + case 3: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.134 + case 2: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.135 + case 1: write(aSrc, aDst);aSrc+=4;aDst+=2; \
1.136 + } while ((aLen -= 8) > 0); \
1.137 + } \
1.138 + }
1.139 +
1.140 +#define WRITE_RUN2416C2(class2416) \
1.141 + void class2416::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
1.142 + { \
1.143 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.144 + { \
1.145 + case 0: do { write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.146 + case 7: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.147 + case 6: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.148 + case 5: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.149 + case 4: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.150 + case 3: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.151 + case 2: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.152 + case 1: write(aSrc, aDst);aSrc+=3;aDst+=2; \
1.153 + } while ((aLen -= 8) > 0); \
1.154 + } \
1.155 + }
1.156 +
1.157 +#define WRITE_RUN1632 \
1.158 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
1.159 + { \
1.160 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.161 + { \
1.162 + case 0: do { write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.163 + case 7: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.164 + case 6: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.165 + case 5: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.166 + case 4: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.167 + case 3: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.168 + case 2: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.169 + case 1: write(aSrc, aDst);aSrc+=2;aDst+=4; \
1.170 + } while ((aLen -= 8) > 0); \
1.171 + } \
1.172 + }
1.173 +
1.174 +// Using non-inline versions can make better usage of registers, need to experiment to find fastest mix
1.175 +
1.176 +#define WRITE_RUN1632C(class1632) \
1.177 + void class1632::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)\
1.178 + { \
1.179 + const TUint16* lowAdd = Convert16to32bppLow();\
1.180 + const TUint32* highAdd = Convert16to32bppHigh();\
1.181 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.182 + { \
1.183 + case 0: do { Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.184 + case 7: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.185 + case 6: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.186 + case 5: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.187 + case 4: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.188 + case 3: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.189 + case 2: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.190 + case 1: Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
1.191 + } while ((aLen -= 8) > 0); \
1.192 + } \
1.193 + }
1.194 +
1.195 +#define WRITE_ALPHA_MASK_RUN \
1.196 + FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.197 + { \
1.198 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.199 + { \
1.200 + case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.201 + case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.202 + case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.203 + case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.204 + case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.205 + case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.206 + case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.207 + case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
1.208 + } while ((aLen -= 8) > 0); \
1.209 + } \
1.210 + }
1.211 +
1.212 +#define WRITE_ALPHA_MASK_RUN3216 \
1.213 + FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.214 + { \
1.215 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.216 + { \
1.217 + case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.218 + case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.219 + case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.220 + case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.221 + case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.222 + case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.223 + case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.224 + case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
1.225 + } while ((aLen -= 8) > 0); \
1.226 + } \
1.227 + }
1.228 +
1.229 +#define WRITE_ALPHA_MASK_RUN2416 \
1.230 + FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.231 + { \
1.232 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.233 + { \
1.234 + case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.235 + case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.236 + case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.237 + case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.238 + case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.239 + case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.240 + case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.241 + case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
1.242 + } while ((aLen -= 8) > 0); \
1.243 + } \
1.244 + }
1.245 +
1.246 +#define WRITE_ALPHA_MASK_RUN1632 \
1.247 + FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.248 + { \
1.249 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.250 + { \
1.251 + case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.252 + case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.253 + case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.254 + case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.255 + case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.256 + case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.257 + case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.258 + case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
1.259 + } while ((aLen -= 8) > 0); \
1.260 + } \
1.261 + }
1.262 +
1.263 +#define WRITE_ALPHA_MASK_RUN1632H \
1.264 + static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen);
1.265 +
1.266 +#define WRITE_ALPHA_MASK_RUN1632C(class1632) \
1.267 + void class1632::writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.268 + { \
1.269 + const TUint8* srcPtr=aSrc;\
1.270 + TUint8* dstPtr=aDst;\
1.271 + const TUint8* alphaPtr=aAlpha;\
1.272 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.273 + { \
1.274 + case 0: do { writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.275 + case 7: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.276 + case 6: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.277 + case 5: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.278 + case 4: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.279 + case 3: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.280 + case 2: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.281 + case 1: writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
1.282 + } while ((aLen -= 8) > 0); \
1.283 + } \
1.284 + aSrc=srcPtr;\
1.285 + aDst=dstPtr;\
1.286 + aAlpha=alphaPtr;\
1.287 + }
1.288 +
1.289 +#define WRITE_ALPHA_MASK_RUN1616 \
1.290 + FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
1.291 + { \
1.292 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.293 + { \
1.294 + case 0: do { writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.295 + case 7: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.296 + case 6: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.297 + case 5: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.298 + case 4: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.299 + case 3: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.300 + case 2: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.301 + case 1: writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
1.302 + } while ((aLen -= 8) > 0); \
1.303 + } \
1.304 + }
1.305 +
1.306 +#define WRITE_ALPHA_MASK_RUN_ROT32 \
1.307 + FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\
1.308 + { \
1.309 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.310 + { \
1.311 + case 0: do { writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.312 + case 7: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.313 + case 6: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.314 + case 5: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.315 + case 4: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.316 + case 3: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.317 + case 2: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.318 + case 1: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
1.319 + } while ((aLen -= 8) > 0); \
1.320 + } \
1.321 + }
1.322 +
1.323 +#define WRITE_ALPHA_MASK_RUN_ROT16 \
1.324 + FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\
1.325 + { \
1.326 + switch (aLen % 8) /* aLen > 0 assumed */ \
1.327 + { \
1.328 + case 0: do { writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.329 + case 7: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.330 + case 6: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.331 + case 5: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.332 + case 4: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.333 + case 3: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.334 + case 2: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.335 + case 1: writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
1.336 + } while ((aLen -= 8) > 0); \
1.337 + } \
1.338 + }
1.339 +
1.340 +#define MultAlphaWithSrcAlpha(aAlpha, aSrc)\
1.341 + {\
1.342 + const TUint32 src=*(TUint32*)aSrc;\
1.343 + TUint32 srcAlpha=src>>24;\
1.344 + aAlpha=(aAlpha*srcAlpha);\
1.345 + aAlpha+=srcAlpha;\
1.346 + aAlpha>>=8;\
1.347 + }
1.348 +
1.349 +// Takes a pre-multipled alpha source and additionally multiplies it by the alpha
1.350 +// value so the source is effectively now pre-multiplied by both it's own alpha
1.351 +// and the specified alpha.
1.352 +// No aAlpha==0xFF or ==0 checks as should never come here in those situations
1.353 +#define MultMapSrcByAlpha(aAlpha, aSrc)\
1.354 + {\
1.355 + TUint32 d1 = (aSrc>>8)&0x00FF00FF;\
1.356 + d1=d1*aAlpha+d1;\
1.357 + TUint32 d2=aSrc&0x00FF00FF;\
1.358 + d2=d2*aAlpha+d2;\
1.359 + aSrc=(d1&0xFF00FF00)|((d2&0xFF00FF00)>>8);\
1.360 + }
1.361 +
1.362 +#define Write16MTo64K(aSrc, aDst)\
1.363 + {\
1.364 + TInt color64K=(aSrc & 0x0000f8) >> 3;\
1.365 + color64K|=(aSrc & 0x00fc00) >> 5;\
1.366 + color64K|=(aSrc & 0xf80000) >> 8;\
1.367 + *(TUint16*)aDst = color64K;\
1.368 + }
1.369 +
1.370 +// Calc new alpha as src+(1-src)*dst;
1.371 +#define CalcDestMultAlpha(aDestMultAlpha, aDA, aSrcAlpha, aDstAlpha)\
1.372 + {\
1.373 + const TUint32 srcAlpha=aSrcAlpha;\
1.374 + const TUint32 dstAlpha=aDstAlpha;\
1.375 + aDA=dstAlpha<<16;\
1.376 + aDA=aDA*(0x100-srcAlpha);\
1.377 + aDA+=srcAlpha<<24;\
1.378 + aDestMultAlpha=(((0x100-srcAlpha)*dstAlpha)>>8)+1;\
1.379 + }
1.380 +
1.381 +// Note: This function assumes incoming rgb's are shifted up by an extra 8 bits as that's the
1.382 +// most efficient way of processing the preceding functions with this final write to 64K handling
1.383 +// the extra shift down.
1.384 +#define WriteRedBlueAndGreenTo64K(aRedBlue, aGreen, aDst)\
1.385 + {\
1.386 + TInt targ64K=(aRedBlue&0x00f800) >> 11;\
1.387 + targ64K|=(aRedBlue&0xf8000000) >> 16;\
1.388 + targ64K|=(aGreen&0xfc0000) >> 13;\
1.389 + *(TUint16*)aDst = targ64K;\
1.390 + }
1.391 +
1.392 +
1.393 +// Used for calculating blending from a MAP source to any of 16M dest formats.
1.394 +#define CalcMapToMxRGBA(aSrcPixel, aDst, aDestMult, aDestAG, aDestRB)\
1.395 + {\
1.396 + const TUint32 dstPixel=*(TUint32*)aDst;\
1.397 + aDestAG=(dstPixel&0xFF00FF00)>>8;\
1.398 + aDestAG=aDestAG*aDestMult;\
1.399 + aDestAG+=aSrcPixel&0xFF00FF00;\
1.400 + aDestRB=dstPixel&0x00FF00FF;\
1.401 + aDestRB=(aDestRB*aDestMult)>>8;\
1.402 + aDestRB+=aSrcPixel&0x00FF00FF;\
1.403 + }
1.404 +
1.405 +// Used For non MAP source blending using dest=src*alpha+dest*destAlpha
1.406 +// aDestMultAlpha is typically (1-aAlpha) or (srcAlpha+(1-srcAlpha)*destAlpha)
1.407 +#define CalcMxToMxRGBA2A(aMxMxSrcPixel, aMxMxDestPixel, aMxMxAlpha, aMxMxDestMultAlpha, aMxMxDestAG, aMxMxDestRB)\
1.408 + {\
1.409 + aMxMxDestAG=(aMxMxDestPixel & 0xFF00FF00)>>8;\
1.410 + aMxMxDestAG=aMxMxDestAG*aMxMxDestMultAlpha;\
1.411 + TUint32 srcAG=(aMxMxSrcPixel&0xFF00FF00)>>8;\
1.412 + aMxMxDestAG&=0xFF00FF00;\
1.413 + TUint32 alphaPlus1=aMxMxAlpha+1;\
1.414 + aMxMxDestAG+=srcAG*alphaPlus1;\
1.415 + aMxMxDestRB=aMxMxDestPixel&0x00FF00FF;\
1.416 + aMxMxDestRB=aMxMxDestRB*aMxMxDestMultAlpha;\
1.417 + aMxMxDestRB&=0xFF00FF00;\
1.418 + TUint32 srcRB=(aMxMxSrcPixel&0x00FF00FF);\
1.419 + aMxMxDestRB+=srcRB*alphaPlus1;\
1.420 + aMxMxDestRB>>=8;\
1.421 + }
1.422 +
1.423 +// Used For non MAP source blending using dest=src*alpha+dest*(1-alpha)
1.424 +#define CalcMxToMxRGBA(aSrc, aDest, aAlpha, aDestAG, aDestRB)\
1.425 + {\
1.426 + const TUint32 srcPixel=*(TUint32*)aSrc;\
1.427 + const TUint32 dstPixel=*(TUint32*)aDst;\
1.428 + const TUint32 oneMinusAlpha = 0x100 - aAlpha;\
1.429 + CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, oneMinusAlpha , aDestAG, aDestRB);\
1.430 + }
1.431 +
1.432 +#define WriteMu(aDestAG, aDestRB, aDst)\
1.433 + *(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF)|0xFF000000
1.434 +
1.435 +#define WriteMxA(aDestG, aDestRB, aDestA, aDst)\
1.436 + *(TUint32*)aDst=(aDestG&0x0000FF00)|(aDestRB&0x00FF00FF)|(aDestA&0xFF000000)
1.437 +
1.438 +#define WriteMx(aDestAG, aDestRB, aDst)\
1.439 + *(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF)
1.440 +
1.441 +struct TMapToMu
1.442 + {
1.443 + #define writeMapMu(aSrc, aDst)\
1.444 + {\
1.445 + const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
1.446 + TUint32 d1;\
1.447 + TUint32 d2;\
1.448 + CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\
1.449 + WriteMu(d1,d2,aDst);\
1.450 + }
1.451 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.452 + {
1.453 + const TUint32 src=*(TUint32*)aSrc;
1.454 +#if defined(__CHECK_ALPHA01__)
1.455 + if (src >= 0xFF000000)
1.456 + {
1.457 + *(TUint32*)aDst = src;
1.458 + return;
1.459 + }
1.460 + if (src <= 0x00FFFFFF)
1.461 + return;
1.462 +#endif
1.463 + writeMapMu(src, aDst);
1.464 + }
1.465 + WRITE_ALPHA_MASK_RUN_ROT32
1.466 + WRITE_RUN2ROT
1.467 + WRITE_RUN
1.468 + WRITE_RUN2H
1.469 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.470 + {
1.471 + TUint32 src=*(TUint32*)aSrc;
1.472 +#if defined(__CHECK_ALPHA01__)
1.473 + if (src>0x00FFFFFF)
1.474 +#endif
1.475 + {
1.476 + MultMapSrcByAlpha(aAlpha,src);
1.477 + // No aAlpha==0xFF check as should never come here in that situation
1.478 + writeMapMu(src, aDst);
1.479 + }
1.480 + }
1.481 + WRITE_ALPHA_MASK_RUN
1.482 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.483 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.484 + };
1.485 +
1.486 +struct TMapToMa
1.487 + {
1.488 + #define writeMapMa(aSrc, aDst)\
1.489 + {\
1.490 + const TUint32 d=*(TUint32*)aDst;\
1.491 + TUint32 da;\
1.492 + TUint32 destMultAlpha;\
1.493 + CalcDestMultAlpha(destMultAlpha,da,aSrc>>24,d>>24);\
1.494 + TUint32 d1;\
1.495 + TUint32 d2;\
1.496 + CalcMapToMxRGBA(aSrc,aDst,destMultAlpha,d1,d2);\
1.497 + WriteMxA(d1,d2,da,aDst);\
1.498 + }
1.499 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.500 + {
1.501 + const TUint32 src=*(TUint32*)aSrc;
1.502 +#if defined(__CHECK_ALPHA01__)
1.503 + if (src>0x00FFFFFF)
1.504 + {
1.505 + if (src >= 0xFF000000)
1.506 + *(TUint32*)aDst=src;
1.507 + else
1.508 + writeMapMa(src,aDst);
1.509 + }
1.510 +#else
1.511 + writeMapMa(src,aDst);
1.512 +#endif
1.513 + }
1.514 + WRITE_RUN
1.515 + WRITE_ALPHA_MASK_RUN_ROT32
1.516 + WRITE_RUN2ROT
1.517 + WRITE_RUN2H
1.518 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.519 + {
1.520 + TUint32 src=*(TUint32*)aSrc;
1.521 +#if defined(__CHECK_ALPHA01__)
1.522 + if (src>0x00FFFFFF)
1.523 +#endif
1.524 + {
1.525 + MultMapSrcByAlpha(aAlpha,src);
1.526 + // No aAlpha==0xFF check as should never come here in that situation
1.527 + writeMapMa(src,aDst);
1.528 + }
1.529 + }
1.530 + WRITE_ALPHA_MASK_RUN
1.531 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.532 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.533 + };
1.534 +
1.535 +struct TMapToMap
1.536 + {
1.537 + #define writeMapMap(aSrc, aDst)\
1.538 + {\
1.539 + const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
1.540 + TUint32 d1;\
1.541 + TUint32 d2;\
1.542 + CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\
1.543 + WriteMx(d1,d2,aDst);\
1.544 + }
1.545 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.546 + {
1.547 + const TUint32 src=*(TUint32*)aSrc;
1.548 +#if defined(__CHECK_ALPHA01__)
1.549 + if (src >= 0xFF000000)
1.550 + {
1.551 + *(TUint32*)aDst = src;
1.552 + return;
1.553 + }
1.554 + if (src <= 0x00FFFFFF)
1.555 + return;
1.556 +#endif
1.557 + writeMapMap(src,aDst);
1.558 + }
1.559 + WRITE_RUN
1.560 + WRITE_ALPHA_MASK_RUN_ROT32
1.561 + WRITE_RUN2ROT
1.562 + WRITE_RUN2H
1.563 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.564 + {
1.565 + TUint32 src=*(TUint32*)aSrc;
1.566 +#if defined(__CHECK_ALPHA01__)
1.567 + if (src<=0x00FFFFFF)
1.568 + return;
1.569 +#endif
1.570 + MultMapSrcByAlpha(aAlpha,src);
1.571 + // No aAlpha==0xFF check as should never come here in that situation
1.572 + writeMapMap(src,aDst);
1.573 + }
1.574 + WRITE_ALPHA_MASK_RUN
1.575 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.576 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.577 + };
1.578 +
1.579 +struct TMaToMu
1.580 + {
1.581 + #define writeMaMu(aSrc, aAlpha, aDst)\
1.582 + {\
1.583 + TUint32 d1;\
1.584 + TUint32 d2;\
1.585 + CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\
1.586 + WriteMu(d1,d2,aDst);\
1.587 + }
1.588 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.589 + {
1.590 + const TUint32 src=*(TUint32*)aSrc;
1.591 +#if defined(__CHECK_ALPHA01__)
1.592 + if (src >= 0xFF000000)
1.593 + {
1.594 + *(TUint32*)aDst = src;
1.595 + return;
1.596 + }
1.597 + if (src <= 0x00FFFFFF)
1.598 + return;
1.599 +#endif
1.600 + const TUint32 alpha=src>>24;
1.601 + writeMaMu(aSrc,alpha,aDst);
1.602 + }
1.603 + WRITE_RUN
1.604 + WRITE_ALPHA_MASK_RUN_ROT32
1.605 + WRITE_RUN2ROT
1.606 + WRITE_RUN2H
1.607 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.608 + {
1.609 + MultAlphaWithSrcAlpha(aAlpha,aSrc);
1.610 + writeMaMu(aSrc,aAlpha,aDst);
1.611 + }
1.612 + WRITE_ALPHA_MASK_RUN
1.613 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.614 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.615 + };
1.616 +
1.617 +struct TMuToMu
1.618 + {
1.619 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.620 + {
1.621 + *(TUint32*)aDst = *(TUint32*)aSrc;
1.622 + }
1.623 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
1.624 + {
1.625 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.626 + aSrc+=aLen*4;
1.627 + aDst+=aLen*4;
1.628 + }
1.629 + FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
1.630 + {
1.631 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.632 + }
1.633 + WRITE_ALPHA_MASK_RUN_ROT32
1.634 + WRITE_RUN2ROT
1.635 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.636 + {
1.637 + TUint32 d1;
1.638 + TUint32 d2;
1.639 + CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);
1.640 + WriteMu(d1,d2,aDst);
1.641 + }
1.642 + WRITE_ALPHA_MASK_RUN
1.643 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.644 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.645 + };
1.646 +
1.647 +struct TMuToMa
1.648 + {
1.649 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.650 + {
1.651 + *(TUint32*)aDst = (*(TUint32*)aSrc);
1.652 + }
1.653 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
1.654 + {
1.655 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.656 + aSrc+=aLen*4;
1.657 + aDst+=aLen*4;
1.658 + }
1.659 + FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
1.660 + {
1.661 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.662 + }
1.663 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.664 + {
1.665 + TUint32 da;
1.666 + TUint32 d1;
1.667 + TUint32 d2;
1.668 + TUint32 destMultAlpha;
1.669 + const TUint32 d = *(TUint32*)aDst;
1.670 + CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24);
1.671 + const TUint32 srcPixel=*(TUint32*)aSrc;
1.672 + const TUint32 dstPixel=*(TUint32*)aDst;
1.673 + CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2);
1.674 + WriteMxA(d1,d2,da,aDst);
1.675 + }
1.676 + WRITE_ALPHA_MASK_RUN
1.677 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.678 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.679 + };
1.680 +
1.681 +struct TMaToMa
1.682 + {
1.683 + #define writeMaMa(aSrc, aAlpha, aDst)\
1.684 + {\
1.685 + TUint32 da;\
1.686 + TUint32 d1;\
1.687 + TUint32 d2;\
1.688 + TUint32 destMultAlpha;\
1.689 + const TUint32 d = *(TUint32*)aDst;\
1.690 + CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24);\
1.691 + const TUint32 srcPixel=*(TUint32*)aSrc;\
1.692 + const TUint32 dstPixel=*(TUint32*)aDst;\
1.693 + CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2);\
1.694 + WriteMxA(d1,d2,da,aDst);\
1.695 + }
1.696 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.697 + {
1.698 + const TUint32 src=*(TUint32*)aSrc;
1.699 +#if defined(__CHECK_ALPHA01__)
1.700 + if (src >= 0xFF000000)
1.701 + {
1.702 + *(TUint32*)aDst = src;
1.703 + return;
1.704 + }
1.705 + if (src <= 0x00FFFFFF)
1.706 + return;
1.707 +#endif
1.708 + const TUint32 alpha=src>>24;
1.709 + writeMaMa(aSrc,alpha,aDst);
1.710 + }
1.711 + WRITE_RUN
1.712 + WRITE_ALPHA_MASK_RUN_ROT32
1.713 + WRITE_RUN2ROT
1.714 + WRITE_RUN2H
1.715 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.716 + {
1.717 + MultAlphaWithSrcAlpha(aAlpha,aSrc);
1.718 + writeMaMa(aSrc,aAlpha,aDst);
1.719 + }
1.720 + WRITE_ALPHA_MASK_RUN
1.721 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.722 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.723 + };
1.724 +
1.725 +struct TMaToMap
1.726 + {
1.727 + #define writeMaToMap(aSrc, aAlpha, aDst)\
1.728 + {\
1.729 + const TUint32 d = *(TUint32*)aDst;\
1.730 + const TUint32 oneMinusAlpha = 0x100-aAlpha;\
1.731 + TUint32 da=(d&0xFF000000)>>8;\
1.732 + da=da*oneMinusAlpha;\
1.733 + da+=aAlpha<<24;\
1.734 + TUint32 d1;\
1.735 + TUint32 d2;\
1.736 + CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\
1.737 + WriteMxA(d1,d2,da,aDst);\
1.738 + }
1.739 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.740 + {
1.741 + const TUint32 src=*(TUint32*)aSrc;
1.742 +#if defined(__CHECK_ALPHA01__)
1.743 + if (src >= 0xFF000000)
1.744 + {
1.745 + *(TUint32*)aDst = src;
1.746 + return;
1.747 + }
1.748 + if (src <= 0x00FFFFFF)
1.749 + return;
1.750 +#endif
1.751 + const TUint32 alpha=src>>24;
1.752 + writeMaToMap(aSrc,alpha,aDst);
1.753 + }
1.754 + WRITE_RUN
1.755 + WRITE_ALPHA_MASK_RUN_ROT32
1.756 + WRITE_RUN2ROT
1.757 + WRITE_RUN2H
1.758 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.759 + {
1.760 + MultAlphaWithSrcAlpha(aAlpha,aSrc);
1.761 + writeMaToMap(aSrc,aAlpha,aDst);
1.762 + }
1.763 + WRITE_ALPHA_MASK_RUN
1.764 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.765 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.766 + };
1.767 +
1.768 +struct TMuToMap
1.769 + {
1.770 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.771 + {
1.772 + *(TUint32*)aDst = (*(TUint32*)aSrc);
1.773 + }
1.774 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
1.775 + {
1.776 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.777 + aSrc+=aLen*4;
1.778 + aDst+=aLen*4;
1.779 + }
1.780 + FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
1.781 + {
1.782 + Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
1.783 + }
1.784 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.785 + {
1.786 + TUint32 d1;
1.787 + TUint32 d2;
1.788 + CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);
1.789 + WriteMx(d1,d2,aDst);
1.790 + }
1.791 + WRITE_ALPHA_MASK_RUN_ROT32
1.792 + WRITE_RUN2ROT
1.793 + WRITE_ALPHA_MASK_RUN
1.794 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.795 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.796 + };
1.797 +
1.798 +WRITE_RUN2C(TMapToMap)
1.799 +WRITE_RUN2C(TMapToMa)
1.800 +WRITE_RUN2C(TMapToMu)
1.801 +WRITE_RUN2C(TMaToMap)
1.802 +WRITE_RUN2C(TMaToMa)
1.803 +WRITE_RUN2C(TMaToMu)
1.804 +
1.805 +// reads green value from 64K source, or's it with 0xFF alpha channel, and leaves
1.806 +// it shifted down by 8 ready for multiplying by alpha value.
1.807 +#define ReadGreen64K(aRG64KGreen, aRG64KSrc)\
1.808 + aRG64KGreen=(aRG64KSrc&0x07E0)>>3;\
1.809 + aRG64KGreen=((aRG64KGreen+(aRG64KGreen>>6))&0x000000FF)|0x00FF0000;
1.810 +
1.811 +// Reads the red and blue values from a 64K source into their RGBA values.
1.812 +#define ReadRedBlue64K(aRedBlue,aColor64K)\
1.813 + {\
1.814 + aRedBlue=(aColor64K&0xF800)<<8;\
1.815 + aRedBlue|=(aColor64K&0x001F)<<3;\
1.816 + aRedBlue+=aRedBlue>>5;\
1.817 + aRedBlue&=0x00FF00FF;\
1.818 + }
1.819 +
1.820 +// reads green value from 64K source into aGreen and red and blue into aRedBlue
1.821 +// All left in correct place for 16M operations
1.822 +#define Read64KColors(aGreen,aRedBlue,aPtr)\
1.823 + {\
1.824 + const TUint32 r64Kcolor64K=*(TUint16*)aPtr;\
1.825 + aGreen=(r64Kcolor64K&0x07E0)<<5;\
1.826 + aGreen+=aGreen>>6;\
1.827 + aGreen&=0x0000FF00;\
1.828 + ReadRedBlue64K(aRedBlue,r64Kcolor64K);\
1.829 + }
1.830 +
1.831 +struct TMapTo64K
1.832 + {
1.833 + #define writeMap64K(aSrc, aDst)\
1.834 + {\
1.835 + TUint32 green;\
1.836 + TUint32 redBlue;\
1.837 + Read64KColors(green,redBlue,aDst);\
1.838 + const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
1.839 + green=green*oneMinusAlpha;\
1.840 + green+=(aSrc<<8)&0x00FF00FF;\
1.841 + redBlue=redBlue*oneMinusAlpha;\
1.842 + redBlue+=(aSrc&0x00FF00FF)<<8;\
1.843 + WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\
1.844 + }
1.845 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.846 + {
1.847 + const TUint32 src=*(TUint32*)aSrc;
1.848 +#if defined(__CHECK_ALPHA01__)
1.849 + if (src >= 0xFF000000)
1.850 + {
1.851 + Write16MTo64K(src,aDst);
1.852 + return;
1.853 + }
1.854 + if (src <= 0x00FFFFFF)
1.855 + return;
1.856 +#endif
1.857 + writeMap64K(src,aDst);
1.858 + }
1.859 + WRITE_RUN2H
1.860 + WRITE_RUN3216
1.861 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.862 + {
1.863 + TUint32 src=*(TUint32*)aSrc;
1.864 +#if defined(__CHECK_ALPHA01__)
1.865 + if (src<=0x00FFFFFF)
1.866 + return;
1.867 +#endif
1.868 + MultMapSrcByAlpha(aAlpha,src);
1.869 + // No aAlpha==0xFF check as should never come here in that situation
1.870 + writeMap64K(src,aDst);
1.871 + }
1.872 + WRITE_ALPHA_MASK_RUN3216
1.873 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.874 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
1.875 + };
1.876 +
1.877 +// Calculates green and redBlue shifted up by 8, that will be sorted in WriteRedBlueAndGreenTo64K
1.878 +// this works out the most efficient way of getting the end result
1.879 +//
1.880 +// Note +++
1.881 +// Having the extra +greenSrc and +redBlueSrc (as in lines shown below) gives a better result, but
1.882 +// is inconsistent with old code and causes test code failures, so it has been removed.
1.883 +// greenSrc=greenSrc*aAlpha+greenSrc;
1.884 +// redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.885 +#define WriteMaOrMuTo64K(aSrc, aDst, aAlpha)\
1.886 + {\
1.887 + const TUint32 src=*(TUint32*)aSrc;\
1.888 + TUint32 green;\
1.889 + TUint32 redBlue;\
1.890 + Read64KColors(green,redBlue,aDst);\
1.891 + const TUint32 oneMinusAlpha = 0x100-aAlpha;\
1.892 + green=green*oneMinusAlpha;\
1.893 + TUint32 greenSrc=src&0x0000FF00;\
1.894 + greenSrc=greenSrc*aAlpha;\
1.895 + green+=greenSrc;\
1.896 + redBlue=redBlue*oneMinusAlpha;\
1.897 + TUint32 redBlueSrc=src&0x00FF00FF;\
1.898 + redBlueSrc=redBlueSrc*aAlpha;\
1.899 + redBlue+=redBlueSrc;\
1.900 + WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\
1.901 + }
1.902 +
1.903 +struct TMTo64K
1.904 + {
1.905 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.906 + {
1.907 + const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16);
1.908 + Write16MTo64K(src,aDst);
1.909 + }
1.910 + WRITE_RUN2416
1.911 + WRITE_RUN2H
1.912 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.913 + {
1.914 + const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16);
1.915 + TUint32 green;
1.916 + TUint32 redBlue;
1.917 + Read64KColors(green,redBlue,aDst);
1.918 + const TUint32 oneMinusAlpha = 0x100-aAlpha;
1.919 + green=green*oneMinusAlpha;
1.920 + TUint32 greenSrc=src&0x0000FF00;
1.921 + greenSrc=greenSrc*aAlpha+greenSrc;
1.922 + green+=greenSrc;
1.923 + redBlue=redBlue*oneMinusAlpha;
1.924 + TUint32 redBlueSrc=src&0x00FF00FF;
1.925 + redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.926 + redBlue+=redBlueSrc;
1.927 + WriteRedBlueAndGreenTo64K(redBlue,green,aDst);
1.928 + }
1.929 + WRITE_ALPHA_MASK_RUN2416
1.930 + FORCEINLINE static TInt SrcPixelBytes() {return(3);};
1.931 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
1.932 + };
1.933 +
1.934 +struct TMuTo64K
1.935 + {
1.936 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.937 + {
1.938 + const TUint32 src=*(TUint32*)aSrc;
1.939 + Write16MTo64K(src,aDst);
1.940 + }
1.941 + WRITE_RUN3216
1.942 + WRITE_RUN2H
1.943 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.944 + {
1.945 + WriteMaOrMuTo64K(aSrc,aDst,aAlpha);
1.946 + }
1.947 + WRITE_ALPHA_MASK_RUN3216
1.948 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.949 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
1.950 + };
1.951 +
1.952 +struct TMaTo64K
1.953 + {
1.954 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.955 + {
1.956 + const TUint32 src=*(TUint32*)aSrc;
1.957 +#if defined(__CHECK_ALPHA01__)
1.958 + if (src >= 0xFF000000)
1.959 + {
1.960 + Write16MTo64K(src,aDst);
1.961 + return;
1.962 + }
1.963 + if (src <= 0x00FFFFFF)
1.964 + return;
1.965 +#endif
1.966 + const TUint32 alpha=src>>24;
1.967 + WriteMaOrMuTo64K(aSrc,aDst,alpha);
1.968 + }
1.969 + WRITE_RUN3216
1.970 + WRITE_RUN2H
1.971 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.972 + {
1.973 + MultAlphaWithSrcAlpha(aAlpha,aSrc);
1.974 + WriteMaOrMuTo64K(aSrc,aDst,aAlpha);
1.975 + }
1.976 + WRITE_ALPHA_MASK_RUN3216
1.977 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
1.978 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
1.979 + };
1.980 +
1.981 +struct T64KTo64K
1.982 + {
1.983 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.984 + {
1.985 + *(TUint16*)aDst=*(const TUint16 *)aSrc;
1.986 + }
1.987 + FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
1.988 + {
1.989 + Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16));
1.990 + aSrc+=aLen*2;
1.991 + aDst+=aLen*2;
1.992 + }
1.993 + FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
1.994 + {
1.995 + Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16));
1.996 + }
1.997 + WRITE_ALPHA_MASK_RUN_ROT16
1.998 + WRITE_RUN2ROT
1.999 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.1000 + {
1.1001 + const TUint32 oneMinusAlpha = 0x100-aAlpha;
1.1002 +//
1.1003 + TUint32 green;
1.1004 + TUint32 redBlue;
1.1005 + Read64KColors(green,redBlue,aDst);
1.1006 + green=green*oneMinusAlpha;
1.1007 + TUint32 greenSrc;
1.1008 + TUint32 redBlueSrc;
1.1009 + Read64KColors(greenSrc,redBlueSrc,aSrc);
1.1010 +// See note +++
1.1011 +// greenSrc=greenSrc*aAlpha+greenSrc;
1.1012 + greenSrc=greenSrc*aAlpha;
1.1013 + green+=greenSrc; // needs shift down by 8, but do that when going to 64K
1.1014 +//
1.1015 + redBlue=redBlue*oneMinusAlpha;
1.1016 +// See note +++
1.1017 +// redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.1018 + redBlueSrc=redBlueSrc*aAlpha;
1.1019 + redBlue+=redBlueSrc; // needs shift down by 8, but do that when going to 64K
1.1020 + WriteRedBlueAndGreenTo64K(redBlue,green,aDst);
1.1021 + }
1.1022 + WRITE_ALPHA_MASK_RUN1616
1.1023 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
1.1024 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
1.1025 + };
1.1026 +
1.1027 +#define Write64KTo16M(aSrc, aDst)\
1.1028 + TUint32 w6216Mgreen;\
1.1029 + TUint32 w6216MredBlue;\
1.1030 + Read64KColors(w6216Mgreen,w6216MredBlue, aSrc);\
1.1031 + WriteMu(w6216Mgreen,w6216MredBlue,aDst);
1.1032 +
1.1033 +#define Write64KTo16MLookup(aSrc, aDst, aLowAdd, aHighAdd)\
1.1034 + {\
1.1035 + const TUint32 srcData=*(TUint16*)aSrc;\
1.1036 + *(TUint32*)aDst = aHighAdd[srcData>>8] | aLowAdd[srcData&0xff];\
1.1037 + }
1.1038 +
1.1039 +struct T64KToMu
1.1040 + {
1.1041 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.1042 + {
1.1043 + Write64KTo16M(aSrc,aDst);
1.1044 + }
1.1045 + WRITE_RUN1632
1.1046 + WRITE_RUN2H
1.1047 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.1048 + {
1.1049 + const TUint32 oneMinusAlpha = 0x100-aAlpha;
1.1050 + const TUint32 d = *(TUint32*)aDst;
1.1051 + TUint32 src=*(TUint16*)aSrc;
1.1052 +//
1.1053 + TUint32 green = (d&0x0000FF00)>>8;
1.1054 + green=green*oneMinusAlpha;
1.1055 + TUint32 greenSrc;
1.1056 + ReadGreen64K(greenSrc,src);
1.1057 +// See note +++
1.1058 +// greenSrc=greenSrc*aAlpha+greenSrc;
1.1059 + greenSrc=greenSrc*aAlpha;
1.1060 + green+=greenSrc;
1.1061 +//
1.1062 + TUint32 redBlue = d&0x00FF00FF;
1.1063 + redBlue=redBlue*oneMinusAlpha;
1.1064 + TUint32 redBlueSrc;
1.1065 + ReadRedBlue64K(redBlueSrc,src);
1.1066 +// See note +++
1.1067 +// redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.1068 + redBlueSrc=redBlueSrc*aAlpha;
1.1069 + redBlue+=redBlueSrc;
1.1070 +//
1.1071 + redBlue>>=8;
1.1072 + WriteMu(green,redBlue,aDst);
1.1073 + }
1.1074 + WRITE_ALPHA_MASK_RUN1632
1.1075 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
1.1076 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.1077 + };
1.1078 +
1.1079 +struct T64KToMa
1.1080 + {
1.1081 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.1082 + {
1.1083 + Write64KTo16M(aSrc,aDst);
1.1084 + }
1.1085 + WRITE_RUN1632
1.1086 + WRITE_RUN2H
1.1087 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.1088 + {
1.1089 + const TUint32 destSrc = *(TUint32*)aDst;
1.1090 + TUint32 destAlpha=destSrc>>24;
1.1091 +// Calc new alpha as src+(1-src)*dst;
1.1092 + destAlpha=(0x100-aAlpha)*destAlpha;
1.1093 + TUint32 targDestPixel=(destAlpha>>8)<<24;
1.1094 + targDestPixel+=aAlpha<<24;
1.1095 +//
1.1096 + TUint32 greenAlpha=(destSrc>>8)&0x000000FF;
1.1097 + const TUint32 destMultAlpha = (destAlpha>>8)+1;
1.1098 + greenAlpha=greenAlpha*destMultAlpha;
1.1099 + TUint32 redBlue = destSrc&0x00FF00FF;
1.1100 + redBlue=redBlue*destMultAlpha;
1.1101 +//
1.1102 + TUint32 src=*(TUint16*)aSrc;
1.1103 + TUint32 greenSrc;
1.1104 + ReadGreen64K(greenSrc,src);
1.1105 + greenSrc=greenSrc*aAlpha+greenSrc;
1.1106 + greenAlpha+=greenSrc;
1.1107 + targDestPixel|=greenAlpha&0x0000FF00;
1.1108 +//
1.1109 + TUint32 redBlueSrc;
1.1110 + ReadRedBlue64K(redBlueSrc,src);
1.1111 + redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.1112 + redBlue+=redBlueSrc;
1.1113 +//
1.1114 + targDestPixel|=(redBlue>>8)&0x00FF00FF;
1.1115 + *(TUint32*)aDst=targDestPixel;
1.1116 + }
1.1117 + WRITE_ALPHA_MASK_RUN1632H
1.1118 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
1.1119 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.1120 + };
1.1121 +
1.1122 +WRITE_ALPHA_MASK_RUN1632C(T64KToMa)
1.1123 +
1.1124 +struct T64KToMap
1.1125 + {
1.1126 + FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
1.1127 + {
1.1128 + Write64KTo16M(aSrc,aDst);
1.1129 + }
1.1130 + WRITE_RUN1632
1.1131 + WRITE_RUN2H
1.1132 + FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
1.1133 + {
1.1134 + const TUint32 oneMinusAlpha = 0x100-aAlpha;
1.1135 + const TUint32 d = *(TUint32*)aDst;
1.1136 + TUint32 src=*(TUint16*)aSrc;
1.1137 +//
1.1138 + TUint32 greenAlpha = (d&0xFF00FF00)>>8;
1.1139 + greenAlpha=greenAlpha*oneMinusAlpha;
1.1140 + TUint32 greenSrc;
1.1141 + ReadGreen64K(greenSrc,src);
1.1142 + greenSrc=greenSrc*aAlpha+greenSrc;
1.1143 + greenAlpha&=0xFF00FF00; // Needed to stop adding rounding errors together in next step
1.1144 + greenAlpha+=greenSrc;
1.1145 +//
1.1146 + TUint32 redBlue = d&0x00FF00FF;
1.1147 + redBlue=redBlue*oneMinusAlpha;
1.1148 + TUint32 redBlueSrc;
1.1149 + ReadRedBlue64K(redBlueSrc,src);
1.1150 + redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
1.1151 + redBlue&=0xFF00FF00; // Needed to stop adding rounding errors together in next step
1.1152 + redBlue+=redBlueSrc; // needs shift down by 8, but do that when writing to dest
1.1153 +//
1.1154 + redBlue>>=8;
1.1155 + WriteMx(greenAlpha,redBlue,aDst);
1.1156 + }
1.1157 + WRITE_ALPHA_MASK_RUN1632
1.1158 + FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
1.1159 + FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
1.1160 + };
1.1161 +
1.1162 +WRITE_RUN1632C(T64KToMap)
1.1163 +WRITE_RUN1632C(T64KToMa)
1.1164 +WRITE_RUN1632C(T64KToMu)
1.1165 +WRITE_RUN3216C2(TMapTo64K)
1.1166 +WRITE_RUN3216C2(TMaTo64K)
1.1167 +WRITE_RUN3216C2(TMuTo64K)
1.1168 +WRITE_RUN2416C2(TMTo64K)
1.1169 +
1.1170 +inline TInt InitDda(TInt &aDdaCount, TBool &aStretching, TInt aSrcValue, TInt aDstValue, TInt aSkipSteps)
1.1171 + {
1.1172 + aDdaCount=0;
1.1173 + aStretching=aDstValue>aSrcValue;
1.1174 + TInt skip=0;
1.1175 + if (aStretching)
1.1176 + {
1.1177 + aDdaCount=aDstValue-1;
1.1178 + while(aSkipSteps--)
1.1179 + {
1.1180 + aDdaCount-=aSrcValue;
1.1181 + if (aDdaCount<0)
1.1182 + {
1.1183 + skip++;
1.1184 + aDdaCount+=aDstValue;
1.1185 + }
1.1186 + }
1.1187 + }
1.1188 + else
1.1189 + {
1.1190 + aDdaCount=aSrcValue-1;
1.1191 + while(aSkipSteps)
1.1192 + {
1.1193 + aDdaCount-=aDstValue;
1.1194 + if (aDdaCount<0)
1.1195 + {
1.1196 + aSkipSteps--;
1.1197 + aDdaCount+=aSrcValue;
1.1198 + }
1.1199 + skip++;
1.1200 + }
1.1201 + }
1.1202 + return(skip);
1.1203 + }
1.1204 +
1.1205 +inline void DdaStep(TInt &aDdaCount, TBool aStretching, TInt aSrcValue, TInt aDstValue, TInt &aSkipCount)
1.1206 + {
1.1207 + if (aStretching)
1.1208 + {
1.1209 + aDdaCount-=aSrcValue;
1.1210 + if (aDdaCount<0)
1.1211 + {
1.1212 + aSkipCount++;
1.1213 + aDdaCount+=aDstValue;
1.1214 + }
1.1215 + }
1.1216 + else
1.1217 + {
1.1218 + do
1.1219 + {
1.1220 + aSkipCount++;
1.1221 + aDdaCount-=aDstValue;
1.1222 + } while(aDdaCount>=0);
1.1223 + aDdaCount+=aSrcValue;
1.1224 + }
1.1225 + }
1.1226 +
1.1227 +template <class op>
1.1228 +static void ScaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, TRect& aDstRect, const TRect &aClipRect)
1.1229 + {
1.1230 + TInt srcWidth = aSrcRect.Width();
1.1231 + TInt srcHeight = aSrcRect.Height();
1.1232 + TInt dstWidth = aDstRect.Width();
1.1233 + TInt dstHeight = aDstRect.Height();
1.1234 +//
1.1235 + TInt yDdaCount;
1.1236 + TBool yStretching;
1.1237 + TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
1.1238 +//
1.1239 + TInt xDdaCountBase;
1.1240 + TBool xStretching;
1.1241 + TInt sxOffset=aSrcRect.iTl.iX+InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
1.1242 + sxOffset*=op::SrcPixelBytes();
1.1243 +//
1.1244 + const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
1.1245 + const TInt xCount=aClipRect.Width();
1.1246 + TUint8* dstPixelBase = aDataAddress + aDstStride*aClipRect.iTl.iY + aClipRect.iTl.iX*op::DestPixelBytes();
1.1247 + for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
1.1248 + {
1.1249 + const TUint8* srcPixel = aSrcBase + aSrcStride*ySrcOffset + sxOffset;
1.1250 + TUint8* dstPixel = dstPixelBase;
1.1251 + TInt xCountDown=xCount;
1.1252 + TInt ddaCount = xDdaCountBase;
1.1253 + if (xStretching)
1.1254 + {
1.1255 + do
1.1256 + {
1.1257 + op::write(srcPixel, dstPixel);
1.1258 + dstPixel+=op::DestPixelBytes();
1.1259 + ddaCount-=srcWidth;
1.1260 + if (ddaCount<0)
1.1261 + {
1.1262 + srcPixel+=op::SrcPixelBytes();
1.1263 + ddaCount+=dstWidth;
1.1264 + }
1.1265 + } while(--xCountDown);
1.1266 + }
1.1267 + else
1.1268 + {
1.1269 + do
1.1270 + {
1.1271 + op::write(srcPixel, dstPixel);
1.1272 + dstPixel+=op::DestPixelBytes();
1.1273 + do
1.1274 + {
1.1275 + srcPixel+=op::SrcPixelBytes();
1.1276 + ddaCount-=dstWidth;
1.1277 + } while(ddaCount>=0);
1.1278 + ddaCount+=srcWidth;
1.1279 + } while(--xCountDown);
1.1280 + }
1.1281 + dstPixelBase+=aDstStride;
1.1282 + DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
1.1283 + }
1.1284 + }
1.1285 +
1.1286 +template <class op>
1.1287 +static void UnscaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos)
1.1288 + {
1.1289 + const TInt blitWidth = aSrcRect.Width();
1.1290 + const TUint8* srcPixel = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes();
1.1291 + TUint8* dstPixel = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes();
1.1292 + const TUint8* dstPixelEnd = dstPixel+aSrcRect.Height()*aDstStride;
1.1293 + do
1.1294 + {
1.1295 + op::write2(srcPixel,dstPixel,blitWidth);
1.1296 + srcPixel+=aSrcStride;
1.1297 + dstPixel+=aDstStride;
1.1298 + } while(dstPixel<dstPixelEnd);
1.1299 + }
1.1300 +
1.1301 +static void ReplaceBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos)
1.1302 + {
1.1303 + TInt srcStride=aSrcStride/4;
1.1304 + TInt dstStride=aDstStride/4;
1.1305 + TInt dx = aDstPos.iX;
1.1306 + TInt dstWidth = aSrcRect.Width();
1.1307 + const TUint32* srcPixel = reinterpret_cast<const TUint32*>(aSrcBase) + srcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX;
1.1308 + TUint32* dstPixel = ((TUint32*)aDataAddress) + dstStride*aDstPos.iY + dx;
1.1309 + const TInt copyLen=dstWidth*4;
1.1310 + for (TInt linesToGo=aSrcRect.Height();linesToGo;--linesToGo)
1.1311 + {
1.1312 + // Andy - not convinced that this function is any good atall
1.1313 + // try stdlib memcpy instead.
1.1314 + Mem::Move(dstPixel, srcPixel, copyLen);
1.1315 + srcPixel+=srcStride;
1.1316 + dstPixel+=dstStride;
1.1317 + }
1.1318 + }
1.1319 +
1.1320 +template <class op>
1.1321 +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)
1.1322 + {
1.1323 + TInt srcStep=op::SrcPixelBytes();
1.1324 + TInt dstStep=op::DestPixelBytes();
1.1325 + TInt dstStride=aDstStride;
1.1326 + TInt blitWidth = aSrcRect.Width();
1.1327 + TInt blitHeight = aSrcRect.Height();
1.1328 + const TUint8* srcPixel = aSrcBase + aSrcRect.iTl.iY*aSrcStride + aSrcRect.iTl.iX*srcStep;
1.1329 + const TUint8* srcPixelEnd = srcPixel + blitHeight*aSrcStride;
1.1330 + TUint8* dstPixel = aDataAddress;
1.1331 +
1.1332 +
1.1333 + switch(aOrientation)
1.1334 + {
1.1335 + case CFbsDrawDevice::EOrientationRotated90:
1.1336 + dstPixel += (aDstPos.iX*aDstStride + (aDestSize.iWidth-aDstPos.iY-1)*op::DestPixelBytes());
1.1337 + dstStep = aDstStride;
1.1338 + dstStride = - op::DestPixelBytes();
1.1339 + break;
1.1340 + case CFbsDrawDevice::EOrientationRotated180:
1.1341 + dstPixel += ( (aDestSize.iHeight - aDstPos.iY -1 )*aDstStride +(aDestSize.iWidth - aDstPos.iX -1)*op::DestPixelBytes() ) ;
1.1342 + dstStep = -dstStep;
1.1343 + dstStride = -aDstStride;
1.1344 + break;
1.1345 + case CFbsDrawDevice::EOrientationRotated270:
1.1346 + dstPixel += ( (aDestSize.iHeight- aDstPos.iX - 1 )*aDstStride + aDstPos.iY*op::DestPixelBytes() ) ;
1.1347 + dstStep = -aDstStride;
1.1348 + dstStride = op::DestPixelBytes();
1.1349 + break;
1.1350 + }
1.1351 + do
1.1352 + {
1.1353 + Mem::Copy(aScanLineBuffer, srcPixel, blitWidth*srcStep);
1.1354 + op::write2rot((TUint8*)aScanLineBuffer, dstPixel, blitWidth, srcStep, dstStep);
1.1355 + srcPixel+=aSrcStride;
1.1356 + dstPixel+=dstStride;
1.1357 + }
1.1358 + while(srcPixel<srcPixelEnd);
1.1359 + }
1.1360 +
1.1361 +template <class op>
1.1362 +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)
1.1363 + {
1.1364 + TInt sx = aSrcRect.iTl.iX;
1.1365 + TInt sxOffset=sx*op::SrcPixelBytes();
1.1366 +
1.1367 + TInt srcWidth = aSrcRect.Width();
1.1368 + TInt srcHeight = aSrcRect.Height();
1.1369 + TInt dstWidth = aDstRect.Width();
1.1370 + TInt dstHeight = aDstRect.Height();
1.1371 +//
1.1372 + TInt yDdaCount;
1.1373 + TBool yStretching;
1.1374 + TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
1.1375 +//
1.1376 + TInt xDdaCountBase;
1.1377 + TBool xStretching;
1.1378 + TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
1.1379 +//
1.1380 + const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
1.1381 + const TInt xCount=aClipRect.Width();
1.1382 + TUint8* dstPixelBase = aDataAddress+aDstStride*aClipRect.iTl.iY+aClipRect.iTl.iX*op::DestPixelBytes();
1.1383 + for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
1.1384 + {
1.1385 + const TUint8* srcPixel = aSrcBase+aSrcStride*ySrcOffset+sxOffset;
1.1386 + const TUint32* mskRowBase = (const TUint32*)(aMaskBase+aMaskStride*ySrcOffset);
1.1387 + TUint8* dstPixel = dstPixelBase;
1.1388 + TInt xCountDown=xCount;
1.1389 + TInt curMaskOffset=-1;
1.1390 + TUint32 maskbits=0;
1.1391 + TInt xOffset=xOffsetBase;
1.1392 + TInt ddaCount = xDdaCountBase;
1.1393 + if (xStretching)
1.1394 + {
1.1395 + do
1.1396 + {
1.1397 + const TInt maskOffset=xOffset+sx;
1.1398 + TInt maskBitOffset=maskOffset>>5;
1.1399 + if (curMaskOffset==maskBitOffset)
1.1400 + {
1.1401 +blitIt1: const TInt mask=1<<(maskOffset%32);
1.1402 + if (maskbits&mask)
1.1403 + op::write(srcPixel, dstPixel);
1.1404 + dstPixel+=op::DestPixelBytes();
1.1405 + ddaCount-=srcWidth;
1.1406 + if (ddaCount<0)
1.1407 + {
1.1408 + xOffset++;
1.1409 + srcPixel+=op::SrcPixelBytes();
1.1410 + ddaCount+=dstWidth;
1.1411 + }
1.1412 + continue;
1.1413 + }
1.1414 + maskbits=*(mskRowBase+maskBitOffset);
1.1415 + if (aInvertMask)
1.1416 + maskbits=~maskbits;
1.1417 + curMaskOffset=maskBitOffset;
1.1418 + goto blitIt1;
1.1419 + } while(--xCountDown);
1.1420 + }
1.1421 + else
1.1422 + {
1.1423 + do
1.1424 + {
1.1425 + const TInt maskOffset=xOffset+sx;
1.1426 + TInt maskBitOffset=maskOffset>>5;
1.1427 + if (curMaskOffset==maskBitOffset)
1.1428 + {
1.1429 +blitIt2: const TInt mask=1<<(maskOffset%32);
1.1430 + if (maskbits&mask)
1.1431 + op::write(srcPixel, dstPixel);
1.1432 + dstPixel+=op::DestPixelBytes();
1.1433 + do
1.1434 + {
1.1435 + xOffset++;
1.1436 + srcPixel+=op::SrcPixelBytes();
1.1437 + ddaCount-=dstWidth;
1.1438 + } while(ddaCount>=0);
1.1439 + ddaCount+=srcWidth;
1.1440 + continue;
1.1441 + }
1.1442 + maskbits=*(mskRowBase+maskBitOffset);
1.1443 + if (aInvertMask)
1.1444 + maskbits=~maskbits;
1.1445 + curMaskOffset=maskBitOffset;
1.1446 + goto blitIt2;
1.1447 + } while(--xCountDown);
1.1448 + }
1.1449 + dstPixelBase+=aDstStride;
1.1450 + DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
1.1451 + }
1.1452 + }
1.1453 +
1.1454 +template <class op>
1.1455 +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)
1.1456 + {
1.1457 + TInt sx = aSrcRect.iTl.iX;
1.1458 + TInt sy = aSrcRect.iTl.iY;
1.1459 + TInt dx = aDstPos.iX;
1.1460 + TInt dy = aDstPos.iY;
1.1461 +
1.1462 + TInt dstWidth = aSrcRect.Width();
1.1463 + TInt dstHeight = aSrcRect.Height();
1.1464 + TInt maskWidth=aMaskSize.iWidth;
1.1465 + TInt maskHeight=aMaskSize.iHeight;
1.1466 + TInt maskXStart=aMaskSrcPos.iX%maskWidth;
1.1467 + TInt maskStartShift=maskXStart&0x1F;
1.1468 + TInt xMaskLoopCount=1+(dstWidth-1)/maskWidth;
1.1469 + const TUint8* mskBasePtr=aMaskBase + (maskXStart/32)*4;
1.1470 + for(TInt xMaskLoop=0;xMaskLoop<xMaskLoopCount;xMaskLoop++)
1.1471 + {
1.1472 + TInt xOffset=xMaskLoop*maskWidth;
1.1473 + TInt blitWidth=Min(maskWidth-maskStartShift,dstWidth-xOffset);
1.1474 + const TUint8* srcPixelStart = aSrcBase + aSrcStride*sy + (sx+xOffset)*op::SrcPixelBytes();
1.1475 + TUint8* dstPixelStart = aDataAddress + aDstStride*dy + (dx+xOffset)*op::DestPixelBytes();
1.1476 + for(TInt yPos=0;yPos<dstHeight;yPos++)
1.1477 + {
1.1478 + const TUint8* srcPixel=srcPixelStart;
1.1479 + const TUint32* mskPixel=(const TUint32*)(mskBasePtr + aMaskStride*((aMaskSrcPos.iY+yPos)%maskHeight));
1.1480 + TUint8* dstPixel=dstPixelStart;
1.1481 + TUint mask=1<<maskStartShift;
1.1482 + TUint32 maskPixels=*mskPixel;
1.1483 + if (aInvertMask)
1.1484 + maskPixels=~maskPixels;
1.1485 + TInt runCount=0;
1.1486 + TInt toGo=blitWidth;
1.1487 + TUint32 endMask=0;
1.1488 + const TInt tgMinusRun0=toGo+maskStartShift;
1.1489 + if (tgMinusRun0<32)
1.1490 + {
1.1491 + endMask=1<<tgMinusRun0;
1.1492 + maskPixels|=endMask; // ensure the end of the scanline will fail set run where we will check for the end
1.1493 + }
1.1494 + // Into skip loop first, assume start of scanline more likely to be masked out than set
1.1495 + FOREVER
1.1496 + {
1.1497 + if (!(mask&maskPixels))
1.1498 + {
1.1499 + runCount++;
1.1500 +rbm2startSkipRun:
1.1501 + mask<<=1;
1.1502 + if (mask!=0)
1.1503 + continue;
1.1504 + mask=1;
1.1505 +rbm2nextMaskSkip:
1.1506 + const TInt tgMinusRun1=toGo-runCount;
1.1507 + if (tgMinusRun1 == 0)
1.1508 + {
1.1509 + endMask = mask;
1.1510 + maskPixels = endMask;
1.1511 + }
1.1512 + else
1.1513 + {
1.1514 + maskPixels=*++mskPixel;
1.1515 + if (aInvertMask)
1.1516 + {
1.1517 + maskPixels=~maskPixels;
1.1518 + }
1.1519 + if (tgMinusRun1<32)
1.1520 + {
1.1521 + endMask=1<<tgMinusRun1;
1.1522 + maskPixels|=endMask; // ensure the end of the scanline will fail set run where we will check for the end
1.1523 + }
1.1524 + else if (maskPixels==0)
1.1525 + {
1.1526 + runCount+=32;
1.1527 + goto rbm2nextMaskSkip;
1.1528 + }
1.1529 + }
1.1530 + continue;
1.1531 + }
1.1532 + toGo-=runCount;
1.1533 + if (toGo==0)
1.1534 + goto rbm2nextY;
1.1535 + dstPixel+=runCount*op::DestPixelBytes();
1.1536 + srcPixel+=runCount*op::SrcPixelBytes();
1.1537 + runCount=1;
1.1538 + maskPixels^=endMask; // toggle the end mask (if there is one)
1.1539 + goto rbm2startSetRun;
1.1540 + }
1.1541 +// Code within this section deals with runs of pixels to set
1.1542 + {
1.1543 +rbm2startTopLoop:
1.1544 + if (mask&maskPixels)
1.1545 + {
1.1546 + runCount++;
1.1547 +rbm2startSetRun:
1.1548 + mask<<=1;
1.1549 + if (mask!=0)
1.1550 + goto rbm2startTopLoop;
1.1551 + mask=1;
1.1552 +rbm2nextMaskSet:
1.1553 + const TInt tgMinusRun2=toGo-runCount;
1.1554 + if (tgMinusRun2 == 0)
1.1555 + {
1.1556 + endMask = mask;
1.1557 + maskPixels = 0;
1.1558 + }
1.1559 + else
1.1560 + {
1.1561 + maskPixels=*++mskPixel;
1.1562 + if (aInvertMask)
1.1563 + {
1.1564 + maskPixels=~maskPixels;
1.1565 + }
1.1566 + if (tgMinusRun2<32)
1.1567 + {
1.1568 + endMask=mask<<tgMinusRun2;
1.1569 + maskPixels&=~endMask; // ensure the end of the scanline will fail set run where we will check for the end
1.1570 + }
1.1571 + else if (maskPixels==0xFFFFFFFF)
1.1572 + {
1.1573 + runCount+=32;
1.1574 + goto rbm2nextMaskSet;
1.1575 + }
1.1576 + }
1.1577 + goto rbm2startTopLoop;
1.1578 + }
1.1579 + op::write(srcPixel, dstPixel, runCount);
1.1580 + toGo-=runCount;
1.1581 + if (toGo==0)
1.1582 + goto rbm2nextY;
1.1583 + maskPixels^=endMask; // toggle the end mask (if there is one)
1.1584 + runCount=1;
1.1585 + goto rbm2startSkipRun;
1.1586 + }
1.1587 +rbm2nextY:
1.1588 + srcPixelStart+=aSrcStride;
1.1589 + dstPixelStart+=aDstStride;
1.1590 + }
1.1591 + maskStartShift=0;
1.1592 + }
1.1593 + }
1.1594 +
1.1595 +template <class op>
1.1596 +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)
1.1597 + {
1.1598 + TInt sx = aSrcRect.iTl.iX;
1.1599 + TInt sxOffset=sx*op::SrcPixelBytes();
1.1600 +
1.1601 + TInt srcWidth = aSrcRect.Width();
1.1602 + TInt srcHeight = aSrcRect.Height();
1.1603 + TInt dstWidth = aDstRect.Width();
1.1604 + TInt dstHeight = aDstRect.Height();
1.1605 +//
1.1606 + TInt yDdaCount;
1.1607 + TBool yStretching;
1.1608 + TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
1.1609 +//
1.1610 + TInt xDdaCountBase;
1.1611 + TBool xStretching;
1.1612 + TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
1.1613 +//
1.1614 + const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
1.1615 + const TInt xCount=aClipRect.Width();
1.1616 + TUint8* dstPixelBase = aDataAddress+aClipRect.iTl.iY*aDstStride+aClipRect.iTl.iX*op::DestPixelBytes();
1.1617 + for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
1.1618 + {
1.1619 + const TUint8* srcRowBase = aSrcBase+aSrcStride*ySrcOffset+sxOffset;
1.1620 + const TUint8* mskRowBase = aMaskBase+aMaskStride*ySrcOffset+sx;
1.1621 + TUint8* dstPixel = dstPixelBase;
1.1622 + TInt xCountDown=xCount;
1.1623 + TInt xOffset=xOffsetBase;
1.1624 +//
1.1625 + TInt ddaCount = xDdaCountBase;
1.1626 + if (xStretching)
1.1627 + {
1.1628 + do
1.1629 + {
1.1630 + TUint mask=*(mskRowBase+xOffset);
1.1631 + if (mask==0xFF)
1.1632 + op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel);
1.1633 + else if (mask!=0)
1.1634 + op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask);
1.1635 + dstPixel+=op::DestPixelBytes();
1.1636 +//
1.1637 + ddaCount-=srcWidth;
1.1638 + if (ddaCount<0)
1.1639 + {
1.1640 + xOffset++;
1.1641 + ddaCount+=dstWidth;
1.1642 + }
1.1643 + } while(--xCountDown);
1.1644 + }
1.1645 + else
1.1646 + {
1.1647 + do
1.1648 + {
1.1649 + TUint mask=*(mskRowBase+xOffset);
1.1650 + if (mask==0xFF)
1.1651 + op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel);
1.1652 + else if (mask!=0)
1.1653 + op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask);
1.1654 + dstPixel+=op::DestPixelBytes();
1.1655 +//
1.1656 + do
1.1657 + {
1.1658 + xOffset++;
1.1659 + ddaCount-=dstWidth;
1.1660 + } while(ddaCount>=0);
1.1661 + ddaCount+=srcWidth;
1.1662 + } while(--xCountDown);
1.1663 + }
1.1664 + dstPixelBase+=aDstStride;
1.1665 + DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
1.1666 + }
1.1667 + }
1.1668 +
1.1669 +template <class op>
1.1670 +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)
1.1671 + {
1.1672 + TInt dstWidth = aSrcRect.Width();
1.1673 + const TInt dstHeight = aSrcRect.Height();
1.1674 + const TUint8* srcPixelStart = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes();
1.1675 + TUint8* dstPixelStart = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes();
1.1676 + TInt yPos=0;
1.1677 + const TInt maskWidth=aMaskSize.iWidth;
1.1678 + const TInt maskHeight=aMaskSize.iHeight;
1.1679 + const TInt maskStartOffset=aMaskSrcPos.iX%maskWidth;
1.1680 + FOREVER
1.1681 + {
1.1682 + const TUint8* srcPixel=srcPixelStart;
1.1683 + const TUint8* maskBase=aMaskBase + (aMaskStride*((aMaskSrcPos.iY+yPos)%maskHeight));
1.1684 + const TUint8* mskPixel=maskBase + maskStartOffset;
1.1685 + const TUint8* mskEnd=maskBase + maskWidth;
1.1686 + if (dstWidth<(mskEnd-mskPixel))
1.1687 + mskEnd=mskPixel+dstWidth;
1.1688 + TUint8* dstPixel=dstPixelStart;
1.1689 + const TUint8* runStart=mskPixel;
1.1690 + TInt toGo=dstWidth;
1.1691 + FOREVER
1.1692 + {
1.1693 +// Into skip loop first, assume start of scanline more likely to be masked out than set
1.1694 + TInt runLen1=0;
1.1695 +skipPixels:
1.1696 + while(mskPixel<mskEnd && *mskPixel==0)
1.1697 + mskPixel++;
1.1698 + const TInt runSubLen1=mskPixel-runStart;
1.1699 + runLen1+=runSubLen1;
1.1700 + toGo-=runSubLen1;
1.1701 + if (mskPixel==mskEnd && toGo!=0)
1.1702 + {
1.1703 + mskPixel=maskBase;
1.1704 + runStart=maskBase;
1.1705 + if (toGo<maskWidth)
1.1706 + mskEnd=mskPixel+toGo;
1.1707 + goto skipPixels;
1.1708 + }
1.1709 + dstPixel+=runLen1*op::DestPixelBytes();
1.1710 + srcPixel+=runLen1*op::SrcPixelBytes();
1.1711 + if (toGo==0)
1.1712 + break;
1.1713 + runStart=mskPixel++;
1.1714 + if (*runStart!=255)
1.1715 + goto blendIt;
1.1716 +// Fall through to solid fill code
1.1717 +solidFill:
1.1718 + {// bracketing to avoid gccxml compile errors
1.1719 + TInt runLen2=0;
1.1720 +solidFill2:
1.1721 + while(mskPixel<mskEnd && *mskPixel==0xFF)
1.1722 + mskPixel++;
1.1723 + {// bracketing to avoid gccxml compile errors
1.1724 + const TInt runSubLen2=mskPixel-runStart;
1.1725 + runLen2+=runSubLen2;
1.1726 + toGo-=runSubLen2;
1.1727 + }
1.1728 + if (mskPixel==mskEnd && toGo!=0)
1.1729 + {
1.1730 + mskPixel=maskBase;
1.1731 + runStart=maskBase;
1.1732 + if (toGo<maskWidth)
1.1733 + mskEnd=mskPixel+toGo;
1.1734 + goto solidFill2;
1.1735 + }
1.1736 + if (runLen2)
1.1737 + op::write(srcPixel, dstPixel, runLen2);
1.1738 + }
1.1739 + if (toGo==0)
1.1740 + break;
1.1741 + runStart=mskPixel++;
1.1742 + if (*runStart==0)
1.1743 + continue;
1.1744 +blendIt:
1.1745 + while(mskPixel<mskEnd && *mskPixel!=0 && *mskPixel!=255)
1.1746 + mskPixel++;
1.1747 + const TInt runSubLen3=mskPixel-runStart;
1.1748 + if (runSubLen3)
1.1749 + {
1.1750 + toGo-=runSubLen3;
1.1751 + op::writeAlphaMask(srcPixel,dstPixel,runStart,runSubLen3);
1.1752 + }
1.1753 + if (mskPixel==mskEnd && toGo!=0)
1.1754 + {
1.1755 + mskPixel=maskBase;
1.1756 + runStart=maskBase;
1.1757 + if (toGo<maskWidth)
1.1758 + mskEnd=mskPixel+toGo;
1.1759 + goto blendIt;
1.1760 + }
1.1761 + if (toGo==0)
1.1762 + break;
1.1763 + runStart=mskPixel++;
1.1764 + if (*runStart==255)
1.1765 + goto solidFill;
1.1766 + }
1.1767 + if (++yPos==dstHeight)
1.1768 + break;
1.1769 + srcPixelStart+=aSrcStride;
1.1770 + dstPixelStart+=aDstStride;
1.1771 + }
1.1772 + }
1.1773 +
1.1774 +template <class op>
1.1775 +static void UnscaledFastBlitMaskedRotG256(const TUint8* aSrcBase, CFbsDrawDevice::TOrientation aOrientation,
1.1776 + TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride,
1.1777 + TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TSize &aDestSize,
1.1778 + const TPoint& aMaskSrcPos, const TSize &aMaskSize)
1.1779 + {
1.1780 + TPoint dstPos(aDstPos);
1.1781 + TInt srcStep=op::SrcPixelBytes();
1.1782 + TInt maskStep=1;
1.1783 + TRect srcRect(aSrcRect);
1.1784 + TSize maskSize(aMaskSize);
1.1785 + TPoint maskSrcPos(aMaskSrcPos);
1.1786 + switch(aOrientation)
1.1787 + {
1.1788 + case CFbsDrawDevice::EOrientationRotated90:
1.1789 + srcStep=-aSrcStride;
1.1790 + aSrcStride=op::SrcPixelBytes();
1.1791 + maskStep=-aMaskStride;
1.1792 + aMaskStride=1;
1.1793 + dstPos.iX=aDestSize.iWidth-aDstPos.iY-aSrcRect.Height();
1.1794 + dstPos.iY=aDstPos.iX;
1.1795 + srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX);
1.1796 + maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth);
1.1797 + maskSrcPos.iX=aMaskSrcPos.iY;
1.1798 + maskSrcPos.iY=aMaskSrcPos.iX;
1.1799 + break;
1.1800 + case CFbsDrawDevice::EOrientationRotated180:
1.1801 + srcStep=-op::SrcPixelBytes();
1.1802 + maskStep=-1;
1.1803 + aSrcStride=-aSrcStride;
1.1804 + aMaskStride=-aMaskStride;
1.1805 + dstPos.iX=aDestSize.iWidth-aDstPos.iX-aSrcRect.Width();
1.1806 + dstPos.iY=aDestSize.iHeight-aDstPos.iY-aSrcRect.Height();
1.1807 + break;
1.1808 + case CFbsDrawDevice::EOrientationRotated270:
1.1809 + srcStep=aSrcStride;
1.1810 + aSrcStride=-op::SrcPixelBytes();
1.1811 + maskStep=aMaskStride;
1.1812 + aMaskStride=-1;
1.1813 + dstPos.iX=aDstPos.iY;
1.1814 + dstPos.iY=aDestSize.iHeight-aDstPos.iX-aSrcRect.Width();
1.1815 + srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX);
1.1816 + maskSrcPos.iX=aMaskSrcPos.iY;
1.1817 + maskSrcPos.iY=aMaskSrcPos.iX;
1.1818 + maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth);
1.1819 + break;
1.1820 + }
1.1821 + const TUint8* srcPixelStart = aSrcBase;
1.1822 + if (srcStep>0)
1.1823 + srcPixelStart+=srcRect.iTl.iX*srcStep;
1.1824 + else
1.1825 + srcPixelStart-=(srcRect.iBr.iX-1)*srcStep;
1.1826 + if (aSrcStride>0)
1.1827 + srcPixelStart+=srcRect.iTl.iY*aSrcStride;
1.1828 + else
1.1829 + srcPixelStart-=(srcRect.iBr.iY-1)*aSrcStride;
1.1830 +//
1.1831 + const TInt dstWidth = srcRect.Width();
1.1832 + const TInt dstHeight = srcRect.Height();
1.1833 + TUint8* dstPixelStart = aDataAddress + aDstStride*dstPos.iY + dstPos.iX*op::DestPixelBytes();
1.1834 + TInt yPos=0;
1.1835 + const TInt maskWidth=dstWidth<maskSize.iWidth?dstWidth:maskSize.iWidth;
1.1836 + const TInt maskHeight=maskSize.iHeight;
1.1837 + const TInt maskStartOffset=(maskStep>0?maskSrcPos.iX:srcRect.iBr.iX-1)%maskSize.iWidth;
1.1838 + FOREVER
1.1839 + {
1.1840 + const TUint8* srcPixel=srcPixelStart;
1.1841 + const TUint8* maskBase=aMaskBase;
1.1842 + TInt maskYpos=(maskSrcPos.iY+yPos)%maskHeight;
1.1843 + if (aMaskStride>0)
1.1844 + maskBase+=maskYpos*aMaskStride;
1.1845 + else
1.1846 + {
1.1847 + TInt maskEndPos=(maskSrcPos.iY+dstHeight-1-yPos)%maskHeight;
1.1848 + maskBase-=maskEndPos*aMaskStride;
1.1849 + }
1.1850 + const TUint8* mskPixel=maskBase;
1.1851 + const TUint8* mskEnd=maskBase;
1.1852 + if (maskStep>0)
1.1853 + {
1.1854 + mskPixel+=maskStartOffset*maskStep;
1.1855 + mskEnd+=maskSize.iWidth*maskStep;
1.1856 + }
1.1857 + else
1.1858 + {
1.1859 + maskBase-=(maskSize.iWidth-1)*maskStep;
1.1860 + mskPixel-=maskStartOffset*maskStep;
1.1861 + mskEnd+=maskStep;
1.1862 + }
1.1863 + const TInt maskToGo=(mskEnd-mskPixel)/maskStep;
1.1864 + if (maskToGo>dstWidth)
1.1865 + mskEnd=mskPixel+dstWidth*maskStep;
1.1866 + TUint8* dstPixel=dstPixelStart;
1.1867 + const TUint8* runStart=mskPixel;
1.1868 + TInt toGo=dstWidth;
1.1869 + FOREVER
1.1870 + {
1.1871 +// Into skip loop first, assume start of scanline more likely to be masked out than set
1.1872 + TInt runLen1=0;
1.1873 +skipPixels:
1.1874 + while(mskPixel!=mskEnd && *mskPixel==0)
1.1875 + mskPixel+=maskStep;
1.1876 + const TInt runSubLen1=(mskPixel-runStart)/maskStep;
1.1877 + runLen1+=runSubLen1;
1.1878 + toGo-=runSubLen1;
1.1879 + if (mskPixel==mskEnd && toGo!=0)
1.1880 + {
1.1881 + mskPixel=maskBase;
1.1882 + runStart=maskBase;
1.1883 + if (toGo<maskWidth)
1.1884 + mskEnd=mskPixel+toGo*maskStep;
1.1885 + goto skipPixels;
1.1886 + }
1.1887 + dstPixel+=runLen1*op::DestPixelBytes();
1.1888 + srcPixel+=runLen1*srcStep;
1.1889 + if (toGo==0)
1.1890 + break;
1.1891 + runStart=mskPixel;
1.1892 + mskPixel+=maskStep;
1.1893 + if (*runStart!=255)
1.1894 + goto blendIt;
1.1895 +// Fall through to solid fill code
1.1896 +solidFill:
1.1897 + {// bracketing to avoid gccxml compile errors
1.1898 + TInt runLen2=0;
1.1899 +solidFill2:
1.1900 + while(mskPixel!=mskEnd && *mskPixel==0xFF)
1.1901 + mskPixel+=maskStep;
1.1902 + {// bracketing to avoid gccxml compile errors
1.1903 + const TInt runSubLen2=(mskPixel-runStart)/maskStep;
1.1904 + runLen2+=runSubLen2;
1.1905 + toGo-=runSubLen2;
1.1906 + }
1.1907 + if (mskPixel==mskEnd && toGo!=0)
1.1908 + {
1.1909 + mskPixel=maskBase;
1.1910 + runStart=maskBase;
1.1911 + if (toGo<maskWidth)
1.1912 + mskEnd=mskPixel+toGo*maskStep;
1.1913 + goto solidFill2;
1.1914 + }
1.1915 + if (runLen2)
1.1916 + {
1.1917 + op::write2rot(srcPixel,dstPixel,runLen2,srcStep, op::DestPixelBytes());
1.1918 + srcPixel+=runLen2*srcStep;
1.1919 + dstPixel+=runLen2*op::DestPixelBytes();
1.1920 + }
1.1921 + }
1.1922 + if (toGo==0)
1.1923 + break;
1.1924 + runStart=mskPixel;
1.1925 + mskPixel+=maskStep;
1.1926 + if (*runStart==0)
1.1927 + continue;
1.1928 +blendIt:
1.1929 + while(mskPixel!=mskEnd && *mskPixel!=0 && *mskPixel!=255)
1.1930 + mskPixel+=maskStep;
1.1931 + const TInt runSubLen3=(mskPixel-runStart)/maskStep;
1.1932 + if (runSubLen3)
1.1933 + {
1.1934 + toGo-=runSubLen3;
1.1935 + op::writeAlphaMaskRot(srcPixel,dstPixel,runStart,runSubLen3,srcStep,maskStep);
1.1936 + }
1.1937 + if (mskPixel==mskEnd && toGo!=0)
1.1938 + {
1.1939 + mskPixel=maskBase;
1.1940 + runStart=maskBase;
1.1941 + if (toGo<maskWidth)
1.1942 + mskEnd=mskPixel+toGo*maskStep;
1.1943 + goto blendIt;
1.1944 + }
1.1945 + if (toGo==0)
1.1946 + break;
1.1947 + runStart=mskPixel;
1.1948 + mskPixel+=maskStep;
1.1949 + if (*runStart==255)
1.1950 + goto solidFill;
1.1951 + }
1.1952 + if (++yPos==dstHeight)
1.1953 + break;
1.1954 + srcPixelStart+=aSrcStride;
1.1955 + dstPixelStart+=aDstStride;
1.1956 + }
1.1957 + }
1.1958 +
1.1959 +void CDrawBitmap::GetBlendPosAndRect(TRect &aSrcRect, const TRect &aSrcRectIn, const TSize &aSrcSize, const TPoint &aDestOffset)
1.1960 + {
1.1961 + aSrcRect.iTl=aSrcRectIn.iTl+aDestOffset;
1.1962 + aSrcRect.iBr=aSrcRectIn.iBr;
1.1963 +// Wrap source top left to within source bitmap
1.1964 + if (aSrcRect.iTl.iX<0)
1.1965 + {
1.1966 + TInt negOffset=1-(aSrcRect.iTl.iX+1)/aSrcSize.iWidth;
1.1967 + aSrcRect.Move(negOffset*aSrcSize.iWidth,0);
1.1968 + }
1.1969 + else if (aSrcRect.iTl.iX>=aSrcSize.iWidth)
1.1970 + aSrcRect.Move(-(aSrcRect.iTl.iX/aSrcSize.iWidth)*aSrcSize.iWidth,0);
1.1971 + if (aSrcRect.iTl.iY<0)
1.1972 + {
1.1973 + TInt negOffset=1-(aSrcRect.iTl.iY+1)/aSrcSize.iHeight;
1.1974 + aSrcRect.Move(0,negOffset*aSrcSize.iHeight);
1.1975 + }
1.1976 + else if (aSrcRect.iTl.iY>=aSrcSize.iHeight)
1.1977 + aSrcRect.Move(0,-(aSrcRect.iTl.iY/aSrcSize.iHeight)*aSrcSize.iHeight);
1.1978 + if (aSrcRect.iBr.iY>aSrcSize.iHeight)
1.1979 + aSrcRect.iBr.iY=aSrcSize.iHeight;
1.1980 + if (aSrcRect.iBr.iX>aSrcSize.iWidth)
1.1981 + aSrcRect.iBr.iX=aSrcSize.iWidth;
1.1982 + }
1.1983 +
1.1984 +void CDrawBitmap::GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDstRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize)
1.1985 + {
1.1986 + aDstRect=aDstRectIn;
1.1987 + aSrcRect=aSrcRectIn;
1.1988 + if (aSrcRect.iTl.iX<0)
1.1989 + aSrcRect.iTl.iX=0;
1.1990 + if (aSrcRect.iTl.iY<0)
1.1991 + aSrcRect.iTl.iY=0;
1.1992 + TInt extraWidth=aSrcRect.iBr.iX-aSrcSize.iWidth;
1.1993 + if (extraWidth>0)
1.1994 + aSrcRect.iBr.iX-=extraWidth;
1.1995 + TInt extraHeight=aSrcRect.iBr.iY-aSrcSize.iHeight;
1.1996 + if (extraHeight>0)
1.1997 + aSrcRect.iBr.iY-=extraHeight;
1.1998 + }
1.1999 +
1.2000 +TInt CDrawBitmap::FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
1.2001 + const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch,
1.2002 + TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
1.2003 + const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
1.2004 + CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
1.2005 + {
1.2006 + if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch) ||
1.2007 + !FastBlendMaskSupported(aMaskDisplayMode, aMaskStride) ||
1.2008 + iOrientation!=EOrientationNormal)
1.2009 + return(KErrNotSupported);
1.2010 + TRect srcRect;
1.2011 + TRect dstRect;
1.2012 + GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize);
1.2013 + const TInt KDestModeShift=8;
1.2014 + const TInt KMaskModeShift=16;
1.2015 +#define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<<KDestModeShift)|(mask<<KMaskModeShift)
1.2016 +#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
1.2017 + TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift)|(aMaskDisplayMode<<KMaskModeShift);
1.2018 + if (srcRect.iBr.iX>aMaskSize.iWidth || srcRect.iBr.iY>aMaskSize.iHeight)
1.2019 + return(KErrNotSupported);
1.2020 + TUint8 *dstBits=reinterpret_cast<TUint8*>(iBits);
1.2021 + TInt dstStride=iScanLineWords*4;
1.2022 + const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
1.2023 + const TUint8 *maskBits=reinterpret_cast<const TUint8*>(aMaskBase);
1.2024 + if (!dstRect.IsEmpty() && !srcRect.IsEmpty())
1.2025 + {
1.2026 + switch (switchValue)
1.2027 + {
1.2028 +// 16MA source
1.2029 + MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2):
1.2030 + ScaledFastBlitMaskedG2<TMaToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2031 + break;
1.2032 + MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2):
1.2033 + ScaledFastBlitMaskedG2<TMaToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2034 + break;
1.2035 + MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2):
1.2036 + ScaledFastBlitMaskedG2<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2037 + break;
1.2038 + MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
1.2039 + ScaledFastBlitMaskedG256<TMaToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2040 + break;
1.2041 + MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
1.2042 + ScaledFastBlitMaskedG256<TMaToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2043 + break;
1.2044 + MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256):
1.2045 + ScaledFastBlitMaskedG256<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2046 + break;
1.2047 + // 16MU source
1.2048 + MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2):
1.2049 + ScaledFastBlitMaskedG2<TMuToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2050 + break;
1.2051 + MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2):
1.2052 + ScaledFastBlitMaskedG2<TMuToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2053 + break;
1.2054 + MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2):
1.2055 + ScaledFastBlitMaskedG2<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2056 + break;
1.2057 + MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2):
1.2058 + ScaledFastBlitMaskedG2<TMTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2059 + break;
1.2060 + MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
1.2061 + ScaledFastBlitMaskedG256<TMuToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2062 + break;
1.2063 + MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
1.2064 + ScaledFastBlitMaskedG256<TMuToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2065 + break;
1.2066 + MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256):
1.2067 + ScaledFastBlitMaskedG256<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2068 + break;
1.2069 + MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256):
1.2070 + ScaledFastBlitMaskedG256<TMTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2071 + break;
1.2072 + // 16MAP source
1.2073 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2):
1.2074 + ScaledFastBlitMaskedG2<TMapToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2075 + break;
1.2076 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2):
1.2077 + ScaledFastBlitMaskedG2<TMapToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2078 + break;
1.2079 + MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2):
1.2080 + ScaledFastBlitMaskedG2<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2081 + break;
1.2082 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
1.2083 + ScaledFastBlitMaskedG256<TMapToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2084 + break;
1.2085 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
1.2086 + ScaledFastBlitMaskedG256<TMapToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2087 + break;
1.2088 + MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256):
1.2089 + ScaledFastBlitMaskedG256<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2090 + break;
1.2091 + // 64K source
1.2092 + MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2):
1.2093 + ScaledFastBlitMaskedG2<T64KToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2094 + break;
1.2095 + MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2):
1.2096 + ScaledFastBlitMaskedG2<T64KToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2097 + break;
1.2098 + MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2):
1.2099 + ScaledFastBlitMaskedG2<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2100 + break;
1.2101 + MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256):
1.2102 + ScaledFastBlitMaskedG256<T64KToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2103 + break;
1.2104 + MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256):
1.2105 + ScaledFastBlitMaskedG256<T64KToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2106 + break;
1.2107 + MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
1.2108 + ScaledFastBlitMaskedG256<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2109 + break;
1.2110 +#if defined(__SUPPORT_16MA_TARGET__)
1.2111 + MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2):
1.2112 + ScaledFastBlitMaskedG2<TMaToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2113 + break;
1.2114 + MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256):
1.2115 + ScaledFastBlitMaskedG256<TMaToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2116 + break;
1.2117 + MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2):
1.2118 + ScaledFastBlitMaskedG2<TMuToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2119 + break;
1.2120 + MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256):
1.2121 + ScaledFastBlitMaskedG256<TMuToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2122 + break;
1.2123 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2):
1.2124 + ScaledFastBlitMaskedG2<TMapToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2125 + break;
1.2126 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256):
1.2127 + ScaledFastBlitMaskedG256<TMapToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2128 + break;
1.2129 + MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2):
1.2130 + ScaledFastBlitMaskedG2<T64KToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
1.2131 + break;
1.2132 + MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256):
1.2133 + ScaledFastBlitMaskedG256<T64KToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
1.2134 + break;
1.2135 +#endif
1.2136 + default:
1.2137 + return KErrNotSupported;
1.2138 + }
1.2139 + }
1.2140 + return(KErrNone);
1.2141 + }
1.2142 +
1.2143 +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)
1.2144 + {
1.2145 + if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch))
1.2146 + return(KErrNotSupported);
1.2147 + TRect srcRect;
1.2148 + TRect dstRect;
1.2149 + GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize);
1.2150 + const TInt KDestModeShift=8;
1.2151 +#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
1.2152 + TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
1.2153 + TUint8 *dstBits=reinterpret_cast<TUint8*>(iBits);
1.2154 + TInt dstStride=iScanLineWords*4;
1.2155 + const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
1.2156 + if (!dstRect.IsEmpty() && !srcRect.IsEmpty())
1.2157 + {
1.2158 + switch (switchValue)
1.2159 + {
1.2160 +// 16MA Source
1.2161 + MODE_SWITCH(EColor16MA,EColor16MU):
1.2162 + ScaledFastBlit<TMaToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2163 + break;
1.2164 + MODE_SWITCH(EColor16MA,EColor16MAP):
1.2165 + ScaledFastBlit<TMaToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2166 + break;
1.2167 + MODE_SWITCH(EColor16MA,EColor64K):
1.2168 + ScaledFastBlit<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2169 + break;
1.2170 +// 16MAP Source
1.2171 + MODE_SWITCH(EColor16MAP,EColor16MU):
1.2172 + ScaledFastBlit<TMapToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2173 + break;
1.2174 + MODE_SWITCH(EColor16MAP,EColor16MAP):
1.2175 + ScaledFastBlit<TMapToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2176 + break;
1.2177 + MODE_SWITCH(EColor16MAP,EColor64K):
1.2178 + ScaledFastBlit<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2179 + break;
1.2180 +// 16MU Source
1.2181 + MODE_SWITCH(EColor16MU,EColor16MU):
1.2182 + ScaledFastBlit<TMuToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2183 + break;
1.2184 + MODE_SWITCH(EColor16MU,EColor64K):
1.2185 + ScaledFastBlit<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2186 + break;
1.2187 + // No EColor16MU to EColor16MAP fast blit performed because it
1.2188 + // cannot be guaranteed that the alpha channel of the EColor16MU
1.2189 + // source is 0xFF, which any fast blit would require.
1.2190 +// 64K Source
1.2191 + MODE_SWITCH(EColor64K,EColor16MU):
1.2192 + ScaledFastBlit<T64KToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2193 + break;
1.2194 + MODE_SWITCH(EColor64K,EColor16MAP):
1.2195 + ScaledFastBlit<T64KToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2196 + break;
1.2197 + MODE_SWITCH(EColor64K,EColor64K):
1.2198 + ScaledFastBlit<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2199 + break;
1.2200 +// 16M source
1.2201 + MODE_SWITCH(EColor16M,EColor64K):
1.2202 + ScaledFastBlit<TMTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2203 + break;
1.2204 +#if defined(__SUPPORT_16MA_TARGET__)
1.2205 + MODE_SWITCH(EColor16MA,EColor16MA):
1.2206 + ScaledFastBlit<TMaToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2207 + break;
1.2208 + MODE_SWITCH(EColor16MAP,EColor16MA):
1.2209 + ScaledFastBlit<TMapToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2210 + break;
1.2211 + MODE_SWITCH(EColor64K,EColor16MA):
1.2212 + ScaledFastBlit<T64KToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
1.2213 + break;
1.2214 + // No EColor16MU to EColor16MA fast blit performed because it
1.2215 + // cannot be guaranteed that the alpha channel of the EColor16MU
1.2216 + // source is 0xFF, which any fast blit would require.
1.2217 +#endif
1.2218 + default:
1.2219 + return KErrNotSupported;
1.2220 + }
1.2221 + }
1.2222 + return KErrNone;
1.2223 + }
1.2224 +
1.2225 +TInt CDrawBitmap::DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize)
1.2226 + {
1.2227 + const TInt KDestModeShift=8;
1.2228 + TInt dstStride=iScanLineWords*4;
1.2229 + TUint8 *dstBits=(TUint8*)iBits;
1.2230 +#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
1.2231 + TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
1.2232 + TInt xEnd=aDest.iX+aSrcRect.Width();
1.2233 + TInt yEnd=aDest.iY+aSrcRect.Height();
1.2234 + TPoint dstPos;
1.2235 + dstPos.iY=aDest.iY;
1.2236 + while(dstPos.iY<yEnd)
1.2237 + {
1.2238 + TRect srcRect;
1.2239 + dstPos.iX=aDest.iX;
1.2240 + while(dstPos.iX<xEnd)
1.2241 + {
1.2242 +// Clip source rect to within source bitmap size
1.2243 + GetBlendPosAndRect(srcRect,aSrcRect,aSrcSize,dstPos-aDest);
1.2244 + if (iOrientation==EOrientationNormal)
1.2245 + {
1.2246 + switch (switchValue)
1.2247 + {
1.2248 + // 16MA Source
1.2249 + MODE_SWITCH(EColor16MA,EColor16MU):
1.2250 + UnscaledFastBlit<TMaToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2251 + break;
1.2252 + MODE_SWITCH(EColor16MA,EColor16MAP):
1.2253 + UnscaledFastBlit<TMaToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2254 + break;
1.2255 + MODE_SWITCH(EColor16MA,EColor64K):
1.2256 + UnscaledFastBlit<TMaTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2257 + break;
1.2258 + // 16MAP Source
1.2259 + MODE_SWITCH(EColor16MAP,EColor16MU):
1.2260 + UnscaledFastBlit<TMapToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2261 + break;
1.2262 + MODE_SWITCH(EColor16MAP,EColor16MAP):
1.2263 + UnscaledFastBlit<TMapToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2264 + break;
1.2265 + MODE_SWITCH(EColor16MAP,EColor64K):
1.2266 + UnscaledFastBlit<TMapTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2267 + break;
1.2268 + // 16MU Source
1.2269 + MODE_SWITCH(EColor16MU,EColor16MU):
1.2270 + ReplaceBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2271 + break;
1.2272 + MODE_SWITCH(EColor16MU,EColor64K):
1.2273 + UnscaledFastBlit<TMuTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2274 + break;
1.2275 + // No EColor16MU to EColor16MAP fast blit performed because it
1.2276 + // cannot be guaranteed that the alpha channel of the EColor16MU
1.2277 + // source is 0xFF, which any fast blit would require.
1.2278 + // 64K Source
1.2279 + MODE_SWITCH(EColor64K,EColor16MU):
1.2280 + UnscaledFastBlit<T64KToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2281 + break;
1.2282 + MODE_SWITCH(EColor64K,EColor16MAP):
1.2283 + UnscaledFastBlit<T64KToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2284 + break;
1.2285 + MODE_SWITCH(EColor64K,EColor64K):
1.2286 + UnscaledFastBlit<T64KTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2287 + break;
1.2288 + // 16M Source
1.2289 + MODE_SWITCH(EColor16M,EColor64K):
1.2290 + UnscaledFastBlit<TMTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2291 + break;
1.2292 +#if defined(__SUPPORT_16MA_TARGET__)
1.2293 + MODE_SWITCH(EColor16MA,EColor16MA):
1.2294 + UnscaledFastBlit<TMaToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2295 + break;
1.2296 + MODE_SWITCH(EColor16MAP,EColor16MA):
1.2297 + UnscaledFastBlit<TMapToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2298 + break;
1.2299 + MODE_SWITCH(EColor64K,EColor16MA):
1.2300 + UnscaledFastBlit<T64KToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
1.2301 + break;
1.2302 + // No EColor16MU to EColor16MA fast blit performed because it
1.2303 + // cannot be guaranteed that the alpha channel of the EColor16MU
1.2304 + // source is 0xFF, which any fast blit would require.
1.2305 +#endif
1.2306 + default:
1.2307 + return KErrNotSupported;
1.2308 + }
1.2309 + }
1.2310 + else
1.2311 + {
1.2312 + switch (switchValue)
1.2313 + {
1.2314 + // 16MA Source
1.2315 + MODE_SWITCH(EColor16MA,EColor16MU):
1.2316 + UnscaledFastBlitRot<TMaToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2317 + break;
1.2318 + MODE_SWITCH(EColor16MA,EColor16MAP):
1.2319 + UnscaledFastBlitRot<TMaToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2320 + break;
1.2321 + // 16MAP Source
1.2322 + MODE_SWITCH(EColor16MAP,EColor16MU):
1.2323 + UnscaledFastBlitRot<TMapToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2324 + break;
1.2325 + MODE_SWITCH(EColor16MAP,EColor16MAP):
1.2326 + UnscaledFastBlitRot<TMapToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2327 + break;
1.2328 + // 16MU Source
1.2329 + MODE_SWITCH(EColor16MU,EColor16MU):
1.2330 + UnscaledFastBlitRot<TMuToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2331 + break;
1.2332 + MODE_SWITCH(EColor16MU,EColor16MAP):
1.2333 + UnscaledFastBlitRot<TMuToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2334 + break;
1.2335 + // 64K Source
1.2336 + MODE_SWITCH(EColor64K,EColor64K):
1.2337 + UnscaledFastBlitRot<T64KTo64K>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
1.2338 + break;
1.2339 + default:
1.2340 + return KErrNotSupported;
1.2341 + }
1.2342 + }
1.2343 + dstPos.iX+=srcRect.Width();
1.2344 + }
1.2345 + dstPos.iY+=srcRect.Height();
1.2346 + }
1.2347 + return KErrNone;
1.2348 + }
1.2349 +
1.2350 +TBool CDrawBitmap::FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch)
1.2351 + {
1.2352 + // FastBlend supports all combinations of EColor16Mxx and EColor64K, and when User Display Mode is ENone.
1.2353 + if ((iUserDispMode != EColor64K && iUserDispMode != EColor16M &&
1.2354 + iUserDispMode != EColor16MU && iUserDispMode != EColor16MA &&
1.2355 + iUserDispMode != EColor16MAP && iUserDispMode != ENone))
1.2356 + {
1.2357 + return (EFalse);
1.2358 + }
1.2359 + if (!IsScalingOff() ||
1.2360 + !iOriginIsZero)
1.2361 + {
1.2362 + return(EFalse);
1.2363 + }
1.2364 + return((aDrawMode==CGraphicsContext::EDrawModePEN || (aDrawMode==CGraphicsContext::EDrawModeWriteAlpha && !IsAlphaChannel(aSrcDisplayMode))) &&
1.2365 + aShadowMode==CFbsDrawDevice::ENoShadow && aSrcLinePitch>0);
1.2366 + }
1.2367 +
1.2368 +TBool CDrawBitmap::FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride)
1.2369 + {
1.2370 + return((aMaskDisplayMode==EGray2 || aMaskDisplayMode==EGray256) && aMaskStride>0);
1.2371 + }
1.2372 +
1.2373 +/**
1.2374 +CDrawBitmap::BlendBitmap() implementation.
1.2375 +@internalTechnology
1.2376 +*/
1.2377 +TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
1.2378 + {
1.2379 + TInt srcPitch=aSrcDrawDevice->ScanLineBytes();
1.2380 + if (!FastBlendSupported(aSrcDrawDevice->DisplayMode(), aDrawMode, aShadowMode, srcPitch))
1.2381 + return(KErrNotSupported);
1.2382 + MScalingSettings* scalingSettings=NULL;
1.2383 + if (aSrcDrawDevice->GetInterface(KScalingSettingsInterfaceID,
1.2384 + reinterpret_cast<TAny*&>(scalingSettings))==KErrNone)
1.2385 + {
1.2386 + if (!scalingSettings->IsScalingOff())
1.2387 + return(KErrNotSupported);
1.2388 + }
1.2389 + MDrawDeviceOrigin* originInterface = NULL;
1.2390 + if(aSrcDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
1.2391 + reinterpret_cast <TAny*&> (originInterface)) == KErrNone)
1.2392 + {
1.2393 + TPoint origin;
1.2394 + originInterface->Get(origin);
1.2395 + if (origin.iX!=0 || origin.iY!=0)
1.2396 + return(KErrNotSupported);
1.2397 + }
1.2398 + MDrawDeviceOrientation* orientationInterface=NULL;
1.2399 + if(aSrcDrawDevice->GetInterface(KOrientationInterfaceID,
1.2400 + reinterpret_cast <TAny*&> (orientationInterface))!=KErrNone || (orientationInterface && orientationInterface->Orientation() != 0))
1.2401 + {
1.2402 + return KErrNotSupported;
1.2403 + }
1.2404 + TAny* interface=NULL;
1.2405 + TInt ret=aSrcDrawDevice->GetInterface(KFastBlit2InterfaceID, interface);
1.2406 + if (ret!=KErrNone)
1.2407 + return(ret);
1.2408 + MFastBlit2 *fb2=reinterpret_cast<MFastBlit2*>(interface);
1.2409 + const TUint8* srcBase = reinterpret_cast<const TUint8*>(fb2->Bits());
1.2410 + return(DoFastBlendBitmap(aDest, aSrcRect, srcBase, srcPitch, aSrcDrawDevice->DisplayMode(), aSrcDrawDevice->SizeInPixels()));
1.2411 + }
1.2412 +
1.2413 +TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
1.2414 + {
1.2415 + if (!FastBlendSupported(aDisplayMode, aDrawMode, aShadowMode, aSrcStride))
1.2416 + return(KErrNotSupported);
1.2417 + return(DoFastBlendBitmap(aDest, aSrcRect, reinterpret_cast<const TUint8*>(aSrcBase), aSrcStride, aDisplayMode, aSrcSize));
1.2418 + }
1.2419 +
1.2420 +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)
1.2421 + {
1.2422 + if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcStride) ||
1.2423 + !FastBlendMaskSupported(aMaskDisplayMode, aMaskStride))
1.2424 + return(KErrNotSupported);
1.2425 + TRect srcRect;
1.2426 + GetBlendPosAndRect(srcRect,aSrcRect,aSrcSize,TPoint(0,0));
1.2427 + const TInt KDestModeShift=8;
1.2428 + const TInt KMaskModeShift=16;
1.2429 + TInt dstStride=iScanLineWords*4;
1.2430 +#define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<<KDestModeShift)|(mask<<KMaskModeShift)
1.2431 + TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
1.2432 + switchValue|=aMaskDisplayMode<<KMaskModeShift;
1.2433 + const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
1.2434 + TUint8 *dstBits=(TUint8*)iBits;
1.2435 + const TUint8 *maskBits=reinterpret_cast<const TUint8*>(aMaskBase);
1.2436 + if (iOrientation==EOrientationNormal)
1.2437 + {
1.2438 + switch (switchValue)
1.2439 + {
1.2440 +// 16MA source
1.2441 + MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2):
1.2442 + UnscaledFastBlitMaskedG2<TMaToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2443 + break;
1.2444 + MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2):
1.2445 + UnscaledFastBlitMaskedG2<TMaToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2446 + break;
1.2447 + MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2):
1.2448 + UnscaledFastBlitMaskedG2<TMaTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2449 + break;
1.2450 + MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
1.2451 + UnscaledFastBlitMaskedG256<TMaToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2452 + break;
1.2453 + MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
1.2454 + UnscaledFastBlitMaskedG256<TMaToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2455 + break;
1.2456 + MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256):
1.2457 + UnscaledFastBlitMaskedG256<TMaTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2458 + break;
1.2459 +// 16MU source
1.2460 + MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2):
1.2461 + UnscaledFastBlitMaskedG2<TMuToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2462 + break;
1.2463 + MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2):
1.2464 + UnscaledFastBlitMaskedG2<TMuToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2465 + break;
1.2466 + MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2):
1.2467 + UnscaledFastBlitMaskedG2<TMuTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2468 + break;
1.2469 + MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2):
1.2470 + UnscaledFastBlitMaskedG2<TMTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2471 + break;
1.2472 + MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
1.2473 + UnscaledFastBlitMaskedG256<TMuToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2474 + break;
1.2475 + MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
1.2476 + UnscaledFastBlitMaskedG256<TMuToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2477 + break;
1.2478 + MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256):
1.2479 + UnscaledFastBlitMaskedG256<TMuTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2480 + break;
1.2481 + MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256):
1.2482 + UnscaledFastBlitMaskedG256<TMTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2483 + break;
1.2484 +// 16MAP source
1.2485 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2):
1.2486 + UnscaledFastBlitMaskedG2<TMapToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2487 + break;
1.2488 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2):
1.2489 + UnscaledFastBlitMaskedG2<TMapToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2490 + break;
1.2491 + MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2):
1.2492 + UnscaledFastBlitMaskedG2<TMapTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2493 + break;
1.2494 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
1.2495 + UnscaledFastBlitMaskedG256<TMapToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2496 + break;
1.2497 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
1.2498 + UnscaledFastBlitMaskedG256<TMapToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2499 + break;
1.2500 + MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256):
1.2501 + UnscaledFastBlitMaskedG256<TMapTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2502 + break;
1.2503 +// 64K source
1.2504 + MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2):
1.2505 + UnscaledFastBlitMaskedG2<T64KToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2506 + break;
1.2507 + MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2):
1.2508 + UnscaledFastBlitMaskedG2<T64KToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2509 + break;
1.2510 + MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2):
1.2511 + UnscaledFastBlitMaskedG2<T64KTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2512 + break;
1.2513 + MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256):
1.2514 + UnscaledFastBlitMaskedG256<T64KToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2515 + break;
1.2516 + MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256):
1.2517 + UnscaledFastBlitMaskedG256<T64KToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2518 + break;
1.2519 + MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
1.2520 + UnscaledFastBlitMaskedG256<T64KTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2521 + break;
1.2522 +#if defined(__SUPPORT_16MA_TARGET__)
1.2523 + MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2):
1.2524 + UnscaledFastBlitMaskedG2<TMaToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2525 + break;
1.2526 + MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256):
1.2527 + UnscaledFastBlitMaskedG256<TMaToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2528 + break;
1.2529 + MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2):
1.2530 + UnscaledFastBlitMaskedG2<TMuToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2531 + break;
1.2532 + MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256):
1.2533 + UnscaledFastBlitMaskedG256<TMuToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2534 + break;
1.2535 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2):
1.2536 + UnscaledFastBlitMaskedG2<TMapToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2537 + break;
1.2538 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256):
1.2539 + UnscaledFastBlitMaskedG256<TMapToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2540 + break;
1.2541 + MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2):
1.2542 + UnscaledFastBlitMaskedG2<T64KToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2543 + break;
1.2544 + MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256):
1.2545 + UnscaledFastBlitMaskedG256<T64KToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
1.2546 + break;
1.2547 +#endif
1.2548 + default:
1.2549 + return KErrNotSupported;
1.2550 + }
1.2551 + }
1.2552 + else
1.2553 + {
1.2554 + switch (switchValue)
1.2555 + {
1.2556 + // 16MA Source
1.2557 + MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
1.2558 + UnscaledFastBlitMaskedRotG256<TMaToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2559 + break;
1.2560 + MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
1.2561 + UnscaledFastBlitMaskedRotG256<TMaToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2562 + break;
1.2563 + // 16MAP Source
1.2564 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
1.2565 + UnscaledFastBlitMaskedRotG256<TMapToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2566 + break;
1.2567 + MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
1.2568 + UnscaledFastBlitMaskedRotG256<TMapToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2569 + break;
1.2570 + // 16MU Source
1.2571 + MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
1.2572 + UnscaledFastBlitMaskedRotG256<TMuToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2573 + break;
1.2574 + MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
1.2575 + UnscaledFastBlitMaskedRotG256<TMuToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2576 + break;
1.2577 + // 64K Source
1.2578 + MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
1.2579 + UnscaledFastBlitMaskedRotG256<T64KTo64K>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
1.2580 + break;
1.2581 + default:
1.2582 + return KErrNotSupported;
1.2583 + }
1.2584 + }
1.2585 + return KErrNone;
1.2586 + }