os/graphics/graphicsdeviceinterface/screendriver/sbit/FastBlend.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <bitstd.h>
sl@0
    17
#include <graphics/lookuptable.h>
sl@0
    18
#include <bitdrawinterfaceid.h>
sl@0
    19
#include "../inc/BMDRAW.H"
sl@0
    20
#include <graphics/gdi/gdiinline.inl>
sl@0
    21
sl@0
    22
// Current plan is to depreciate 16MA targets so we have removed acceleration of these.
sl@0
    23
// To re-enable put the __SUPPORT_16MA_TARGET__ back in
sl@0
    24
//#define __SUPPORT_16MA_TARGET__
sl@0
    25
sl@0
    26
// Enabling __CHECK_ALPHA01__ causes checks for alpha values of 0 and 1 to be made to attempt to
sl@0
    27
// accelerate handling of these cases. This may not always work as branching the execution path
sl@0
    28
// can potentially lose more time than is gained.
sl@0
    29
sl@0
    30
#define __CHECK_ALPHA01__
sl@0
    31
sl@0
    32
#define WRITE_RUN \
sl@0
    33
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
sl@0
    34
		{ \
sl@0
    35
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
    36
			{ \
sl@0
    37
			case 0:        do {  write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    38
			case 7:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    39
			case 6:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    40
			case 5:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    41
			case 4:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    42
			case 3:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    43
			case 2:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    44
			case 1:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    45
				} while ((aLen -= 8) > 0); \
sl@0
    46
			} \
sl@0
    47
		}
sl@0
    48
sl@0
    49
#define WRITE_RUN2ROT \
sl@0
    50
	FORCEINLINE static void write2rot(const TUint8* aSrc, TUint8* aDst, TInt aLen, TInt aSrcStep, TInt aDstStep) \
sl@0
    51
		{ \
sl@0
    52
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
    53
			{ \
sl@0
    54
			case 0:        do {  write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    55
			case 7:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    56
			case 6:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    57
			case 5:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    58
			case 4:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    59
			case 3:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    60
			case 2:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    61
			case 1:              write(aSrc, aDst);aSrc+=aSrcStep;aDst+=aDstStep; \
sl@0
    62
				} while ((aLen -= 8) > 0); \
sl@0
    63
			} \
sl@0
    64
		}
sl@0
    65
sl@0
    66
#define WRITE_RUN2H \
sl@0
    67
	static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen);
sl@0
    68
sl@0
    69
#define WRITE_RUN2C(class3232) \
sl@0
    70
	void class3232::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
sl@0
    71
		{ \
sl@0
    72
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
    73
			{ \
sl@0
    74
			case 0:        do {  write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    75
			case 7:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    76
			case 6:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    77
			case 5:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    78
			case 4:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    79
			case 3:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    80
			case 2:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    81
			case 1:              write(aSrc, aDst);aSrc+=4;aDst+=4; \
sl@0
    82
				} while ((aLen -= 8) > 0); \
sl@0
    83
			} \
sl@0
    84
		}
sl@0
    85
sl@0
    86
#define WRITE_RUN2416 \
sl@0
    87
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
sl@0
    88
		{ \
sl@0
    89
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
    90
			{ \
sl@0
    91
			case 0:        do {  write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    92
			case 7:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    93
			case 6:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    94
			case 5:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    95
			case 4:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    96
			case 3:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    97
			case 2:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    98
			case 1:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
    99
				} while ((aLen -= 8) > 0); \
sl@0
   100
			} \
sl@0
   101
		}
sl@0
   102
sl@0
   103
#define WRITE_RUN3216 \
sl@0
   104
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
sl@0
   105
		{ \
sl@0
   106
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   107
			{ \
sl@0
   108
			case 0:        do {  write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   109
			case 7:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   110
			case 6:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   111
			case 5:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   112
			case 4:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   113
			case 3:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   114
			case 2:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   115
			case 1:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   116
				} while ((aLen -= 8) > 0); \
sl@0
   117
			} \
sl@0
   118
		}
sl@0
   119
sl@0
   120
#define WRITE_RUN3216C2(class3216) \
sl@0
   121
	void class3216::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
sl@0
   122
		{ \
sl@0
   123
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   124
			{ \
sl@0
   125
			case 0:        do {  write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   126
			case 7:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   127
			case 6:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   128
			case 5:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   129
			case 4:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   130
			case 3:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   131
			case 2:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   132
			case 1:              write(aSrc, aDst);aSrc+=4;aDst+=2; \
sl@0
   133
				} while ((aLen -= 8) > 0); \
sl@0
   134
			} \
sl@0
   135
		}
sl@0
   136
sl@0
   137
#define WRITE_RUN2416C2(class2416) \
sl@0
   138
	void class2416::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen) \
sl@0
   139
		{ \
sl@0
   140
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   141
			{ \
sl@0
   142
			case 0:        do {  write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   143
			case 7:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   144
			case 6:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   145
			case 5:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   146
			case 4:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   147
			case 3:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   148
			case 2:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   149
			case 1:              write(aSrc, aDst);aSrc+=3;aDst+=2; \
sl@0
   150
				} while ((aLen -= 8) > 0); \
sl@0
   151
			} \
sl@0
   152
		}
sl@0
   153
sl@0
   154
#define WRITE_RUN1632 \
sl@0
   155
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen) \
sl@0
   156
		{ \
sl@0
   157
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   158
			{ \
sl@0
   159
			case 0:        do {  write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   160
			case 7:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   161
			case 6:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   162
			case 5:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   163
			case 4:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   164
			case 3:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   165
			case 2:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   166
			case 1:              write(aSrc, aDst);aSrc+=2;aDst+=4; \
sl@0
   167
				} while ((aLen -= 8) > 0); \
sl@0
   168
			} \
sl@0
   169
		}
sl@0
   170
sl@0
   171
// Using non-inline versions can make better usage of registers, need to experiment to find fastest mix
sl@0
   172
sl@0
   173
#define WRITE_RUN1632C(class1632) \
sl@0
   174
	void class1632::write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)\
sl@0
   175
		{ \
sl@0
   176
		const TUint16* lowAdd = Convert16to32bppLow();\
sl@0
   177
		const TUint32* highAdd = Convert16to32bppHigh();\
sl@0
   178
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   179
			{ \
sl@0
   180
			case 0:        do {  Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   181
			case 7:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   182
			case 6:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   183
			case 5:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   184
			case 4:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   185
			case 3:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   186
			case 2:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   187
			case 1:              Write64KTo16MLookup(aSrc, aDst, lowAdd, highAdd);aSrc+=2;aDst+=4; \
sl@0
   188
				} while ((aLen -= 8) > 0); \
sl@0
   189
			} \
sl@0
   190
		}
sl@0
   191
sl@0
   192
#define WRITE_ALPHA_MASK_RUN \
sl@0
   193
	FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   194
		{ \
sl@0
   195
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   196
			{ \
sl@0
   197
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   198
			case 7:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   199
			case 6:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   200
			case 5:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   201
			case 4:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   202
			case 3:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   203
			case 2:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   204
			case 1:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=4; \
sl@0
   205
				} while ((aLen -= 8) > 0); \
sl@0
   206
			} \
sl@0
   207
		}
sl@0
   208
sl@0
   209
#define WRITE_ALPHA_MASK_RUN3216 \
sl@0
   210
	FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   211
		{ \
sl@0
   212
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   213
			{ \
sl@0
   214
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   215
			case 7:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   216
			case 6:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   217
			case 5:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   218
			case 4:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   219
			case 3:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   220
			case 2:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   221
			case 1:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=4;aDst+=2; \
sl@0
   222
				} while ((aLen -= 8) > 0); \
sl@0
   223
			} \
sl@0
   224
		}
sl@0
   225
sl@0
   226
#define WRITE_ALPHA_MASK_RUN2416 \
sl@0
   227
	FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   228
		{ \
sl@0
   229
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   230
			{ \
sl@0
   231
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   232
			case 7:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   233
			case 6:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   234
			case 5:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   235
			case 4:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   236
			case 3:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   237
			case 2:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   238
			case 1:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=3;aDst+=2; \
sl@0
   239
				} while ((aLen -= 8) > 0); \
sl@0
   240
			} \
sl@0
   241
		}
sl@0
   242
sl@0
   243
#define WRITE_ALPHA_MASK_RUN1632 \
sl@0
   244
	FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   245
		{ \
sl@0
   246
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   247
			{ \
sl@0
   248
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   249
			case 7:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   250
			case 6:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   251
			case 5:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   252
			case 4:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   253
			case 3:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   254
			case 2:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   255
			case 1:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=4; \
sl@0
   256
				} while ((aLen -= 8) > 0); \
sl@0
   257
			} \
sl@0
   258
		}
sl@0
   259
sl@0
   260
#define WRITE_ALPHA_MASK_RUN1632H \
sl@0
   261
	static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen);
sl@0
   262
sl@0
   263
#define WRITE_ALPHA_MASK_RUN1632C(class1632) \
sl@0
   264
	void class1632::writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   265
		{ \
sl@0
   266
		const TUint8* srcPtr=aSrc;\
sl@0
   267
		TUint8* dstPtr=aDst;\
sl@0
   268
		const TUint8* alphaPtr=aAlpha;\
sl@0
   269
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   270
			{ \
sl@0
   271
			case 0:        do {  writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   272
			case 7:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   273
			case 6:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   274
			case 5:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   275
			case 4:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   276
			case 3:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   277
			case 2:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   278
			case 1:              writeMask(srcPtr, dstPtr, *alphaPtr++);srcPtr+=2;dstPtr+=4; \
sl@0
   279
				} while ((aLen -= 8) > 0); \
sl@0
   280
			} \
sl@0
   281
		aSrc=srcPtr;\
sl@0
   282
		aDst=dstPtr;\
sl@0
   283
		aAlpha=alphaPtr;\
sl@0
   284
		}
sl@0
   285
sl@0
   286
#define WRITE_ALPHA_MASK_RUN1616 \
sl@0
   287
	FORCEINLINE static void writeAlphaMask(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen)\
sl@0
   288
		{ \
sl@0
   289
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   290
			{ \
sl@0
   291
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   292
			case 7:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   293
			case 6:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   294
			case 5:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   295
			case 4:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   296
			case 3:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   297
			case 2:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   298
			case 1:              writeMask(aSrc, aDst, *aAlpha++);aSrc+=2;aDst+=2; \
sl@0
   299
				} while ((aLen -= 8) > 0); \
sl@0
   300
			} \
sl@0
   301
		}
sl@0
   302
sl@0
   303
#define WRITE_ALPHA_MASK_RUN_ROT32 \
sl@0
   304
	FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\
sl@0
   305
		{ \
sl@0
   306
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   307
			{ \
sl@0
   308
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   309
			case 7:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   310
			case 6:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   311
			case 5:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   312
			case 4:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   313
			case 3:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   314
			case 2:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   315
			case 1:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=4;aAlpha+=aMaskStride; \
sl@0
   316
				} while ((aLen -= 8) > 0); \
sl@0
   317
			} \
sl@0
   318
		}
sl@0
   319
sl@0
   320
#define WRITE_ALPHA_MASK_RUN_ROT16 \
sl@0
   321
	FORCEINLINE static void writeAlphaMaskRot(const TUint8* &aSrc, TUint8* &aDst, const TUint8* aAlpha, TInt aLen, TInt aSrcStride, TInt aMaskStride)\
sl@0
   322
		{ \
sl@0
   323
		switch (aLen % 8)  /* aLen > 0 assumed */ \
sl@0
   324
			{ \
sl@0
   325
			case 0:        do {  writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   326
			case 7:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   327
			case 6:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   328
			case 5:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   329
			case 4:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   330
			case 3:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   331
			case 2:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   332
			case 1:              writeMask(aSrc, aDst, *aAlpha);aSrc+=aSrcStride;aDst+=2;aAlpha+=aMaskStride; \
sl@0
   333
				} while ((aLen -= 8) > 0); \
sl@0
   334
			} \
sl@0
   335
		}
sl@0
   336
sl@0
   337
#define MultAlphaWithSrcAlpha(aAlpha, aSrc)\
sl@0
   338
	{\
sl@0
   339
	const TUint32 src=*(TUint32*)aSrc;\
sl@0
   340
	TUint32 srcAlpha=src>>24;\
sl@0
   341
	aAlpha=(aAlpha*srcAlpha);\
sl@0
   342
	aAlpha+=srcAlpha;\
sl@0
   343
	aAlpha>>=8;\
sl@0
   344
	}
sl@0
   345
sl@0
   346
// Takes a pre-multipled alpha source and additionally multiplies it by the alpha
sl@0
   347
// value so the source is effectively now pre-multiplied by both it's own alpha
sl@0
   348
// and the specified alpha.
sl@0
   349
// No aAlpha==0xFF or ==0 checks as should never come here in those situations
sl@0
   350
#define MultMapSrcByAlpha(aAlpha, aSrc)\
sl@0
   351
	{\
sl@0
   352
	TUint32 d1 = (aSrc>>8)&0x00FF00FF;\
sl@0
   353
	d1=d1*aAlpha+d1;\
sl@0
   354
	TUint32 d2=aSrc&0x00FF00FF;\
sl@0
   355
	d2=d2*aAlpha+d2;\
sl@0
   356
	aSrc=(d1&0xFF00FF00)|((d2&0xFF00FF00)>>8);\
sl@0
   357
	}
sl@0
   358
sl@0
   359
#define Write16MTo64K(aSrc, aDst)\
sl@0
   360
	{\
sl@0
   361
	TInt color64K=(aSrc & 0x0000f8) >> 3;\
sl@0
   362
	color64K|=(aSrc & 0x00fc00) >> 5;\
sl@0
   363
	color64K|=(aSrc & 0xf80000) >> 8;\
sl@0
   364
	*(TUint16*)aDst = color64K;\
sl@0
   365
	}
sl@0
   366
sl@0
   367
// Calc new alpha as src+(1-src)*dst;
sl@0
   368
#define CalcDestMultAlpha(aDestMultAlpha, aDA, aSrcAlpha, aDstAlpha)\
sl@0
   369
	{\
sl@0
   370
	const TUint32 srcAlpha=aSrcAlpha;\
sl@0
   371
	const TUint32 dstAlpha=aDstAlpha;\
sl@0
   372
	aDA=dstAlpha<<16;\
sl@0
   373
	aDA=aDA*(0x100-srcAlpha);\
sl@0
   374
	aDA+=srcAlpha<<24;\
sl@0
   375
	aDestMultAlpha=(((0x100-srcAlpha)*dstAlpha)>>8)+1;\
sl@0
   376
	}
sl@0
   377
sl@0
   378
// Note: This function assumes incoming rgb's are shifted up by an extra 8 bits as that's the
sl@0
   379
// most efficient way of processing the preceding functions with this final write to 64K handling
sl@0
   380
// the extra shift down.
sl@0
   381
#define WriteRedBlueAndGreenTo64K(aRedBlue, aGreen, aDst)\
sl@0
   382
	{\
sl@0
   383
	TInt targ64K=(aRedBlue&0x00f800) >> 11;\
sl@0
   384
	targ64K|=(aRedBlue&0xf8000000) >> 16;\
sl@0
   385
	targ64K|=(aGreen&0xfc0000) >> 13;\
sl@0
   386
	*(TUint16*)aDst = targ64K;\
sl@0
   387
	}
sl@0
   388
sl@0
   389
sl@0
   390
// Used for calculating blending from a MAP source to any of 16M dest formats.
sl@0
   391
#define CalcMapToMxRGBA(aSrcPixel, aDst, aDestMult, aDestAG, aDestRB)\
sl@0
   392
	{\
sl@0
   393
	const TUint32 dstPixel=*(TUint32*)aDst;\
sl@0
   394
	aDestAG=(dstPixel&0xFF00FF00)>>8;\
sl@0
   395
	aDestAG=aDestAG*aDestMult;\
sl@0
   396
	aDestAG+=aSrcPixel&0xFF00FF00;\
sl@0
   397
	aDestRB=dstPixel&0x00FF00FF;\
sl@0
   398
	aDestRB=(aDestRB*aDestMult)>>8;\
sl@0
   399
	aDestRB+=aSrcPixel&0x00FF00FF;\
sl@0
   400
	}
sl@0
   401
sl@0
   402
// Used For non MAP source blending using dest=src*alpha+dest*destAlpha
sl@0
   403
// aDestMultAlpha is typically (1-aAlpha) or (srcAlpha+(1-srcAlpha)*destAlpha)
sl@0
   404
#define CalcMxToMxRGBA2A(aMxMxSrcPixel, aMxMxDestPixel, aMxMxAlpha, aMxMxDestMultAlpha, aMxMxDestAG, aMxMxDestRB)\
sl@0
   405
	{\
sl@0
   406
	aMxMxDestAG=(aMxMxDestPixel & 0xFF00FF00)>>8;\
sl@0
   407
	aMxMxDestAG=aMxMxDestAG*aMxMxDestMultAlpha;\
sl@0
   408
	TUint32 srcAG=(aMxMxSrcPixel&0xFF00FF00)>>8;\
sl@0
   409
	aMxMxDestAG&=0xFF00FF00;\
sl@0
   410
	TUint32 alphaPlus1=aMxMxAlpha+1;\
sl@0
   411
	aMxMxDestAG+=srcAG*alphaPlus1;\
sl@0
   412
	aMxMxDestRB=aMxMxDestPixel&0x00FF00FF;\
sl@0
   413
	aMxMxDestRB=aMxMxDestRB*aMxMxDestMultAlpha;\
sl@0
   414
	aMxMxDestRB&=0xFF00FF00;\
sl@0
   415
	TUint32 srcRB=(aMxMxSrcPixel&0x00FF00FF);\
sl@0
   416
	aMxMxDestRB+=srcRB*alphaPlus1;\
sl@0
   417
	aMxMxDestRB>>=8;\
sl@0
   418
	}
sl@0
   419
sl@0
   420
// Used For non MAP source blending using dest=src*alpha+dest*(1-alpha)
sl@0
   421
#define CalcMxToMxRGBA(aSrc, aDest, aAlpha, aDestAG, aDestRB)\
sl@0
   422
	{\
sl@0
   423
	const TUint32 srcPixel=*(TUint32*)aSrc;\
sl@0
   424
	const TUint32 dstPixel=*(TUint32*)aDst;\
sl@0
   425
	const TUint32 oneMinusAlpha = 0x100 - aAlpha;\
sl@0
   426
	CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, oneMinusAlpha , aDestAG, aDestRB);\
sl@0
   427
	}
sl@0
   428
sl@0
   429
#define WriteMu(aDestAG, aDestRB, aDst)\
sl@0
   430
	*(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF)|0xFF000000
sl@0
   431
sl@0
   432
#define WriteMxA(aDestG, aDestRB, aDestA, aDst)\
sl@0
   433
	*(TUint32*)aDst=(aDestG&0x0000FF00)|(aDestRB&0x00FF00FF)|(aDestA&0xFF000000)
sl@0
   434
sl@0
   435
#define WriteMx(aDestAG, aDestRB, aDst)\
sl@0
   436
	*(TUint32*)aDst=(aDestAG&0xFF00FF00)|(aDestRB&0x00FF00FF)
sl@0
   437
sl@0
   438
struct TMapToMu
sl@0
   439
	{
sl@0
   440
	#define writeMapMu(aSrc, aDst)\
sl@0
   441
		{\
sl@0
   442
		const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
sl@0
   443
		TUint32 d1;\
sl@0
   444
		TUint32 d2;\
sl@0
   445
		CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\
sl@0
   446
		WriteMu(d1,d2,aDst);\
sl@0
   447
		}
sl@0
   448
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   449
		{
sl@0
   450
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   451
#if defined(__CHECK_ALPHA01__)
sl@0
   452
		if (src >= 0xFF000000)
sl@0
   453
			{
sl@0
   454
			*(TUint32*)aDst = src;
sl@0
   455
			return;
sl@0
   456
			}
sl@0
   457
		if (src <= 0x00FFFFFF)
sl@0
   458
			return;
sl@0
   459
#endif
sl@0
   460
		writeMapMu(src, aDst);
sl@0
   461
		}
sl@0
   462
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   463
	WRITE_RUN2ROT
sl@0
   464
	WRITE_RUN
sl@0
   465
	WRITE_RUN2H
sl@0
   466
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   467
		{
sl@0
   468
		TUint32 src=*(TUint32*)aSrc;
sl@0
   469
#if defined(__CHECK_ALPHA01__)
sl@0
   470
		if (src>0x00FFFFFF)
sl@0
   471
#endif
sl@0
   472
			{
sl@0
   473
			MultMapSrcByAlpha(aAlpha,src);
sl@0
   474
			// No aAlpha==0xFF check as should never come here in that situation
sl@0
   475
			writeMapMu(src, aDst);
sl@0
   476
			}
sl@0
   477
		}
sl@0
   478
	WRITE_ALPHA_MASK_RUN
sl@0
   479
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   480
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   481
	};
sl@0
   482
sl@0
   483
struct TMapToMa
sl@0
   484
	{
sl@0
   485
	#define writeMapMa(aSrc, aDst)\
sl@0
   486
		{\
sl@0
   487
		const TUint32 d=*(TUint32*)aDst;\
sl@0
   488
		TUint32 da;\
sl@0
   489
		TUint32 destMultAlpha;\
sl@0
   490
		CalcDestMultAlpha(destMultAlpha,da,aSrc>>24,d>>24);\
sl@0
   491
		TUint32 d1;\
sl@0
   492
		TUint32 d2;\
sl@0
   493
		CalcMapToMxRGBA(aSrc,aDst,destMultAlpha,d1,d2);\
sl@0
   494
		WriteMxA(d1,d2,da,aDst);\
sl@0
   495
		}
sl@0
   496
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   497
		{
sl@0
   498
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   499
#if defined(__CHECK_ALPHA01__)
sl@0
   500
		if (src>0x00FFFFFF)
sl@0
   501
			{
sl@0
   502
			if (src >= 0xFF000000)
sl@0
   503
				*(TUint32*)aDst=src;
sl@0
   504
			else
sl@0
   505
				writeMapMa(src,aDst);
sl@0
   506
			}
sl@0
   507
#else
sl@0
   508
		writeMapMa(src,aDst);
sl@0
   509
#endif
sl@0
   510
		}
sl@0
   511
	WRITE_RUN
sl@0
   512
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   513
	WRITE_RUN2ROT
sl@0
   514
	WRITE_RUN2H
sl@0
   515
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   516
		{
sl@0
   517
		TUint32 src=*(TUint32*)aSrc;
sl@0
   518
#if defined(__CHECK_ALPHA01__)
sl@0
   519
		if (src>0x00FFFFFF)
sl@0
   520
#endif
sl@0
   521
			{
sl@0
   522
			MultMapSrcByAlpha(aAlpha,src);
sl@0
   523
			// No aAlpha==0xFF check as should never come here in that situation
sl@0
   524
			writeMapMa(src,aDst);
sl@0
   525
			}
sl@0
   526
		}
sl@0
   527
	WRITE_ALPHA_MASK_RUN
sl@0
   528
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   529
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   530
	};
sl@0
   531
sl@0
   532
struct TMapToMap
sl@0
   533
	{
sl@0
   534
	#define writeMapMap(aSrc, aDst)\
sl@0
   535
		{\
sl@0
   536
		const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
sl@0
   537
		TUint32 d1;\
sl@0
   538
		TUint32 d2;\
sl@0
   539
		CalcMapToMxRGBA(aSrc,aDst,oneMinusAlpha,d1,d2);\
sl@0
   540
		WriteMx(d1,d2,aDst);\
sl@0
   541
		}
sl@0
   542
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   543
		{
sl@0
   544
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   545
#if defined(__CHECK_ALPHA01__)
sl@0
   546
		if (src >= 0xFF000000)
sl@0
   547
			{
sl@0
   548
			*(TUint32*)aDst = src;
sl@0
   549
			return;
sl@0
   550
			}
sl@0
   551
		if (src <= 0x00FFFFFF)
sl@0
   552
			return;
sl@0
   553
#endif
sl@0
   554
		writeMapMap(src,aDst);
sl@0
   555
		}
sl@0
   556
	WRITE_RUN
sl@0
   557
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   558
	WRITE_RUN2ROT
sl@0
   559
	WRITE_RUN2H
sl@0
   560
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   561
		{
sl@0
   562
		TUint32 src=*(TUint32*)aSrc;
sl@0
   563
#if defined(__CHECK_ALPHA01__)
sl@0
   564
		if (src<=0x00FFFFFF)
sl@0
   565
			return;
sl@0
   566
#endif
sl@0
   567
		MultMapSrcByAlpha(aAlpha,src);
sl@0
   568
		// No aAlpha==0xFF check as should never come here in that situation
sl@0
   569
		writeMapMap(src,aDst);
sl@0
   570
		}
sl@0
   571
	WRITE_ALPHA_MASK_RUN
sl@0
   572
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   573
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   574
	};
sl@0
   575
sl@0
   576
struct TMaToMu
sl@0
   577
	{
sl@0
   578
	#define writeMaMu(aSrc, aAlpha, aDst)\
sl@0
   579
		{\
sl@0
   580
		TUint32 d1;\
sl@0
   581
		TUint32 d2;\
sl@0
   582
		CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\
sl@0
   583
		WriteMu(d1,d2,aDst);\
sl@0
   584
		}
sl@0
   585
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   586
		{
sl@0
   587
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   588
#if defined(__CHECK_ALPHA01__)
sl@0
   589
		if (src >= 0xFF000000)
sl@0
   590
			{
sl@0
   591
			*(TUint32*)aDst = src;
sl@0
   592
			return;
sl@0
   593
			}
sl@0
   594
		if (src <= 0x00FFFFFF)
sl@0
   595
			return;
sl@0
   596
#endif
sl@0
   597
		const TUint32 alpha=src>>24;
sl@0
   598
		writeMaMu(aSrc,alpha,aDst);
sl@0
   599
		}
sl@0
   600
	WRITE_RUN
sl@0
   601
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   602
	WRITE_RUN2ROT
sl@0
   603
	WRITE_RUN2H
sl@0
   604
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   605
		{
sl@0
   606
		MultAlphaWithSrcAlpha(aAlpha,aSrc);
sl@0
   607
		writeMaMu(aSrc,aAlpha,aDst);
sl@0
   608
		}
sl@0
   609
	WRITE_ALPHA_MASK_RUN
sl@0
   610
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   611
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   612
	};
sl@0
   613
sl@0
   614
struct TMuToMu
sl@0
   615
	{
sl@0
   616
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   617
		{
sl@0
   618
		*(TUint32*)aDst = *(TUint32*)aSrc;
sl@0
   619
		}
sl@0
   620
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
sl@0
   621
		{
sl@0
   622
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   623
		aSrc+=aLen*4;
sl@0
   624
		aDst+=aLen*4;
sl@0
   625
		}
sl@0
   626
	FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
sl@0
   627
		{
sl@0
   628
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   629
		}
sl@0
   630
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   631
	WRITE_RUN2ROT
sl@0
   632
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   633
		{
sl@0
   634
		TUint32 d1;
sl@0
   635
		TUint32 d2;
sl@0
   636
		CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);
sl@0
   637
		WriteMu(d1,d2,aDst);
sl@0
   638
		}
sl@0
   639
	WRITE_ALPHA_MASK_RUN
sl@0
   640
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   641
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   642
	};
sl@0
   643
sl@0
   644
struct TMuToMa
sl@0
   645
	{
sl@0
   646
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   647
		{
sl@0
   648
		*(TUint32*)aDst = (*(TUint32*)aSrc);
sl@0
   649
		}
sl@0
   650
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
sl@0
   651
		{
sl@0
   652
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   653
		aSrc+=aLen*4;
sl@0
   654
		aDst+=aLen*4;
sl@0
   655
		}
sl@0
   656
	FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
sl@0
   657
		{
sl@0
   658
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   659
		}
sl@0
   660
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   661
		{
sl@0
   662
		TUint32 da;
sl@0
   663
		TUint32 d1;
sl@0
   664
		TUint32 d2;
sl@0
   665
		TUint32 destMultAlpha;
sl@0
   666
		const TUint32 d = *(TUint32*)aDst;
sl@0
   667
		CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24);
sl@0
   668
		const TUint32 srcPixel=*(TUint32*)aSrc;
sl@0
   669
		const TUint32 dstPixel=*(TUint32*)aDst;
sl@0
   670
		CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2);
sl@0
   671
		WriteMxA(d1,d2,da,aDst);
sl@0
   672
		}
sl@0
   673
	WRITE_ALPHA_MASK_RUN
sl@0
   674
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   675
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   676
	};
sl@0
   677
sl@0
   678
struct TMaToMa
sl@0
   679
	{
sl@0
   680
	#define writeMaMa(aSrc, aAlpha, aDst)\
sl@0
   681
		{\
sl@0
   682
		TUint32 da;\
sl@0
   683
		TUint32 d1;\
sl@0
   684
		TUint32 d2;\
sl@0
   685
		TUint32 destMultAlpha;\
sl@0
   686
		const TUint32 d = *(TUint32*)aDst;\
sl@0
   687
		CalcDestMultAlpha(destMultAlpha,da,aAlpha,d>>24);\
sl@0
   688
		const TUint32 srcPixel=*(TUint32*)aSrc;\
sl@0
   689
		const TUint32 dstPixel=*(TUint32*)aDst;\
sl@0
   690
		CalcMxToMxRGBA2A(srcPixel, dstPixel, aAlpha, destMultAlpha, d1, d2);\
sl@0
   691
		WriteMxA(d1,d2,da,aDst);\
sl@0
   692
		}
sl@0
   693
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   694
		{
sl@0
   695
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   696
#if defined(__CHECK_ALPHA01__)
sl@0
   697
		if (src >= 0xFF000000)
sl@0
   698
			{
sl@0
   699
			*(TUint32*)aDst = src;
sl@0
   700
			return;
sl@0
   701
			}
sl@0
   702
		if (src <= 0x00FFFFFF)
sl@0
   703
			return;
sl@0
   704
#endif
sl@0
   705
		const TUint32 alpha=src>>24;
sl@0
   706
		writeMaMa(aSrc,alpha,aDst);
sl@0
   707
		}
sl@0
   708
	WRITE_RUN
sl@0
   709
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   710
	WRITE_RUN2ROT
sl@0
   711
	WRITE_RUN2H
sl@0
   712
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   713
		{
sl@0
   714
		MultAlphaWithSrcAlpha(aAlpha,aSrc);
sl@0
   715
		writeMaMa(aSrc,aAlpha,aDst);
sl@0
   716
		}
sl@0
   717
	WRITE_ALPHA_MASK_RUN
sl@0
   718
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   719
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   720
	};
sl@0
   721
sl@0
   722
struct TMaToMap
sl@0
   723
	{
sl@0
   724
	#define writeMaToMap(aSrc, aAlpha, aDst)\
sl@0
   725
		{\
sl@0
   726
		const TUint32 d = *(TUint32*)aDst;\
sl@0
   727
		const TUint32 oneMinusAlpha = 0x100-aAlpha;\
sl@0
   728
		TUint32 da=(d&0xFF000000)>>8;\
sl@0
   729
		da=da*oneMinusAlpha;\
sl@0
   730
		da+=aAlpha<<24;\
sl@0
   731
		TUint32 d1;\
sl@0
   732
		TUint32 d2;\
sl@0
   733
		CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);\
sl@0
   734
		WriteMxA(d1,d2,da,aDst);\
sl@0
   735
		}
sl@0
   736
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   737
		{
sl@0
   738
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   739
#if defined(__CHECK_ALPHA01__)
sl@0
   740
		if (src >= 0xFF000000)
sl@0
   741
			{
sl@0
   742
			*(TUint32*)aDst = src;
sl@0
   743
			return;
sl@0
   744
			}
sl@0
   745
		if (src <= 0x00FFFFFF)
sl@0
   746
			return;
sl@0
   747
#endif
sl@0
   748
		const TUint32 alpha=src>>24;
sl@0
   749
		writeMaToMap(aSrc,alpha,aDst);
sl@0
   750
		}
sl@0
   751
	WRITE_RUN
sl@0
   752
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   753
	WRITE_RUN2ROT
sl@0
   754
	WRITE_RUN2H
sl@0
   755
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   756
		{
sl@0
   757
		MultAlphaWithSrcAlpha(aAlpha,aSrc);
sl@0
   758
		writeMaToMap(aSrc,aAlpha,aDst);
sl@0
   759
		}
sl@0
   760
	WRITE_ALPHA_MASK_RUN
sl@0
   761
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   762
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   763
	};
sl@0
   764
sl@0
   765
struct TMuToMap
sl@0
   766
	{
sl@0
   767
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   768
		{
sl@0
   769
		*(TUint32*)aDst = (*(TUint32*)aSrc);
sl@0
   770
		}
sl@0
   771
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
sl@0
   772
		{
sl@0
   773
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   774
		aSrc+=aLen*4;
sl@0
   775
		aDst+=aLen*4;
sl@0
   776
		}
sl@0
   777
	FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
sl@0
   778
		{
sl@0
   779
		Mem::Move(aDst,aSrc,aLen*sizeof(TUint32));
sl@0
   780
		}
sl@0
   781
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   782
		{
sl@0
   783
		TUint32 d1;
sl@0
   784
		TUint32 d2;
sl@0
   785
		CalcMxToMxRGBA(aSrc, aDst, aAlpha, d1, d2);
sl@0
   786
		WriteMx(d1,d2,aDst);
sl@0
   787
		}
sl@0
   788
	WRITE_ALPHA_MASK_RUN_ROT32
sl@0
   789
	WRITE_RUN2ROT
sl@0
   790
	WRITE_ALPHA_MASK_RUN
sl@0
   791
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   792
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
   793
	};
sl@0
   794
sl@0
   795
WRITE_RUN2C(TMapToMap)
sl@0
   796
WRITE_RUN2C(TMapToMa)
sl@0
   797
WRITE_RUN2C(TMapToMu)
sl@0
   798
WRITE_RUN2C(TMaToMap)
sl@0
   799
WRITE_RUN2C(TMaToMa)
sl@0
   800
WRITE_RUN2C(TMaToMu)
sl@0
   801
sl@0
   802
// reads green value from 64K source, or's it with 0xFF alpha channel, and leaves
sl@0
   803
// it shifted down by 8 ready for multiplying by alpha value.
sl@0
   804
#define ReadGreen64K(aRG64KGreen, aRG64KSrc)\
sl@0
   805
	aRG64KGreen=(aRG64KSrc&0x07E0)>>3;\
sl@0
   806
	aRG64KGreen=((aRG64KGreen+(aRG64KGreen>>6))&0x000000FF)|0x00FF0000;
sl@0
   807
sl@0
   808
// Reads the red and blue values from a 64K source into their RGBA values.
sl@0
   809
#define ReadRedBlue64K(aRedBlue,aColor64K)\
sl@0
   810
	{\
sl@0
   811
	aRedBlue=(aColor64K&0xF800)<<8;\
sl@0
   812
	aRedBlue|=(aColor64K&0x001F)<<3;\
sl@0
   813
	aRedBlue+=aRedBlue>>5;\
sl@0
   814
	aRedBlue&=0x00FF00FF;\
sl@0
   815
	}
sl@0
   816
sl@0
   817
// reads green value from 64K source into aGreen and red and blue into aRedBlue
sl@0
   818
// All left in correct place for 16M operations
sl@0
   819
#define Read64KColors(aGreen,aRedBlue,aPtr)\
sl@0
   820
	{\
sl@0
   821
	const TUint32 r64Kcolor64K=*(TUint16*)aPtr;\
sl@0
   822
	aGreen=(r64Kcolor64K&0x07E0)<<5;\
sl@0
   823
	aGreen+=aGreen>>6;\
sl@0
   824
	aGreen&=0x0000FF00;\
sl@0
   825
	ReadRedBlue64K(aRedBlue,r64Kcolor64K);\
sl@0
   826
	}
sl@0
   827
sl@0
   828
struct TMapTo64K
sl@0
   829
	{
sl@0
   830
	#define writeMap64K(aSrc, aDst)\
sl@0
   831
		{\
sl@0
   832
		TUint32 green;\
sl@0
   833
		TUint32 redBlue;\
sl@0
   834
		Read64KColors(green,redBlue,aDst);\
sl@0
   835
		const TUint32 oneMinusAlpha = 0x100-(aSrc>>24);\
sl@0
   836
		green=green*oneMinusAlpha;\
sl@0
   837
		green+=(aSrc<<8)&0x00FF00FF;\
sl@0
   838
		redBlue=redBlue*oneMinusAlpha;\
sl@0
   839
		redBlue+=(aSrc&0x00FF00FF)<<8;\
sl@0
   840
		WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\
sl@0
   841
		}
sl@0
   842
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   843
		{
sl@0
   844
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   845
#if defined(__CHECK_ALPHA01__)
sl@0
   846
		if (src >= 0xFF000000)
sl@0
   847
			{
sl@0
   848
			Write16MTo64K(src,aDst);
sl@0
   849
			return;
sl@0
   850
			}
sl@0
   851
		if (src <= 0x00FFFFFF)
sl@0
   852
			return;
sl@0
   853
#endif
sl@0
   854
		writeMap64K(src,aDst);
sl@0
   855
		}
sl@0
   856
	WRITE_RUN2H
sl@0
   857
	WRITE_RUN3216
sl@0
   858
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   859
		{
sl@0
   860
		TUint32 src=*(TUint32*)aSrc;
sl@0
   861
#if defined(__CHECK_ALPHA01__)
sl@0
   862
		if (src<=0x00FFFFFF)
sl@0
   863
			return;
sl@0
   864
#endif
sl@0
   865
		MultMapSrcByAlpha(aAlpha,src);
sl@0
   866
		// No aAlpha==0xFF check as should never come here in that situation
sl@0
   867
		writeMap64K(src,aDst);
sl@0
   868
		}
sl@0
   869
	WRITE_ALPHA_MASK_RUN3216
sl@0
   870
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   871
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
sl@0
   872
	};
sl@0
   873
sl@0
   874
// Calculates green and redBlue shifted up by 8, that will be sorted in WriteRedBlueAndGreenTo64K
sl@0
   875
// this works out the most efficient way of getting the end result
sl@0
   876
//
sl@0
   877
// Note +++
sl@0
   878
// Having the extra +greenSrc and +redBlueSrc (as in lines shown below) gives a better result, but
sl@0
   879
// is inconsistent with old code and causes test code failures, so it has been removed.
sl@0
   880
//	greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
   881
//	redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
   882
#define WriteMaOrMuTo64K(aSrc, aDst, aAlpha)\
sl@0
   883
	{\
sl@0
   884
	const TUint32 src=*(TUint32*)aSrc;\
sl@0
   885
	TUint32 green;\
sl@0
   886
	TUint32 redBlue;\
sl@0
   887
	Read64KColors(green,redBlue,aDst);\
sl@0
   888
	const TUint32 oneMinusAlpha = 0x100-aAlpha;\
sl@0
   889
	green=green*oneMinusAlpha;\
sl@0
   890
	TUint32 greenSrc=src&0x0000FF00;\
sl@0
   891
	greenSrc=greenSrc*aAlpha;\
sl@0
   892
	green+=greenSrc;\
sl@0
   893
	redBlue=redBlue*oneMinusAlpha;\
sl@0
   894
	TUint32 redBlueSrc=src&0x00FF00FF;\
sl@0
   895
	redBlueSrc=redBlueSrc*aAlpha;\
sl@0
   896
	redBlue+=redBlueSrc;\
sl@0
   897
	WriteRedBlueAndGreenTo64K(redBlue,green,aDst);\
sl@0
   898
	}
sl@0
   899
sl@0
   900
struct TMTo64K
sl@0
   901
	{
sl@0
   902
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   903
		{
sl@0
   904
		const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16);
sl@0
   905
		Write16MTo64K(src,aDst);
sl@0
   906
		}
sl@0
   907
	WRITE_RUN2416
sl@0
   908
	WRITE_RUN2H
sl@0
   909
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   910
		{
sl@0
   911
		const TUint32 src=aSrc[0]+(aSrc[1]<<8)+(aSrc[2]<<16);
sl@0
   912
		TUint32 green;
sl@0
   913
		TUint32 redBlue;
sl@0
   914
		Read64KColors(green,redBlue,aDst);
sl@0
   915
		const TUint32 oneMinusAlpha = 0x100-aAlpha;
sl@0
   916
		green=green*oneMinusAlpha;
sl@0
   917
		TUint32 greenSrc=src&0x0000FF00;
sl@0
   918
		greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
   919
		green+=greenSrc;
sl@0
   920
		redBlue=redBlue*oneMinusAlpha;
sl@0
   921
		TUint32 redBlueSrc=src&0x00FF00FF;
sl@0
   922
		redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
   923
		redBlue+=redBlueSrc;
sl@0
   924
		WriteRedBlueAndGreenTo64K(redBlue,green,aDst);
sl@0
   925
		}
sl@0
   926
	WRITE_ALPHA_MASK_RUN2416
sl@0
   927
	FORCEINLINE static TInt SrcPixelBytes() {return(3);};
sl@0
   928
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
sl@0
   929
	};
sl@0
   930
sl@0
   931
struct TMuTo64K
sl@0
   932
	{
sl@0
   933
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   934
		{
sl@0
   935
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   936
		Write16MTo64K(src,aDst);
sl@0
   937
		}
sl@0
   938
	WRITE_RUN3216
sl@0
   939
	WRITE_RUN2H
sl@0
   940
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   941
		{
sl@0
   942
		WriteMaOrMuTo64K(aSrc,aDst,aAlpha);
sl@0
   943
		}
sl@0
   944
	WRITE_ALPHA_MASK_RUN3216
sl@0
   945
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   946
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
sl@0
   947
	};
sl@0
   948
sl@0
   949
struct TMaTo64K
sl@0
   950
	{
sl@0
   951
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   952
		{
sl@0
   953
		const TUint32 src=*(TUint32*)aSrc;
sl@0
   954
#if defined(__CHECK_ALPHA01__)
sl@0
   955
		if (src >= 0xFF000000)
sl@0
   956
			{
sl@0
   957
			Write16MTo64K(src,aDst);
sl@0
   958
			return;
sl@0
   959
			}
sl@0
   960
		if (src <= 0x00FFFFFF)
sl@0
   961
			return;
sl@0
   962
#endif
sl@0
   963
		const TUint32 alpha=src>>24;
sl@0
   964
		WriteMaOrMuTo64K(aSrc,aDst,alpha);
sl@0
   965
		}
sl@0
   966
	WRITE_RUN3216
sl@0
   967
	WRITE_RUN2H
sl@0
   968
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   969
		{
sl@0
   970
		MultAlphaWithSrcAlpha(aAlpha,aSrc);
sl@0
   971
		WriteMaOrMuTo64K(aSrc,aDst,aAlpha);
sl@0
   972
		}
sl@0
   973
	WRITE_ALPHA_MASK_RUN3216
sl@0
   974
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint32));};
sl@0
   975
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
sl@0
   976
	};
sl@0
   977
sl@0
   978
struct T64KTo64K
sl@0
   979
	{
sl@0
   980
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
   981
		{
sl@0
   982
		*(TUint16*)aDst=*(const TUint16 *)aSrc;
sl@0
   983
		}
sl@0
   984
	FORCEINLINE static void write(const TUint8* &aSrc, TUint8* &aDst, TInt aLen)
sl@0
   985
		{
sl@0
   986
		Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16));
sl@0
   987
		aSrc+=aLen*2;
sl@0
   988
		aDst+=aLen*2;
sl@0
   989
		}
sl@0
   990
	FORCEINLINE static void write2(const TUint8* aSrc, TUint8* aDst, TInt aLen)
sl@0
   991
		{
sl@0
   992
		Mem::Copy(aDst,aSrc,aLen*sizeof(TUint16));
sl@0
   993
		}
sl@0
   994
	WRITE_ALPHA_MASK_RUN_ROT16
sl@0
   995
	WRITE_RUN2ROT
sl@0
   996
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
   997
		{
sl@0
   998
		const TUint32 oneMinusAlpha = 0x100-aAlpha;
sl@0
   999
//
sl@0
  1000
		TUint32 green;
sl@0
  1001
		TUint32 redBlue;
sl@0
  1002
		Read64KColors(green,redBlue,aDst);
sl@0
  1003
		green=green*oneMinusAlpha;
sl@0
  1004
		TUint32 greenSrc;
sl@0
  1005
		TUint32 redBlueSrc;
sl@0
  1006
		Read64KColors(greenSrc,redBlueSrc,aSrc);
sl@0
  1007
// See note +++
sl@0
  1008
//		greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
  1009
		greenSrc=greenSrc*aAlpha;
sl@0
  1010
		green+=greenSrc;	// needs shift down by 8, but do that when going to 64K
sl@0
  1011
//
sl@0
  1012
		redBlue=redBlue*oneMinusAlpha;
sl@0
  1013
// See note +++
sl@0
  1014
//		redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
  1015
		redBlueSrc=redBlueSrc*aAlpha;
sl@0
  1016
		redBlue+=redBlueSrc;	// needs shift down by 8, but do that when going to 64K
sl@0
  1017
		WriteRedBlueAndGreenTo64K(redBlue,green,aDst);
sl@0
  1018
		}
sl@0
  1019
	WRITE_ALPHA_MASK_RUN1616
sl@0
  1020
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
sl@0
  1021
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint16));};
sl@0
  1022
	};
sl@0
  1023
sl@0
  1024
#define Write64KTo16M(aSrc, aDst)\
sl@0
  1025
	TUint32 w6216Mgreen;\
sl@0
  1026
	TUint32 w6216MredBlue;\
sl@0
  1027
	Read64KColors(w6216Mgreen,w6216MredBlue, aSrc);\
sl@0
  1028
	WriteMu(w6216Mgreen,w6216MredBlue,aDst);
sl@0
  1029
sl@0
  1030
#define Write64KTo16MLookup(aSrc, aDst, aLowAdd, aHighAdd)\
sl@0
  1031
	{\
sl@0
  1032
	const TUint32 srcData=*(TUint16*)aSrc;\
sl@0
  1033
	*(TUint32*)aDst = aHighAdd[srcData>>8] | aLowAdd[srcData&0xff];\
sl@0
  1034
	}
sl@0
  1035
sl@0
  1036
struct T64KToMu
sl@0
  1037
	{
sl@0
  1038
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
  1039
		{
sl@0
  1040
		Write64KTo16M(aSrc,aDst);
sl@0
  1041
		}
sl@0
  1042
	WRITE_RUN1632
sl@0
  1043
	WRITE_RUN2H
sl@0
  1044
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
  1045
		{
sl@0
  1046
		const TUint32 oneMinusAlpha = 0x100-aAlpha;
sl@0
  1047
		const TUint32 d = *(TUint32*)aDst;
sl@0
  1048
		TUint32 src=*(TUint16*)aSrc;
sl@0
  1049
//
sl@0
  1050
		TUint32 green = (d&0x0000FF00)>>8;
sl@0
  1051
		green=green*oneMinusAlpha;
sl@0
  1052
		TUint32 greenSrc;
sl@0
  1053
		ReadGreen64K(greenSrc,src);
sl@0
  1054
// See note +++
sl@0
  1055
//		greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
  1056
		greenSrc=greenSrc*aAlpha;
sl@0
  1057
		green+=greenSrc;
sl@0
  1058
//
sl@0
  1059
		TUint32 redBlue = d&0x00FF00FF;
sl@0
  1060
		redBlue=redBlue*oneMinusAlpha;
sl@0
  1061
		TUint32 redBlueSrc;
sl@0
  1062
		ReadRedBlue64K(redBlueSrc,src);
sl@0
  1063
// See note +++
sl@0
  1064
//		redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
  1065
		redBlueSrc=redBlueSrc*aAlpha;
sl@0
  1066
		redBlue+=redBlueSrc;
sl@0
  1067
//
sl@0
  1068
		redBlue>>=8;
sl@0
  1069
		WriteMu(green,redBlue,aDst);
sl@0
  1070
		}
sl@0
  1071
	WRITE_ALPHA_MASK_RUN1632
sl@0
  1072
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
sl@0
  1073
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
  1074
	};
sl@0
  1075
sl@0
  1076
struct T64KToMa
sl@0
  1077
	{
sl@0
  1078
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
  1079
		{
sl@0
  1080
		Write64KTo16M(aSrc,aDst);
sl@0
  1081
		}
sl@0
  1082
	WRITE_RUN1632
sl@0
  1083
	WRITE_RUN2H
sl@0
  1084
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
  1085
		{
sl@0
  1086
		const TUint32 destSrc = *(TUint32*)aDst;
sl@0
  1087
		TUint32 destAlpha=destSrc>>24;
sl@0
  1088
// Calc new alpha as src+(1-src)*dst;
sl@0
  1089
		destAlpha=(0x100-aAlpha)*destAlpha;
sl@0
  1090
		TUint32 targDestPixel=(destAlpha>>8)<<24;
sl@0
  1091
		targDestPixel+=aAlpha<<24;
sl@0
  1092
//
sl@0
  1093
		TUint32 greenAlpha=(destSrc>>8)&0x000000FF;
sl@0
  1094
		const TUint32 destMultAlpha = (destAlpha>>8)+1;
sl@0
  1095
		greenAlpha=greenAlpha*destMultAlpha;
sl@0
  1096
		TUint32 redBlue = destSrc&0x00FF00FF;
sl@0
  1097
		redBlue=redBlue*destMultAlpha;
sl@0
  1098
//
sl@0
  1099
		TUint32 src=*(TUint16*)aSrc;
sl@0
  1100
		TUint32 greenSrc;
sl@0
  1101
		ReadGreen64K(greenSrc,src);
sl@0
  1102
		greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
  1103
		greenAlpha+=greenSrc;
sl@0
  1104
		targDestPixel|=greenAlpha&0x0000FF00;
sl@0
  1105
//
sl@0
  1106
		TUint32 redBlueSrc;
sl@0
  1107
		ReadRedBlue64K(redBlueSrc,src);
sl@0
  1108
		redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
  1109
		redBlue+=redBlueSrc;
sl@0
  1110
//
sl@0
  1111
		targDestPixel|=(redBlue>>8)&0x00FF00FF;
sl@0
  1112
		*(TUint32*)aDst=targDestPixel;
sl@0
  1113
		}
sl@0
  1114
	WRITE_ALPHA_MASK_RUN1632H
sl@0
  1115
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
sl@0
  1116
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
  1117
	};
sl@0
  1118
sl@0
  1119
WRITE_ALPHA_MASK_RUN1632C(T64KToMa)
sl@0
  1120
sl@0
  1121
struct T64KToMap
sl@0
  1122
	{
sl@0
  1123
	FORCEINLINE static void write(const TUint8 *aSrc, TUint8* aDst)
sl@0
  1124
		{
sl@0
  1125
		Write64KTo16M(aSrc,aDst);
sl@0
  1126
		}
sl@0
  1127
	WRITE_RUN1632
sl@0
  1128
	WRITE_RUN2H
sl@0
  1129
	FORCEINLINE static void writeMask(const TUint8 *aSrc, TUint8* aDst, TUint aAlpha)
sl@0
  1130
		{
sl@0
  1131
		const TUint32 oneMinusAlpha = 0x100-aAlpha;
sl@0
  1132
		const TUint32 d = *(TUint32*)aDst;
sl@0
  1133
		TUint32 src=*(TUint16*)aSrc;
sl@0
  1134
//
sl@0
  1135
		TUint32 greenAlpha = (d&0xFF00FF00)>>8;
sl@0
  1136
		greenAlpha=greenAlpha*oneMinusAlpha;
sl@0
  1137
		TUint32 greenSrc;
sl@0
  1138
		ReadGreen64K(greenSrc,src);
sl@0
  1139
		greenSrc=greenSrc*aAlpha+greenSrc;
sl@0
  1140
		greenAlpha&=0xFF00FF00;	// Needed to stop adding rounding errors together in next step
sl@0
  1141
		greenAlpha+=greenSrc;
sl@0
  1142
//
sl@0
  1143
		TUint32 redBlue = d&0x00FF00FF;
sl@0
  1144
		redBlue=redBlue*oneMinusAlpha;
sl@0
  1145
		TUint32 redBlueSrc;
sl@0
  1146
		ReadRedBlue64K(redBlueSrc,src);
sl@0
  1147
		redBlueSrc=redBlueSrc*aAlpha+redBlueSrc;
sl@0
  1148
		redBlue&=0xFF00FF00; // Needed to stop adding rounding errors together in next step
sl@0
  1149
		redBlue+=redBlueSrc;	// needs shift down by 8, but do that when writing to dest
sl@0
  1150
//
sl@0
  1151
		redBlue>>=8;
sl@0
  1152
		WriteMx(greenAlpha,redBlue,aDst);
sl@0
  1153
		}
sl@0
  1154
	WRITE_ALPHA_MASK_RUN1632
sl@0
  1155
	FORCEINLINE static TInt SrcPixelBytes() {return(sizeof(TUint16));};
sl@0
  1156
	FORCEINLINE static TInt DestPixelBytes() {return(sizeof(TUint32));};
sl@0
  1157
	};
sl@0
  1158
sl@0
  1159
WRITE_RUN1632C(T64KToMap)
sl@0
  1160
WRITE_RUN1632C(T64KToMa)
sl@0
  1161
WRITE_RUN1632C(T64KToMu)
sl@0
  1162
WRITE_RUN3216C2(TMapTo64K)
sl@0
  1163
WRITE_RUN3216C2(TMaTo64K)
sl@0
  1164
WRITE_RUN3216C2(TMuTo64K)
sl@0
  1165
WRITE_RUN2416C2(TMTo64K)
sl@0
  1166
sl@0
  1167
inline TInt InitDda(TInt &aDdaCount, TBool &aStretching, TInt aSrcValue, TInt aDstValue, TInt aSkipSteps)
sl@0
  1168
	{
sl@0
  1169
	aDdaCount=0;
sl@0
  1170
	aStretching=aDstValue>aSrcValue;
sl@0
  1171
	TInt skip=0;
sl@0
  1172
	if (aStretching)
sl@0
  1173
		{
sl@0
  1174
		aDdaCount=aDstValue-1;
sl@0
  1175
		while(aSkipSteps--)
sl@0
  1176
			{
sl@0
  1177
			aDdaCount-=aSrcValue;
sl@0
  1178
			if (aDdaCount<0)
sl@0
  1179
				{
sl@0
  1180
				skip++;
sl@0
  1181
				aDdaCount+=aDstValue;
sl@0
  1182
				}
sl@0
  1183
			}
sl@0
  1184
		}
sl@0
  1185
	else
sl@0
  1186
		{
sl@0
  1187
		aDdaCount=aSrcValue-1;
sl@0
  1188
		while(aSkipSteps)
sl@0
  1189
			{
sl@0
  1190
			aDdaCount-=aDstValue;
sl@0
  1191
			if (aDdaCount<0)
sl@0
  1192
				{
sl@0
  1193
				aSkipSteps--;
sl@0
  1194
				aDdaCount+=aSrcValue;
sl@0
  1195
				}
sl@0
  1196
			skip++;
sl@0
  1197
			}
sl@0
  1198
		}
sl@0
  1199
	return(skip);
sl@0
  1200
	}
sl@0
  1201
sl@0
  1202
inline void DdaStep(TInt &aDdaCount, TBool aStretching, TInt aSrcValue, TInt aDstValue, TInt &aSkipCount)
sl@0
  1203
	{
sl@0
  1204
	if (aStretching)
sl@0
  1205
		{
sl@0
  1206
		aDdaCount-=aSrcValue;
sl@0
  1207
		if (aDdaCount<0)
sl@0
  1208
			{
sl@0
  1209
			aSkipCount++;
sl@0
  1210
			aDdaCount+=aDstValue;
sl@0
  1211
			}
sl@0
  1212
		}
sl@0
  1213
	else
sl@0
  1214
		{
sl@0
  1215
		do
sl@0
  1216
			{
sl@0
  1217
			aSkipCount++;
sl@0
  1218
			aDdaCount-=aDstValue;
sl@0
  1219
			} while(aDdaCount>=0);
sl@0
  1220
		aDdaCount+=aSrcValue;
sl@0
  1221
		}
sl@0
  1222
	}
sl@0
  1223
sl@0
  1224
template <class op>
sl@0
  1225
static void ScaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, TRect& aDstRect, const TRect &aClipRect)
sl@0
  1226
	{
sl@0
  1227
	TInt srcWidth = aSrcRect.Width();
sl@0
  1228
	TInt srcHeight = aSrcRect.Height();
sl@0
  1229
	TInt dstWidth = aDstRect.Width();
sl@0
  1230
	TInt dstHeight = aDstRect.Height();
sl@0
  1231
//
sl@0
  1232
	TInt yDdaCount;
sl@0
  1233
	TBool yStretching;
sl@0
  1234
	TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
sl@0
  1235
//
sl@0
  1236
	TInt xDdaCountBase;
sl@0
  1237
	TBool xStretching;
sl@0
  1238
	TInt sxOffset=aSrcRect.iTl.iX+InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
sl@0
  1239
	sxOffset*=op::SrcPixelBytes();
sl@0
  1240
//
sl@0
  1241
	const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
sl@0
  1242
	const TInt xCount=aClipRect.Width();
sl@0
  1243
	TUint8* dstPixelBase = aDataAddress + aDstStride*aClipRect.iTl.iY + aClipRect.iTl.iX*op::DestPixelBytes();
sl@0
  1244
	for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
sl@0
  1245
		{
sl@0
  1246
		const TUint8* srcPixel = aSrcBase + aSrcStride*ySrcOffset + sxOffset;
sl@0
  1247
		TUint8* dstPixel = dstPixelBase;
sl@0
  1248
		TInt xCountDown=xCount;
sl@0
  1249
		TInt ddaCount = xDdaCountBase;
sl@0
  1250
		if (xStretching)
sl@0
  1251
			{
sl@0
  1252
			do
sl@0
  1253
				{
sl@0
  1254
				op::write(srcPixel, dstPixel);
sl@0
  1255
				dstPixel+=op::DestPixelBytes();
sl@0
  1256
				ddaCount-=srcWidth;
sl@0
  1257
				if (ddaCount<0)
sl@0
  1258
					{
sl@0
  1259
					srcPixel+=op::SrcPixelBytes();
sl@0
  1260
					ddaCount+=dstWidth;
sl@0
  1261
					}
sl@0
  1262
				} while(--xCountDown);
sl@0
  1263
			}
sl@0
  1264
		else
sl@0
  1265
			{
sl@0
  1266
			do
sl@0
  1267
				{
sl@0
  1268
				op::write(srcPixel, dstPixel);
sl@0
  1269
				dstPixel+=op::DestPixelBytes();
sl@0
  1270
				do
sl@0
  1271
					{
sl@0
  1272
					srcPixel+=op::SrcPixelBytes();
sl@0
  1273
					ddaCount-=dstWidth;
sl@0
  1274
					} while(ddaCount>=0);
sl@0
  1275
				ddaCount+=srcWidth;
sl@0
  1276
				} while(--xCountDown);
sl@0
  1277
			}
sl@0
  1278
		dstPixelBase+=aDstStride;
sl@0
  1279
		DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
sl@0
  1280
		}
sl@0
  1281
	}
sl@0
  1282
sl@0
  1283
template <class op>
sl@0
  1284
static void UnscaledFastBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos)
sl@0
  1285
	{
sl@0
  1286
	const TInt blitWidth = aSrcRect.Width();
sl@0
  1287
	const TUint8* srcPixel = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes();
sl@0
  1288
	TUint8* dstPixel = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes();
sl@0
  1289
	const TUint8* dstPixelEnd = dstPixel+aSrcRect.Height()*aDstStride;
sl@0
  1290
	do
sl@0
  1291
		{
sl@0
  1292
		op::write2(srcPixel,dstPixel,blitWidth);
sl@0
  1293
		srcPixel+=aSrcStride;
sl@0
  1294
		dstPixel+=aDstStride;
sl@0
  1295
		} while(dstPixel<dstPixelEnd);
sl@0
  1296
	}
sl@0
  1297
sl@0
  1298
static void ReplaceBlit(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos)
sl@0
  1299
	{
sl@0
  1300
	TInt srcStride=aSrcStride/4;
sl@0
  1301
	TInt dstStride=aDstStride/4;
sl@0
  1302
	TInt dx = aDstPos.iX;
sl@0
  1303
	TInt dstWidth = aSrcRect.Width();
sl@0
  1304
	const TUint32* srcPixel = reinterpret_cast<const TUint32*>(aSrcBase) + srcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX;
sl@0
  1305
	TUint32* dstPixel = ((TUint32*)aDataAddress) + dstStride*aDstPos.iY + dx;
sl@0
  1306
	const TInt copyLen=dstWidth*4;
sl@0
  1307
	for (TInt linesToGo=aSrcRect.Height();linesToGo;--linesToGo)
sl@0
  1308
		{
sl@0
  1309
		// Andy - not convinced that this function is any good atall
sl@0
  1310
		// try stdlib memcpy instead.
sl@0
  1311
		Mem::Move(dstPixel, srcPixel, copyLen);
sl@0
  1312
		srcPixel+=srcStride;
sl@0
  1313
		dstPixel+=dstStride;
sl@0
  1314
		}
sl@0
  1315
	}
sl@0
  1316
sl@0
  1317
template <class op>
sl@0
  1318
static void UnscaledFastBlitRot(const TUint8* aSrcBase, CFbsDrawDevice::TOrientation aOrientation, TInt aSrcStride, TRect& aSrcRect, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TSize &aDestSize, TUint32* aScanLineBuffer)
sl@0
  1319
	{
sl@0
  1320
	TInt srcStep=op::SrcPixelBytes();
sl@0
  1321
	TInt dstStep=op::DestPixelBytes();
sl@0
  1322
	TInt dstStride=aDstStride;
sl@0
  1323
	TInt blitWidth = aSrcRect.Width(); 
sl@0
  1324
	TInt blitHeight = aSrcRect.Height(); 
sl@0
  1325
	const TUint8* srcPixel = aSrcBase + aSrcRect.iTl.iY*aSrcStride + aSrcRect.iTl.iX*srcStep; 
sl@0
  1326
	const TUint8* srcPixelEnd = srcPixel + blitHeight*aSrcStride;
sl@0
  1327
	TUint8* dstPixel = aDataAddress; 
sl@0
  1328
	
sl@0
  1329
	
sl@0
  1330
	switch(aOrientation)
sl@0
  1331
		{
sl@0
  1332
		case CFbsDrawDevice::EOrientationRotated90:
sl@0
  1333
			dstPixel += (aDstPos.iX*aDstStride + (aDestSize.iWidth-aDstPos.iY-1)*op::DestPixelBytes());
sl@0
  1334
			dstStep = aDstStride;
sl@0
  1335
			dstStride = - op::DestPixelBytes();
sl@0
  1336
			break;
sl@0
  1337
		case CFbsDrawDevice::EOrientationRotated180: 
sl@0
  1338
			dstPixel += ( (aDestSize.iHeight - aDstPos.iY -1 )*aDstStride +(aDestSize.iWidth - aDstPos.iX -1)*op::DestPixelBytes() ) ;
sl@0
  1339
			dstStep = -dstStep;
sl@0
  1340
			dstStride = -aDstStride;
sl@0
  1341
			break;
sl@0
  1342
		case CFbsDrawDevice::EOrientationRotated270:
sl@0
  1343
			dstPixel += ( (aDestSize.iHeight- aDstPos.iX - 1 )*aDstStride + aDstPos.iY*op::DestPixelBytes() ) ;
sl@0
  1344
			dstStep = -aDstStride;
sl@0
  1345
			dstStride = op::DestPixelBytes();
sl@0
  1346
			break;
sl@0
  1347
		}
sl@0
  1348
	do
sl@0
  1349
		{
sl@0
  1350
		Mem::Copy(aScanLineBuffer, srcPixel, blitWidth*srcStep);
sl@0
  1351
		op::write2rot((TUint8*)aScanLineBuffer, dstPixel, blitWidth, srcStep, dstStep);
sl@0
  1352
		srcPixel+=aSrcStride;
sl@0
  1353
		dstPixel+=dstStride;
sl@0
  1354
		} 
sl@0
  1355
		while(srcPixel<srcPixelEnd);
sl@0
  1356
	}
sl@0
  1357
sl@0
  1358
template <class op>
sl@0
  1359
static void ScaledFastBlitMaskedG2(const TUint8* aSrcBase, TInt aSrcStride, const TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TBool aInvertMask, TUint8 *aDataAddress, TInt aDstStride, const TRect& aDstRect, const TRect &aClipRect)
sl@0
  1360
	{
sl@0
  1361
	TInt sx = aSrcRect.iTl.iX;
sl@0
  1362
	TInt sxOffset=sx*op::SrcPixelBytes();
sl@0
  1363
	
sl@0
  1364
	TInt srcWidth = aSrcRect.Width();
sl@0
  1365
	TInt srcHeight = aSrcRect.Height();
sl@0
  1366
	TInt dstWidth = aDstRect.Width();
sl@0
  1367
	TInt dstHeight = aDstRect.Height();
sl@0
  1368
//
sl@0
  1369
	TInt yDdaCount;
sl@0
  1370
	TBool yStretching;
sl@0
  1371
	TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
sl@0
  1372
//
sl@0
  1373
	TInt xDdaCountBase;
sl@0
  1374
	TBool xStretching;
sl@0
  1375
	TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
sl@0
  1376
//
sl@0
  1377
	const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
sl@0
  1378
	const TInt xCount=aClipRect.Width();
sl@0
  1379
	TUint8* dstPixelBase = aDataAddress+aDstStride*aClipRect.iTl.iY+aClipRect.iTl.iX*op::DestPixelBytes();
sl@0
  1380
	for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
sl@0
  1381
		{
sl@0
  1382
		const TUint8* srcPixel = aSrcBase+aSrcStride*ySrcOffset+sxOffset;
sl@0
  1383
		const TUint32* mskRowBase = (const TUint32*)(aMaskBase+aMaskStride*ySrcOffset);
sl@0
  1384
		TUint8* dstPixel = dstPixelBase;
sl@0
  1385
		TInt xCountDown=xCount;
sl@0
  1386
		TInt curMaskOffset=-1;
sl@0
  1387
		TUint32 maskbits=0;
sl@0
  1388
		TInt xOffset=xOffsetBase;
sl@0
  1389
		TInt ddaCount = xDdaCountBase;
sl@0
  1390
		if (xStretching)
sl@0
  1391
			{
sl@0
  1392
			do
sl@0
  1393
				{
sl@0
  1394
				const TInt maskOffset=xOffset+sx;
sl@0
  1395
				TInt maskBitOffset=maskOffset>>5;
sl@0
  1396
				if (curMaskOffset==maskBitOffset)
sl@0
  1397
					{
sl@0
  1398
blitIt1:			const TInt mask=1<<(maskOffset%32);
sl@0
  1399
					if (maskbits&mask)
sl@0
  1400
						op::write(srcPixel, dstPixel);
sl@0
  1401
					dstPixel+=op::DestPixelBytes();
sl@0
  1402
					ddaCount-=srcWidth;
sl@0
  1403
					if (ddaCount<0)
sl@0
  1404
						{
sl@0
  1405
						xOffset++;
sl@0
  1406
						srcPixel+=op::SrcPixelBytes();
sl@0
  1407
						ddaCount+=dstWidth;
sl@0
  1408
						}
sl@0
  1409
					continue;
sl@0
  1410
					}
sl@0
  1411
				maskbits=*(mskRowBase+maskBitOffset);
sl@0
  1412
				if (aInvertMask)
sl@0
  1413
					maskbits=~maskbits;
sl@0
  1414
				curMaskOffset=maskBitOffset;
sl@0
  1415
				goto blitIt1;
sl@0
  1416
				} while(--xCountDown);
sl@0
  1417
			}
sl@0
  1418
		else
sl@0
  1419
			{
sl@0
  1420
			do
sl@0
  1421
				{
sl@0
  1422
				const TInt maskOffset=xOffset+sx;
sl@0
  1423
				TInt maskBitOffset=maskOffset>>5;
sl@0
  1424
				if (curMaskOffset==maskBitOffset)
sl@0
  1425
					{
sl@0
  1426
blitIt2:			const TInt mask=1<<(maskOffset%32);
sl@0
  1427
					if (maskbits&mask)
sl@0
  1428
						op::write(srcPixel, dstPixel);
sl@0
  1429
					dstPixel+=op::DestPixelBytes();
sl@0
  1430
					do
sl@0
  1431
						{
sl@0
  1432
						xOffset++;
sl@0
  1433
						srcPixel+=op::SrcPixelBytes();
sl@0
  1434
						ddaCount-=dstWidth;
sl@0
  1435
						} while(ddaCount>=0);
sl@0
  1436
					ddaCount+=srcWidth;
sl@0
  1437
					continue;
sl@0
  1438
					}
sl@0
  1439
				maskbits=*(mskRowBase+maskBitOffset);
sl@0
  1440
				if (aInvertMask)
sl@0
  1441
					maskbits=~maskbits;
sl@0
  1442
				curMaskOffset=maskBitOffset;
sl@0
  1443
				goto blitIt2;
sl@0
  1444
				} while(--xCountDown);
sl@0
  1445
			}
sl@0
  1446
		dstPixelBase+=aDstStride;
sl@0
  1447
		DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
sl@0
  1448
		}
sl@0
  1449
	}
sl@0
  1450
sl@0
  1451
template <class op>
sl@0
  1452
static void UnscaledFastBlitMaskedG2(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TBool aInvertMask, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TPoint& aMaskSrcPos, const TSize &aMaskSize)
sl@0
  1453
	{
sl@0
  1454
	TInt sx = aSrcRect.iTl.iX;
sl@0
  1455
	TInt sy = aSrcRect.iTl.iY;
sl@0
  1456
	TInt dx = aDstPos.iX;
sl@0
  1457
	TInt dy = aDstPos.iY;
sl@0
  1458
	
sl@0
  1459
	TInt dstWidth = aSrcRect.Width();
sl@0
  1460
	TInt dstHeight = aSrcRect.Height();
sl@0
  1461
	TInt maskWidth=aMaskSize.iWidth;
sl@0
  1462
	TInt maskHeight=aMaskSize.iHeight;
sl@0
  1463
	TInt maskXStart=aMaskSrcPos.iX%maskWidth;
sl@0
  1464
	TInt maskStartShift=maskXStart&0x1F;
sl@0
  1465
	TInt xMaskLoopCount=1+(dstWidth-1)/maskWidth;
sl@0
  1466
	const TUint8* mskBasePtr=aMaskBase + (maskXStart/32)*4;
sl@0
  1467
	for(TInt xMaskLoop=0;xMaskLoop<xMaskLoopCount;xMaskLoop++)
sl@0
  1468
	  {
sl@0
  1469
	  TInt xOffset=xMaskLoop*maskWidth;
sl@0
  1470
	  TInt blitWidth=Min(maskWidth-maskStartShift,dstWidth-xOffset);
sl@0
  1471
	  const TUint8* srcPixelStart = aSrcBase + aSrcStride*sy + (sx+xOffset)*op::SrcPixelBytes();
sl@0
  1472
	  TUint8* dstPixelStart = aDataAddress + aDstStride*dy + (dx+xOffset)*op::DestPixelBytes();
sl@0
  1473
	  for(TInt yPos=0;yPos<dstHeight;yPos++)
sl@0
  1474
		{
sl@0
  1475
		const TUint8* srcPixel=srcPixelStart;
sl@0
  1476
		const TUint32* mskPixel=(const TUint32*)(mskBasePtr + aMaskStride*((aMaskSrcPos.iY+yPos)%maskHeight));
sl@0
  1477
		TUint8* dstPixel=dstPixelStart;
sl@0
  1478
		TUint mask=1<<maskStartShift;
sl@0
  1479
		TUint32 maskPixels=*mskPixel;
sl@0
  1480
		if (aInvertMask)
sl@0
  1481
			maskPixels=~maskPixels;
sl@0
  1482
		TInt runCount=0;
sl@0
  1483
		TInt toGo=blitWidth;
sl@0
  1484
		TUint32 endMask=0;
sl@0
  1485
		const TInt tgMinusRun0=toGo+maskStartShift;
sl@0
  1486
		if (tgMinusRun0<32)
sl@0
  1487
			{
sl@0
  1488
			endMask=1<<tgMinusRun0;
sl@0
  1489
			maskPixels|=endMask;	// ensure the end of the scanline will fail set run where we will check for the end
sl@0
  1490
			}
sl@0
  1491
		// Into skip loop first, assume start of scanline more likely to be masked out than set
sl@0
  1492
		FOREVER
sl@0
  1493
			{
sl@0
  1494
			if (!(mask&maskPixels))
sl@0
  1495
				{
sl@0
  1496
				runCount++;
sl@0
  1497
rbm2startSkipRun:
sl@0
  1498
				mask<<=1;
sl@0
  1499
				if (mask!=0)
sl@0
  1500
					continue;
sl@0
  1501
				mask=1;
sl@0
  1502
rbm2nextMaskSkip:
sl@0
  1503
				const TInt tgMinusRun1=toGo-runCount;
sl@0
  1504
				if (tgMinusRun1 == 0)
sl@0
  1505
					{
sl@0
  1506
					endMask = mask;
sl@0
  1507
					maskPixels = endMask;
sl@0
  1508
					}
sl@0
  1509
				else
sl@0
  1510
					{
sl@0
  1511
					maskPixels=*++mskPixel;
sl@0
  1512
					if (aInvertMask)
sl@0
  1513
						{
sl@0
  1514
						maskPixels=~maskPixels;
sl@0
  1515
						}
sl@0
  1516
					if (tgMinusRun1<32)
sl@0
  1517
						{
sl@0
  1518
						endMask=1<<tgMinusRun1;
sl@0
  1519
						maskPixels|=endMask;	// ensure the end of the scanline will fail set run where we will check for the end
sl@0
  1520
						}
sl@0
  1521
					else if (maskPixels==0)
sl@0
  1522
						{
sl@0
  1523
						runCount+=32;
sl@0
  1524
						goto rbm2nextMaskSkip;
sl@0
  1525
						}
sl@0
  1526
					}
sl@0
  1527
				continue;
sl@0
  1528
				}
sl@0
  1529
			toGo-=runCount;
sl@0
  1530
			if (toGo==0)
sl@0
  1531
				goto rbm2nextY;
sl@0
  1532
			dstPixel+=runCount*op::DestPixelBytes();
sl@0
  1533
			srcPixel+=runCount*op::SrcPixelBytes();
sl@0
  1534
			runCount=1;
sl@0
  1535
			maskPixels^=endMask;	// toggle the end mask (if there is one)
sl@0
  1536
			goto rbm2startSetRun;
sl@0
  1537
			}
sl@0
  1538
// Code within this section deals with runs of pixels to set
sl@0
  1539
			{
sl@0
  1540
rbm2startTopLoop:
sl@0
  1541
			if (mask&maskPixels)
sl@0
  1542
				{
sl@0
  1543
				runCount++;
sl@0
  1544
rbm2startSetRun:
sl@0
  1545
				mask<<=1;
sl@0
  1546
				if (mask!=0)
sl@0
  1547
					goto rbm2startTopLoop;
sl@0
  1548
				mask=1;
sl@0
  1549
rbm2nextMaskSet:
sl@0
  1550
				const TInt tgMinusRun2=toGo-runCount;
sl@0
  1551
				if (tgMinusRun2 == 0)
sl@0
  1552
					{
sl@0
  1553
					endMask = mask;
sl@0
  1554
					maskPixels = 0;
sl@0
  1555
					}
sl@0
  1556
				else
sl@0
  1557
					{
sl@0
  1558
					maskPixels=*++mskPixel;
sl@0
  1559
					if (aInvertMask)
sl@0
  1560
						{
sl@0
  1561
						maskPixels=~maskPixels;
sl@0
  1562
						}
sl@0
  1563
					if (tgMinusRun2<32)
sl@0
  1564
						{
sl@0
  1565
						endMask=mask<<tgMinusRun2;
sl@0
  1566
						maskPixels&=~endMask;	// ensure the end of the scanline will fail set run where we will check for the end
sl@0
  1567
						}
sl@0
  1568
					else if (maskPixels==0xFFFFFFFF)
sl@0
  1569
						{
sl@0
  1570
						runCount+=32;
sl@0
  1571
						goto rbm2nextMaskSet;
sl@0
  1572
						}
sl@0
  1573
					}
sl@0
  1574
				goto rbm2startTopLoop;
sl@0
  1575
				}
sl@0
  1576
			op::write(srcPixel, dstPixel, runCount);
sl@0
  1577
			toGo-=runCount;
sl@0
  1578
			if (toGo==0)
sl@0
  1579
				goto rbm2nextY;
sl@0
  1580
			maskPixels^=endMask;	// toggle the end mask (if there is one)
sl@0
  1581
			runCount=1;
sl@0
  1582
			goto rbm2startSkipRun;
sl@0
  1583
			}
sl@0
  1584
rbm2nextY:
sl@0
  1585
		srcPixelStart+=aSrcStride;
sl@0
  1586
		dstPixelStart+=aDstStride;
sl@0
  1587
		}
sl@0
  1588
	  maskStartShift=0;
sl@0
  1589
	  }
sl@0
  1590
	}
sl@0
  1591
sl@0
  1592
template <class op>
sl@0
  1593
static void ScaledFastBlitMaskedG256(const TUint8* aSrcBase, TInt aSrcStride, const TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TUint8 *aDataAddress, TInt aDstStride, const TRect& aDstRect, const TRect &aClipRect)
sl@0
  1594
	{
sl@0
  1595
	TInt sx = aSrcRect.iTl.iX;
sl@0
  1596
	TInt sxOffset=sx*op::SrcPixelBytes();
sl@0
  1597
	
sl@0
  1598
	TInt srcWidth = aSrcRect.Width();
sl@0
  1599
	TInt srcHeight = aSrcRect.Height();
sl@0
  1600
	TInt dstWidth = aDstRect.Width();
sl@0
  1601
	TInt dstHeight = aDstRect.Height();
sl@0
  1602
//
sl@0
  1603
	TInt yDdaCount;
sl@0
  1604
	TBool yStretching;
sl@0
  1605
	TInt ySrcOffset=aSrcRect.iTl.iY+InitDda(yDdaCount, yStretching, srcHeight, dstHeight, aClipRect.iTl.iY-aDstRect.iTl.iY);
sl@0
  1606
//
sl@0
  1607
	TInt xDdaCountBase;
sl@0
  1608
	TBool xStretching;
sl@0
  1609
	TInt xOffsetBase=InitDda(xDdaCountBase, xStretching, srcWidth, dstWidth, aClipRect.iTl.iX-aDstRect.iTl.iX);
sl@0
  1610
//
sl@0
  1611
	const TInt yEnd=aClipRect.iBr.iY-aDstRect.iTl.iY;
sl@0
  1612
	const TInt xCount=aClipRect.Width();
sl@0
  1613
	TUint8* dstPixelBase = aDataAddress+aClipRect.iTl.iY*aDstStride+aClipRect.iTl.iX*op::DestPixelBytes();
sl@0
  1614
	for (TInt y = aClipRect.iTl.iY-aDstRect.iTl.iY; y < yEnd; ++y)
sl@0
  1615
		{
sl@0
  1616
		const TUint8* srcRowBase = aSrcBase+aSrcStride*ySrcOffset+sxOffset;
sl@0
  1617
		const TUint8* mskRowBase = aMaskBase+aMaskStride*ySrcOffset+sx;
sl@0
  1618
		TUint8* dstPixel = dstPixelBase;
sl@0
  1619
		TInt xCountDown=xCount;
sl@0
  1620
		TInt xOffset=xOffsetBase;
sl@0
  1621
//
sl@0
  1622
		TInt ddaCount = xDdaCountBase;
sl@0
  1623
		if (xStretching)
sl@0
  1624
			{
sl@0
  1625
			do
sl@0
  1626
				{
sl@0
  1627
				TUint mask=*(mskRowBase+xOffset);
sl@0
  1628
				if (mask==0xFF)
sl@0
  1629
					op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel);
sl@0
  1630
				else if (mask!=0)
sl@0
  1631
					op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask);
sl@0
  1632
				dstPixel+=op::DestPixelBytes();
sl@0
  1633
//
sl@0
  1634
				ddaCount-=srcWidth;
sl@0
  1635
				if (ddaCount<0)
sl@0
  1636
					{
sl@0
  1637
					xOffset++;
sl@0
  1638
					ddaCount+=dstWidth;
sl@0
  1639
					}
sl@0
  1640
				} while(--xCountDown);
sl@0
  1641
			}
sl@0
  1642
		else
sl@0
  1643
			{
sl@0
  1644
			do
sl@0
  1645
				{
sl@0
  1646
				TUint mask=*(mskRowBase+xOffset);
sl@0
  1647
				if (mask==0xFF)
sl@0
  1648
					op::write(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel);
sl@0
  1649
				else if (mask!=0)
sl@0
  1650
					op::writeMask(srcRowBase + xOffset*op::SrcPixelBytes(), dstPixel, mask);
sl@0
  1651
				dstPixel+=op::DestPixelBytes();
sl@0
  1652
//
sl@0
  1653
				do
sl@0
  1654
					{
sl@0
  1655
					xOffset++;
sl@0
  1656
					ddaCount-=dstWidth;
sl@0
  1657
					} while(ddaCount>=0);
sl@0
  1658
				ddaCount+=srcWidth;
sl@0
  1659
				} while(--xCountDown);
sl@0
  1660
			}
sl@0
  1661
		dstPixelBase+=aDstStride;
sl@0
  1662
		DdaStep(yDdaCount, yStretching, srcHeight, dstHeight, ySrcOffset);
sl@0
  1663
		}
sl@0
  1664
	}
sl@0
  1665
sl@0
  1666
template <class op>
sl@0
  1667
static void UnscaledFastBlitMaskedG256(const TUint8* aSrcBase, TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride, TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TPoint& aMaskSrcPos, const TSize &aMaskSize)
sl@0
  1668
	{
sl@0
  1669
	TInt dstWidth = aSrcRect.Width();
sl@0
  1670
	const TInt dstHeight = aSrcRect.Height();
sl@0
  1671
	const TUint8* srcPixelStart = aSrcBase + aSrcStride*aSrcRect.iTl.iY + aSrcRect.iTl.iX*op::SrcPixelBytes();
sl@0
  1672
	TUint8* dstPixelStart = aDataAddress + aDstStride*aDstPos.iY + aDstPos.iX*op::DestPixelBytes();
sl@0
  1673
	TInt yPos=0;
sl@0
  1674
	const TInt maskWidth=aMaskSize.iWidth;
sl@0
  1675
	const TInt maskHeight=aMaskSize.iHeight;
sl@0
  1676
	const TInt maskStartOffset=aMaskSrcPos.iX%maskWidth;
sl@0
  1677
	FOREVER
sl@0
  1678
		{
sl@0
  1679
		const TUint8* srcPixel=srcPixelStart;
sl@0
  1680
		const TUint8* maskBase=aMaskBase + (aMaskStride*((aMaskSrcPos.iY+yPos)%maskHeight));
sl@0
  1681
		const TUint8* mskPixel=maskBase + maskStartOffset;
sl@0
  1682
		const TUint8* mskEnd=maskBase + maskWidth;
sl@0
  1683
		if (dstWidth<(mskEnd-mskPixel))
sl@0
  1684
			mskEnd=mskPixel+dstWidth;
sl@0
  1685
		TUint8* dstPixel=dstPixelStart;
sl@0
  1686
		const TUint8* runStart=mskPixel;
sl@0
  1687
		TInt toGo=dstWidth;
sl@0
  1688
		FOREVER
sl@0
  1689
			{
sl@0
  1690
// Into skip loop first, assume start of scanline more likely to be masked out than set
sl@0
  1691
			TInt runLen1=0;
sl@0
  1692
skipPixels:
sl@0
  1693
			while(mskPixel<mskEnd && *mskPixel==0)
sl@0
  1694
				mskPixel++;
sl@0
  1695
			const TInt runSubLen1=mskPixel-runStart;
sl@0
  1696
			runLen1+=runSubLen1;
sl@0
  1697
			toGo-=runSubLen1;
sl@0
  1698
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1699
				{
sl@0
  1700
				mskPixel=maskBase;
sl@0
  1701
				runStart=maskBase;
sl@0
  1702
				if (toGo<maskWidth)
sl@0
  1703
					mskEnd=mskPixel+toGo;
sl@0
  1704
				goto skipPixels;
sl@0
  1705
				}
sl@0
  1706
			dstPixel+=runLen1*op::DestPixelBytes();
sl@0
  1707
			srcPixel+=runLen1*op::SrcPixelBytes();
sl@0
  1708
			if (toGo==0)
sl@0
  1709
				break;
sl@0
  1710
			runStart=mskPixel++;
sl@0
  1711
			if (*runStart!=255)
sl@0
  1712
				goto blendIt;
sl@0
  1713
// Fall through to solid fill code
sl@0
  1714
solidFill:
sl@0
  1715
			{// bracketing to avoid gccxml compile errors
sl@0
  1716
			TInt runLen2=0;
sl@0
  1717
solidFill2:
sl@0
  1718
			while(mskPixel<mskEnd && *mskPixel==0xFF)
sl@0
  1719
				mskPixel++;
sl@0
  1720
			{// bracketing to avoid gccxml compile errors
sl@0
  1721
			const TInt runSubLen2=mskPixel-runStart;
sl@0
  1722
			runLen2+=runSubLen2;
sl@0
  1723
			toGo-=runSubLen2;
sl@0
  1724
			}
sl@0
  1725
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1726
				{
sl@0
  1727
				mskPixel=maskBase;
sl@0
  1728
				runStart=maskBase;
sl@0
  1729
				if (toGo<maskWidth)
sl@0
  1730
					mskEnd=mskPixel+toGo;
sl@0
  1731
				goto solidFill2;
sl@0
  1732
				}
sl@0
  1733
			if (runLen2)
sl@0
  1734
				op::write(srcPixel, dstPixel, runLen2);
sl@0
  1735
			}
sl@0
  1736
			if (toGo==0)
sl@0
  1737
				break;
sl@0
  1738
			runStart=mskPixel++;
sl@0
  1739
			if (*runStart==0)
sl@0
  1740
				continue;
sl@0
  1741
blendIt:
sl@0
  1742
			while(mskPixel<mskEnd && *mskPixel!=0 && *mskPixel!=255)
sl@0
  1743
				mskPixel++;
sl@0
  1744
			const TInt runSubLen3=mskPixel-runStart;
sl@0
  1745
			if (runSubLen3)
sl@0
  1746
				{
sl@0
  1747
				toGo-=runSubLen3;
sl@0
  1748
				op::writeAlphaMask(srcPixel,dstPixel,runStart,runSubLen3);
sl@0
  1749
				}
sl@0
  1750
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1751
				{
sl@0
  1752
				mskPixel=maskBase;
sl@0
  1753
				runStart=maskBase;
sl@0
  1754
				if (toGo<maskWidth)
sl@0
  1755
					mskEnd=mskPixel+toGo;
sl@0
  1756
				goto blendIt;
sl@0
  1757
				}
sl@0
  1758
			if (toGo==0)
sl@0
  1759
				break;
sl@0
  1760
			runStart=mskPixel++;
sl@0
  1761
			if (*runStart==255)
sl@0
  1762
				goto solidFill;
sl@0
  1763
			}
sl@0
  1764
		if (++yPos==dstHeight)
sl@0
  1765
			break;
sl@0
  1766
		srcPixelStart+=aSrcStride;
sl@0
  1767
		dstPixelStart+=aDstStride;
sl@0
  1768
		}
sl@0
  1769
	}
sl@0
  1770
sl@0
  1771
template <class op>
sl@0
  1772
static void UnscaledFastBlitMaskedRotG256(const TUint8* aSrcBase, CFbsDrawDevice::TOrientation aOrientation, 
sl@0
  1773
				TInt aSrcStride, TRect& aSrcRect, const TUint8* aMaskBase, TInt aMaskStride,
sl@0
  1774
				TUint8 *aDataAddress, TUint32 aDstStride, const TPoint& aDstPos, const TSize &aDestSize,
sl@0
  1775
				const TPoint& aMaskSrcPos, const TSize &aMaskSize)
sl@0
  1776
	{
sl@0
  1777
	TPoint dstPos(aDstPos);
sl@0
  1778
	TInt srcStep=op::SrcPixelBytes();
sl@0
  1779
	TInt maskStep=1;
sl@0
  1780
	TRect srcRect(aSrcRect);
sl@0
  1781
	TSize maskSize(aMaskSize);
sl@0
  1782
	TPoint maskSrcPos(aMaskSrcPos);
sl@0
  1783
	switch(aOrientation)
sl@0
  1784
		{
sl@0
  1785
	case CFbsDrawDevice::EOrientationRotated90:
sl@0
  1786
		srcStep=-aSrcStride;
sl@0
  1787
		aSrcStride=op::SrcPixelBytes();
sl@0
  1788
		maskStep=-aMaskStride;
sl@0
  1789
		aMaskStride=1;
sl@0
  1790
		dstPos.iX=aDestSize.iWidth-aDstPos.iY-aSrcRect.Height();
sl@0
  1791
		dstPos.iY=aDstPos.iX;
sl@0
  1792
		srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX);
sl@0
  1793
		maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth);
sl@0
  1794
		maskSrcPos.iX=aMaskSrcPos.iY;
sl@0
  1795
		maskSrcPos.iY=aMaskSrcPos.iX;
sl@0
  1796
		break;
sl@0
  1797
	case CFbsDrawDevice::EOrientationRotated180:
sl@0
  1798
		srcStep=-op::SrcPixelBytes();
sl@0
  1799
		maskStep=-1;
sl@0
  1800
		aSrcStride=-aSrcStride;
sl@0
  1801
		aMaskStride=-aMaskStride;
sl@0
  1802
		dstPos.iX=aDestSize.iWidth-aDstPos.iX-aSrcRect.Width();
sl@0
  1803
		dstPos.iY=aDestSize.iHeight-aDstPos.iY-aSrcRect.Height();
sl@0
  1804
		break;
sl@0
  1805
	case CFbsDrawDevice::EOrientationRotated270:
sl@0
  1806
		srcStep=aSrcStride;
sl@0
  1807
		aSrcStride=-op::SrcPixelBytes();
sl@0
  1808
		maskStep=aMaskStride;
sl@0
  1809
		aMaskStride=-1;
sl@0
  1810
		dstPos.iX=aDstPos.iY;
sl@0
  1811
		dstPos.iY=aDestSize.iHeight-aDstPos.iX-aSrcRect.Width();
sl@0
  1812
		srcRect.SetRect(aSrcRect.iTl.iY,aSrcRect.iTl.iX,aSrcRect.iBr.iY,aSrcRect.iBr.iX);
sl@0
  1813
		maskSrcPos.iX=aMaskSrcPos.iY;
sl@0
  1814
		maskSrcPos.iY=aMaskSrcPos.iX;
sl@0
  1815
		maskSize.SetSize(aMaskSize.iHeight,aMaskSize.iWidth);
sl@0
  1816
		break;
sl@0
  1817
		}
sl@0
  1818
	const TUint8* srcPixelStart = aSrcBase;
sl@0
  1819
	if (srcStep>0)
sl@0
  1820
		srcPixelStart+=srcRect.iTl.iX*srcStep;
sl@0
  1821
	else
sl@0
  1822
		srcPixelStart-=(srcRect.iBr.iX-1)*srcStep;
sl@0
  1823
	if (aSrcStride>0)
sl@0
  1824
		srcPixelStart+=srcRect.iTl.iY*aSrcStride;
sl@0
  1825
	else
sl@0
  1826
		srcPixelStart-=(srcRect.iBr.iY-1)*aSrcStride;
sl@0
  1827
//
sl@0
  1828
	const TInt dstWidth = srcRect.Width();
sl@0
  1829
	const TInt dstHeight = srcRect.Height();
sl@0
  1830
	TUint8* dstPixelStart = aDataAddress + aDstStride*dstPos.iY + dstPos.iX*op::DestPixelBytes();
sl@0
  1831
	TInt yPos=0;
sl@0
  1832
	const TInt maskWidth=dstWidth<maskSize.iWidth?dstWidth:maskSize.iWidth;
sl@0
  1833
	const TInt maskHeight=maskSize.iHeight;
sl@0
  1834
	const TInt maskStartOffset=(maskStep>0?maskSrcPos.iX:srcRect.iBr.iX-1)%maskSize.iWidth;
sl@0
  1835
	FOREVER
sl@0
  1836
		{
sl@0
  1837
		const TUint8* srcPixel=srcPixelStart;
sl@0
  1838
		const TUint8* maskBase=aMaskBase;
sl@0
  1839
		TInt maskYpos=(maskSrcPos.iY+yPos)%maskHeight;
sl@0
  1840
		if (aMaskStride>0)
sl@0
  1841
			maskBase+=maskYpos*aMaskStride;
sl@0
  1842
		else
sl@0
  1843
			{
sl@0
  1844
			TInt maskEndPos=(maskSrcPos.iY+dstHeight-1-yPos)%maskHeight;
sl@0
  1845
			maskBase-=maskEndPos*aMaskStride;
sl@0
  1846
			}
sl@0
  1847
		const TUint8* mskPixel=maskBase;
sl@0
  1848
		const TUint8* mskEnd=maskBase;
sl@0
  1849
		if (maskStep>0)
sl@0
  1850
			{
sl@0
  1851
			mskPixel+=maskStartOffset*maskStep;
sl@0
  1852
			mskEnd+=maskSize.iWidth*maskStep;
sl@0
  1853
			}
sl@0
  1854
		else
sl@0
  1855
			{
sl@0
  1856
			maskBase-=(maskSize.iWidth-1)*maskStep;
sl@0
  1857
			mskPixel-=maskStartOffset*maskStep;
sl@0
  1858
			mskEnd+=maskStep;
sl@0
  1859
			}
sl@0
  1860
		const TInt maskToGo=(mskEnd-mskPixel)/maskStep;
sl@0
  1861
		if (maskToGo>dstWidth)
sl@0
  1862
			mskEnd=mskPixel+dstWidth*maskStep;
sl@0
  1863
		TUint8* dstPixel=dstPixelStart;
sl@0
  1864
		const TUint8* runStart=mskPixel;
sl@0
  1865
		TInt toGo=dstWidth;
sl@0
  1866
		FOREVER
sl@0
  1867
			{
sl@0
  1868
// Into skip loop first, assume start of scanline more likely to be masked out than set
sl@0
  1869
			TInt runLen1=0;
sl@0
  1870
skipPixels:
sl@0
  1871
			while(mskPixel!=mskEnd && *mskPixel==0)
sl@0
  1872
				mskPixel+=maskStep;
sl@0
  1873
			const TInt runSubLen1=(mskPixel-runStart)/maskStep;
sl@0
  1874
			runLen1+=runSubLen1;
sl@0
  1875
			toGo-=runSubLen1;
sl@0
  1876
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1877
				{
sl@0
  1878
				mskPixel=maskBase;
sl@0
  1879
				runStart=maskBase;
sl@0
  1880
				if (toGo<maskWidth)
sl@0
  1881
					mskEnd=mskPixel+toGo*maskStep;
sl@0
  1882
				goto skipPixels;
sl@0
  1883
				}
sl@0
  1884
			dstPixel+=runLen1*op::DestPixelBytes();
sl@0
  1885
			srcPixel+=runLen1*srcStep;
sl@0
  1886
			if (toGo==0)
sl@0
  1887
				break;
sl@0
  1888
			runStart=mskPixel;
sl@0
  1889
			mskPixel+=maskStep;
sl@0
  1890
			if (*runStart!=255)
sl@0
  1891
				goto blendIt;
sl@0
  1892
// Fall through to solid fill code
sl@0
  1893
solidFill:
sl@0
  1894
			{// bracketing to avoid gccxml compile errors
sl@0
  1895
			TInt runLen2=0;
sl@0
  1896
solidFill2:
sl@0
  1897
			while(mskPixel!=mskEnd && *mskPixel==0xFF)
sl@0
  1898
				mskPixel+=maskStep;
sl@0
  1899
			{// bracketing to avoid gccxml compile errors
sl@0
  1900
			const TInt runSubLen2=(mskPixel-runStart)/maskStep;
sl@0
  1901
			runLen2+=runSubLen2;
sl@0
  1902
			toGo-=runSubLen2;
sl@0
  1903
			}
sl@0
  1904
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1905
				{
sl@0
  1906
				mskPixel=maskBase;
sl@0
  1907
				runStart=maskBase;
sl@0
  1908
				if (toGo<maskWidth)
sl@0
  1909
					mskEnd=mskPixel+toGo*maskStep;
sl@0
  1910
				goto solidFill2;
sl@0
  1911
				}
sl@0
  1912
			if (runLen2)
sl@0
  1913
				{
sl@0
  1914
				op::write2rot(srcPixel,dstPixel,runLen2,srcStep, op::DestPixelBytes());
sl@0
  1915
				srcPixel+=runLen2*srcStep;
sl@0
  1916
				dstPixel+=runLen2*op::DestPixelBytes();
sl@0
  1917
				}
sl@0
  1918
			}
sl@0
  1919
			if (toGo==0)
sl@0
  1920
				break;
sl@0
  1921
			runStart=mskPixel;
sl@0
  1922
			mskPixel+=maskStep;
sl@0
  1923
			if (*runStart==0)
sl@0
  1924
				continue;
sl@0
  1925
blendIt:
sl@0
  1926
			while(mskPixel!=mskEnd && *mskPixel!=0 && *mskPixel!=255)
sl@0
  1927
				mskPixel+=maskStep;
sl@0
  1928
			const TInt runSubLen3=(mskPixel-runStart)/maskStep;
sl@0
  1929
			if (runSubLen3)
sl@0
  1930
				{
sl@0
  1931
				toGo-=runSubLen3;
sl@0
  1932
				op::writeAlphaMaskRot(srcPixel,dstPixel,runStart,runSubLen3,srcStep,maskStep);
sl@0
  1933
				}
sl@0
  1934
			if (mskPixel==mskEnd && toGo!=0)
sl@0
  1935
				{
sl@0
  1936
				mskPixel=maskBase;
sl@0
  1937
				runStart=maskBase;
sl@0
  1938
				if (toGo<maskWidth)
sl@0
  1939
					mskEnd=mskPixel+toGo*maskStep;
sl@0
  1940
				goto blendIt;
sl@0
  1941
				}
sl@0
  1942
			if (toGo==0)
sl@0
  1943
				break;
sl@0
  1944
			runStart=mskPixel;
sl@0
  1945
			mskPixel+=maskStep;
sl@0
  1946
			if (*runStart==255)
sl@0
  1947
				goto solidFill;
sl@0
  1948
			}
sl@0
  1949
		if (++yPos==dstHeight)
sl@0
  1950
			break;
sl@0
  1951
		srcPixelStart+=aSrcStride;
sl@0
  1952
		dstPixelStart+=aDstStride;
sl@0
  1953
		}
sl@0
  1954
	}
sl@0
  1955
sl@0
  1956
void CDrawBitmap::GetBlendPosAndRect(TRect &aSrcRect, const TRect &aSrcRectIn, const TSize &aSrcSize, const TPoint &aDestOffset)
sl@0
  1957
	{
sl@0
  1958
	aSrcRect.iTl=aSrcRectIn.iTl+aDestOffset;
sl@0
  1959
	aSrcRect.iBr=aSrcRectIn.iBr;
sl@0
  1960
// Wrap source top left to within source bitmap
sl@0
  1961
	if (aSrcRect.iTl.iX<0)
sl@0
  1962
		{
sl@0
  1963
		TInt negOffset=1-(aSrcRect.iTl.iX+1)/aSrcSize.iWidth;
sl@0
  1964
		aSrcRect.Move(negOffset*aSrcSize.iWidth,0);
sl@0
  1965
		}
sl@0
  1966
	else if (aSrcRect.iTl.iX>=aSrcSize.iWidth)
sl@0
  1967
		aSrcRect.Move(-(aSrcRect.iTl.iX/aSrcSize.iWidth)*aSrcSize.iWidth,0);
sl@0
  1968
	if (aSrcRect.iTl.iY<0)
sl@0
  1969
		{
sl@0
  1970
		TInt negOffset=1-(aSrcRect.iTl.iY+1)/aSrcSize.iHeight;
sl@0
  1971
		aSrcRect.Move(0,negOffset*aSrcSize.iHeight);
sl@0
  1972
		}
sl@0
  1973
	else if (aSrcRect.iTl.iY>=aSrcSize.iHeight)
sl@0
  1974
		aSrcRect.Move(0,-(aSrcRect.iTl.iY/aSrcSize.iHeight)*aSrcSize.iHeight);
sl@0
  1975
	if (aSrcRect.iBr.iY>aSrcSize.iHeight)
sl@0
  1976
		aSrcRect.iBr.iY=aSrcSize.iHeight;
sl@0
  1977
	if (aSrcRect.iBr.iX>aSrcSize.iWidth)
sl@0
  1978
		aSrcRect.iBr.iX=aSrcSize.iWidth;
sl@0
  1979
	}
sl@0
  1980
sl@0
  1981
void CDrawBitmap::GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDstRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize)
sl@0
  1982
	{
sl@0
  1983
	aDstRect=aDstRectIn;
sl@0
  1984
	aSrcRect=aSrcRectIn;
sl@0
  1985
	if (aSrcRect.iTl.iX<0)
sl@0
  1986
		aSrcRect.iTl.iX=0;
sl@0
  1987
	if (aSrcRect.iTl.iY<0)
sl@0
  1988
		aSrcRect.iTl.iY=0;
sl@0
  1989
	TInt extraWidth=aSrcRect.iBr.iX-aSrcSize.iWidth;
sl@0
  1990
	if (extraWidth>0)
sl@0
  1991
		aSrcRect.iBr.iX-=extraWidth;
sl@0
  1992
	TInt extraHeight=aSrcRect.iBr.iY-aSrcSize.iHeight;
sl@0
  1993
	if (extraHeight>0)
sl@0
  1994
		aSrcRect.iBr.iY-=extraHeight;
sl@0
  1995
	}
sl@0
  1996
sl@0
  1997
TInt CDrawBitmap::FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
sl@0
  1998
							const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch,
sl@0
  1999
							TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
sl@0
  2000
							const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
sl@0
  2001
							CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
sl@0
  2002
	{
sl@0
  2003
	if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch) ||
sl@0
  2004
		!FastBlendMaskSupported(aMaskDisplayMode, aMaskStride) ||
sl@0
  2005
    	iOrientation!=EOrientationNormal)
sl@0
  2006
		return(KErrNotSupported);
sl@0
  2007
	TRect srcRect;
sl@0
  2008
	TRect dstRect;
sl@0
  2009
	GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize);
sl@0
  2010
	const TInt KDestModeShift=8;
sl@0
  2011
	const TInt KMaskModeShift=16;
sl@0
  2012
#define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<<KDestModeShift)|(mask<<KMaskModeShift)
sl@0
  2013
#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
sl@0
  2014
	TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift)|(aMaskDisplayMode<<KMaskModeShift);
sl@0
  2015
	if (srcRect.iBr.iX>aMaskSize.iWidth || srcRect.iBr.iY>aMaskSize.iHeight)
sl@0
  2016
		return(KErrNotSupported);
sl@0
  2017
	TUint8 *dstBits=reinterpret_cast<TUint8*>(iBits);
sl@0
  2018
	TInt dstStride=iScanLineWords*4;
sl@0
  2019
	const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
sl@0
  2020
	const TUint8 *maskBits=reinterpret_cast<const TUint8*>(aMaskBase);
sl@0
  2021
	if (!dstRect.IsEmpty() && !srcRect.IsEmpty())
sl@0
  2022
		{
sl@0
  2023
		switch (switchValue)
sl@0
  2024
			{
sl@0
  2025
// 16MA source
sl@0
  2026
			MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2):
sl@0
  2027
				ScaledFastBlitMaskedG2<TMaToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2028
				break;
sl@0
  2029
			MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2):
sl@0
  2030
				ScaledFastBlitMaskedG2<TMaToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2031
				break;
sl@0
  2032
			MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2):
sl@0
  2033
				ScaledFastBlitMaskedG2<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2034
				break;
sl@0
  2035
			MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
sl@0
  2036
				ScaledFastBlitMaskedG256<TMaToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2037
				break;
sl@0
  2038
			MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
sl@0
  2039
				ScaledFastBlitMaskedG256<TMaToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2040
				break;
sl@0
  2041
			MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256):
sl@0
  2042
				ScaledFastBlitMaskedG256<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2043
				break;
sl@0
  2044
	// 16MU source
sl@0
  2045
			MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2):
sl@0
  2046
				ScaledFastBlitMaskedG2<TMuToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2047
				break;
sl@0
  2048
			MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2):
sl@0
  2049
				ScaledFastBlitMaskedG2<TMuToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2050
				break;
sl@0
  2051
			MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2):
sl@0
  2052
				ScaledFastBlitMaskedG2<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2053
				break;
sl@0
  2054
			MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2):
sl@0
  2055
				ScaledFastBlitMaskedG2<TMTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2056
				break;
sl@0
  2057
			MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
sl@0
  2058
				ScaledFastBlitMaskedG256<TMuToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2059
				break;
sl@0
  2060
			MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
sl@0
  2061
				ScaledFastBlitMaskedG256<TMuToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2062
				break;
sl@0
  2063
			MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256):
sl@0
  2064
				ScaledFastBlitMaskedG256<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2065
				break;
sl@0
  2066
			MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256):
sl@0
  2067
				ScaledFastBlitMaskedG256<TMTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2068
				break;
sl@0
  2069
	// 16MAP source
sl@0
  2070
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2):
sl@0
  2071
				ScaledFastBlitMaskedG2<TMapToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2072
				break;
sl@0
  2073
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2):
sl@0
  2074
				ScaledFastBlitMaskedG2<TMapToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2075
				break;
sl@0
  2076
			MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2):
sl@0
  2077
				ScaledFastBlitMaskedG2<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2078
				break;
sl@0
  2079
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
sl@0
  2080
				ScaledFastBlitMaskedG256<TMapToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2081
				break;
sl@0
  2082
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
sl@0
  2083
				ScaledFastBlitMaskedG256<TMapToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2084
				break;
sl@0
  2085
			MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256):
sl@0
  2086
				ScaledFastBlitMaskedG256<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2087
				break;
sl@0
  2088
	// 64K source
sl@0
  2089
			MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2):
sl@0
  2090
				ScaledFastBlitMaskedG2<T64KToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2091
				break;
sl@0
  2092
			MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2):
sl@0
  2093
				ScaledFastBlitMaskedG2<T64KToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2094
				break;
sl@0
  2095
			MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2):
sl@0
  2096
				ScaledFastBlitMaskedG2<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2097
				break;
sl@0
  2098
			MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256):
sl@0
  2099
				ScaledFastBlitMaskedG256<T64KToMu>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2100
				break;
sl@0
  2101
			MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256):
sl@0
  2102
				ScaledFastBlitMaskedG256<T64KToMap>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2103
				break;
sl@0
  2104
			MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
sl@0
  2105
				ScaledFastBlitMaskedG256<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2106
				break;
sl@0
  2107
#if defined(__SUPPORT_16MA_TARGET__)
sl@0
  2108
			MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2):
sl@0
  2109
				ScaledFastBlitMaskedG2<TMaToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2110
				break;
sl@0
  2111
			MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256):
sl@0
  2112
				ScaledFastBlitMaskedG256<TMaToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2113
				break;
sl@0
  2114
			MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2):
sl@0
  2115
				ScaledFastBlitMaskedG2<TMuToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2116
				break;
sl@0
  2117
			MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256):
sl@0
  2118
				ScaledFastBlitMaskedG256<TMuToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2119
				break;
sl@0
  2120
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2):
sl@0
  2121
				ScaledFastBlitMaskedG2<TMapToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2122
				break;
sl@0
  2123
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256):
sl@0
  2124
				ScaledFastBlitMaskedG256<TMapToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2125
				break;
sl@0
  2126
			MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2):
sl@0
  2127
				ScaledFastBlitMaskedG2<T64KToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2128
				break;
sl@0
  2129
			MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256):
sl@0
  2130
				ScaledFastBlitMaskedG256<T64KToMa>(srcBase, aSrcLinePitch, srcRect, maskBits, aMaskStride, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2131
				break;
sl@0
  2132
#endif
sl@0
  2133
			default:
sl@0
  2134
				return KErrNotSupported;
sl@0
  2135
			}
sl@0
  2136
		}
sl@0
  2137
	return(KErrNone);
sl@0
  2138
	}
sl@0
  2139
sl@0
  2140
TInt CDrawBitmap::FastBlendBitmapScaled(const TRect &aClipRect, const TRect& aDest, const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
sl@0
  2141
	{
sl@0
  2142
	if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcLinePitch))
sl@0
  2143
		return(KErrNotSupported);
sl@0
  2144
	TRect srcRect;
sl@0
  2145
	TRect dstRect;
sl@0
  2146
	GetBlendPosAndRect(dstRect,srcRect,aDest,aSrcRect,aSrcSize);
sl@0
  2147
	const TInt KDestModeShift=8;
sl@0
  2148
#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
sl@0
  2149
	TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
sl@0
  2150
	TUint8 *dstBits=reinterpret_cast<TUint8*>(iBits);
sl@0
  2151
	TInt dstStride=iScanLineWords*4;
sl@0
  2152
	const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
sl@0
  2153
	if (!dstRect.IsEmpty() && !srcRect.IsEmpty())
sl@0
  2154
		{
sl@0
  2155
		switch (switchValue)
sl@0
  2156
			{
sl@0
  2157
// 16MA Source
sl@0
  2158
			MODE_SWITCH(EColor16MA,EColor16MU):
sl@0
  2159
				ScaledFastBlit<TMaToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2160
				break;
sl@0
  2161
			MODE_SWITCH(EColor16MA,EColor16MAP):
sl@0
  2162
				ScaledFastBlit<TMaToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2163
				break;
sl@0
  2164
			MODE_SWITCH(EColor16MA,EColor64K):
sl@0
  2165
				ScaledFastBlit<TMaTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2166
				break;
sl@0
  2167
// 16MAP Source
sl@0
  2168
			MODE_SWITCH(EColor16MAP,EColor16MU):
sl@0
  2169
				ScaledFastBlit<TMapToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2170
				break;
sl@0
  2171
			MODE_SWITCH(EColor16MAP,EColor16MAP):
sl@0
  2172
				ScaledFastBlit<TMapToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2173
				break;
sl@0
  2174
			MODE_SWITCH(EColor16MAP,EColor64K):
sl@0
  2175
				ScaledFastBlit<TMapTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2176
				break;
sl@0
  2177
// 16MU Source
sl@0
  2178
			MODE_SWITCH(EColor16MU,EColor16MU):
sl@0
  2179
				ScaledFastBlit<TMuToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2180
				break;
sl@0
  2181
			MODE_SWITCH(EColor16MU,EColor64K):
sl@0
  2182
				ScaledFastBlit<TMuTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2183
				break;
sl@0
  2184
			// No EColor16MU to EColor16MAP fast blit performed because it
sl@0
  2185
			// cannot be guaranteed that the alpha channel of the EColor16MU
sl@0
  2186
			// source is 0xFF, which any fast blit would require. 
sl@0
  2187
// 64K Source
sl@0
  2188
			MODE_SWITCH(EColor64K,EColor16MU):
sl@0
  2189
				ScaledFastBlit<T64KToMu>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2190
				break;
sl@0
  2191
			MODE_SWITCH(EColor64K,EColor16MAP):
sl@0
  2192
				ScaledFastBlit<T64KToMap>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2193
				break;
sl@0
  2194
			MODE_SWITCH(EColor64K,EColor64K):
sl@0
  2195
				ScaledFastBlit<T64KTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2196
				break;
sl@0
  2197
// 16M source
sl@0
  2198
			MODE_SWITCH(EColor16M,EColor64K):
sl@0
  2199
				ScaledFastBlit<TMTo64K>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2200
				break;
sl@0
  2201
#if defined(__SUPPORT_16MA_TARGET__)
sl@0
  2202
			MODE_SWITCH(EColor16MA,EColor16MA):
sl@0
  2203
				ScaledFastBlit<TMaToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2204
				break;
sl@0
  2205
			MODE_SWITCH(EColor16MAP,EColor16MA):
sl@0
  2206
				ScaledFastBlit<TMapToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2207
				break;
sl@0
  2208
			MODE_SWITCH(EColor64K,EColor16MA):
sl@0
  2209
				ScaledFastBlit<T64KToMa>(srcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstRect, aClipRect);
sl@0
  2210
				break;
sl@0
  2211
			// No EColor16MU to EColor16MA fast blit performed because it
sl@0
  2212
			// cannot be guaranteed that the alpha channel of the EColor16MU
sl@0
  2213
			// source is 0xFF, which any fast blit would require. 
sl@0
  2214
#endif
sl@0
  2215
			default:
sl@0
  2216
				return KErrNotSupported;
sl@0
  2217
			}
sl@0
  2218
		}
sl@0
  2219
	return KErrNone;
sl@0
  2220
	}
sl@0
  2221
sl@0
  2222
TInt CDrawBitmap::DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize)
sl@0
  2223
	{
sl@0
  2224
	const TInt KDestModeShift=8;
sl@0
  2225
	TInt dstStride=iScanLineWords*4;
sl@0
  2226
	TUint8 *dstBits=(TUint8*)iBits;
sl@0
  2227
#define MODE_SWITCH(src,dest) case src|(dest<<KDestModeShift)
sl@0
  2228
	TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
sl@0
  2229
	TInt xEnd=aDest.iX+aSrcRect.Width();
sl@0
  2230
	TInt yEnd=aDest.iY+aSrcRect.Height();
sl@0
  2231
	TPoint dstPos;
sl@0
  2232
	dstPos.iY=aDest.iY;
sl@0
  2233
	while(dstPos.iY<yEnd)
sl@0
  2234
		{
sl@0
  2235
		TRect srcRect;
sl@0
  2236
		dstPos.iX=aDest.iX;
sl@0
  2237
		while(dstPos.iX<xEnd)
sl@0
  2238
			{
sl@0
  2239
// Clip source rect to within source bitmap size
sl@0
  2240
			GetBlendPosAndRect(srcRect,aSrcRect,aSrcSize,dstPos-aDest);
sl@0
  2241
			if (iOrientation==EOrientationNormal)
sl@0
  2242
				{
sl@0
  2243
				switch (switchValue)
sl@0
  2244
					{
sl@0
  2245
		// 16MA Source
sl@0
  2246
				MODE_SWITCH(EColor16MA,EColor16MU):
sl@0
  2247
					UnscaledFastBlit<TMaToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2248
					break;
sl@0
  2249
				MODE_SWITCH(EColor16MA,EColor16MAP):
sl@0
  2250
					UnscaledFastBlit<TMaToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2251
					break;
sl@0
  2252
				MODE_SWITCH(EColor16MA,EColor64K):
sl@0
  2253
					UnscaledFastBlit<TMaTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2254
					break;
sl@0
  2255
		// 16MAP Source
sl@0
  2256
				MODE_SWITCH(EColor16MAP,EColor16MU):
sl@0
  2257
					UnscaledFastBlit<TMapToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2258
					break;
sl@0
  2259
				MODE_SWITCH(EColor16MAP,EColor16MAP):
sl@0
  2260
					UnscaledFastBlit<TMapToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2261
					break;
sl@0
  2262
				MODE_SWITCH(EColor16MAP,EColor64K):
sl@0
  2263
					UnscaledFastBlit<TMapTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2264
					break;
sl@0
  2265
		// 16MU Source
sl@0
  2266
				MODE_SWITCH(EColor16MU,EColor16MU):
sl@0
  2267
					ReplaceBlit(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2268
					break;
sl@0
  2269
				MODE_SWITCH(EColor16MU,EColor64K):
sl@0
  2270
					UnscaledFastBlit<TMuTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2271
					break;
sl@0
  2272
				// No EColor16MU to EColor16MAP fast blit performed because it
sl@0
  2273
				// cannot be guaranteed that the alpha channel of the EColor16MU
sl@0
  2274
				// source is 0xFF, which any fast blit would require. 
sl@0
  2275
		// 64K Source
sl@0
  2276
				MODE_SWITCH(EColor64K,EColor16MU):
sl@0
  2277
					UnscaledFastBlit<T64KToMu>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2278
					break;
sl@0
  2279
				MODE_SWITCH(EColor64K,EColor16MAP):
sl@0
  2280
					UnscaledFastBlit<T64KToMap>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2281
					break;
sl@0
  2282
				MODE_SWITCH(EColor64K,EColor64K):
sl@0
  2283
					UnscaledFastBlit<T64KTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2284
					break;
sl@0
  2285
		// 16M Source
sl@0
  2286
				MODE_SWITCH(EColor16M,EColor64K):
sl@0
  2287
					UnscaledFastBlit<TMTo64K>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2288
					break;
sl@0
  2289
#if defined(__SUPPORT_16MA_TARGET__)
sl@0
  2290
				MODE_SWITCH(EColor16MA,EColor16MA):
sl@0
  2291
					UnscaledFastBlit<TMaToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2292
					break;
sl@0
  2293
				MODE_SWITCH(EColor16MAP,EColor16MA):
sl@0
  2294
					UnscaledFastBlit<TMapToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2295
					break;
sl@0
  2296
				MODE_SWITCH(EColor64K,EColor16MA):
sl@0
  2297
					UnscaledFastBlit<T64KToMa>(aSrcBase, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos);
sl@0
  2298
					break;
sl@0
  2299
				// No EColor16MU to EColor16MA fast blit performed because it
sl@0
  2300
				// cannot be guaranteed that the alpha channel of the EColor16MU
sl@0
  2301
				// source is 0xFF, which any fast blit would require. 
sl@0
  2302
#endif
sl@0
  2303
				default:
sl@0
  2304
					return KErrNotSupported;
sl@0
  2305
					}
sl@0
  2306
				}
sl@0
  2307
			else
sl@0
  2308
				{
sl@0
  2309
				switch (switchValue)
sl@0
  2310
					{
sl@0
  2311
		// 16MA Source
sl@0
  2312
				MODE_SWITCH(EColor16MA,EColor16MU):
sl@0
  2313
					UnscaledFastBlitRot<TMaToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2314
					break;
sl@0
  2315
				MODE_SWITCH(EColor16MA,EColor16MAP):
sl@0
  2316
					UnscaledFastBlitRot<TMaToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2317
					break;
sl@0
  2318
		// 16MAP Source
sl@0
  2319
				MODE_SWITCH(EColor16MAP,EColor16MU):
sl@0
  2320
					UnscaledFastBlitRot<TMapToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2321
					break;
sl@0
  2322
				MODE_SWITCH(EColor16MAP,EColor16MAP):
sl@0
  2323
					UnscaledFastBlitRot<TMapToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2324
					break;
sl@0
  2325
		// 16MU Source
sl@0
  2326
				MODE_SWITCH(EColor16MU,EColor16MU):
sl@0
  2327
					UnscaledFastBlitRot<TMuToMu>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2328
					break;
sl@0
  2329
				MODE_SWITCH(EColor16MU,EColor16MAP):
sl@0
  2330
					UnscaledFastBlitRot<TMuToMap>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2331
					break;
sl@0
  2332
		// 64K Source
sl@0
  2333
				MODE_SWITCH(EColor64K,EColor64K):
sl@0
  2334
					UnscaledFastBlitRot<T64KTo64K>(aSrcBase, iOrientation, aSrcLinePitch, srcRect, dstBits, dstStride, dstPos, iSize, iScanLineBuffer);
sl@0
  2335
					break;
sl@0
  2336
				default:
sl@0
  2337
					return KErrNotSupported;
sl@0
  2338
					}
sl@0
  2339
				}
sl@0
  2340
			dstPos.iX+=srcRect.Width();
sl@0
  2341
			}
sl@0
  2342
		dstPos.iY+=srcRect.Height();
sl@0
  2343
		}
sl@0
  2344
	return KErrNone;
sl@0
  2345
	}
sl@0
  2346
sl@0
  2347
TBool CDrawBitmap::FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch)
sl@0
  2348
    {
sl@0
  2349
    // FastBlend supports all combinations of EColor16Mxx and EColor64K, and when User Display Mode is ENone.
sl@0
  2350
    if ((iUserDispMode != EColor64K && iUserDispMode != EColor16M && 
sl@0
  2351
    	 iUserDispMode != EColor16MU && iUserDispMode != EColor16MA && 
sl@0
  2352
   	     iUserDispMode != EColor16MAP && iUserDispMode != ENone))
sl@0
  2353
    	{
sl@0
  2354
    	return (EFalse);
sl@0
  2355
    	}
sl@0
  2356
    if (!IsScalingOff() ||
sl@0
  2357
        !iOriginIsZero)
sl@0
  2358
        {
sl@0
  2359
		return(EFalse);
sl@0
  2360
        }
sl@0
  2361
	return((aDrawMode==CGraphicsContext::EDrawModePEN || (aDrawMode==CGraphicsContext::EDrawModeWriteAlpha && !IsAlphaChannel(aSrcDisplayMode))) &&
sl@0
  2362
		aShadowMode==CFbsDrawDevice::ENoShadow && aSrcLinePitch>0);
sl@0
  2363
	}
sl@0
  2364
sl@0
  2365
TBool CDrawBitmap::FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride)
sl@0
  2366
	{
sl@0
  2367
	return((aMaskDisplayMode==EGray2 || aMaskDisplayMode==EGray256) && aMaskStride>0);
sl@0
  2368
	}
sl@0
  2369
sl@0
  2370
/**
sl@0
  2371
CDrawBitmap::BlendBitmap() implementation.
sl@0
  2372
@internalTechnology
sl@0
  2373
*/
sl@0
  2374
TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
sl@0
  2375
	{
sl@0
  2376
	TInt srcPitch=aSrcDrawDevice->ScanLineBytes();
sl@0
  2377
	if (!FastBlendSupported(aSrcDrawDevice->DisplayMode(), aDrawMode, aShadowMode, srcPitch))
sl@0
  2378
		return(KErrNotSupported);
sl@0
  2379
	MScalingSettings* scalingSettings=NULL;
sl@0
  2380
	if (aSrcDrawDevice->GetInterface(KScalingSettingsInterfaceID, 
sl@0
  2381
							reinterpret_cast<TAny*&>(scalingSettings))==KErrNone)
sl@0
  2382
		{
sl@0
  2383
		if (!scalingSettings->IsScalingOff())
sl@0
  2384
			return(KErrNotSupported);
sl@0
  2385
		}
sl@0
  2386
	MDrawDeviceOrigin* originInterface = NULL;
sl@0
  2387
	if(aSrcDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID, 
sl@0
  2388
							reinterpret_cast <TAny*&> (originInterface)) == KErrNone)
sl@0
  2389
		{
sl@0
  2390
		TPoint origin;
sl@0
  2391
		originInterface->Get(origin);
sl@0
  2392
		if (origin.iX!=0 || origin.iY!=0)
sl@0
  2393
			return(KErrNotSupported);
sl@0
  2394
		}
sl@0
  2395
	MDrawDeviceOrientation* orientationInterface=NULL;
sl@0
  2396
	if(aSrcDrawDevice->GetInterface(KOrientationInterfaceID,
sl@0
  2397
							reinterpret_cast <TAny*&> (orientationInterface))!=KErrNone || (orientationInterface && orientationInterface->Orientation() != 0))
sl@0
  2398
		{
sl@0
  2399
		return KErrNotSupported;
sl@0
  2400
		}
sl@0
  2401
	TAny* interface=NULL;
sl@0
  2402
	TInt ret=aSrcDrawDevice->GetInterface(KFastBlit2InterfaceID, interface);
sl@0
  2403
	if (ret!=KErrNone)
sl@0
  2404
		return(ret);
sl@0
  2405
	MFastBlit2 *fb2=reinterpret_cast<MFastBlit2*>(interface);
sl@0
  2406
	const TUint8* srcBase = reinterpret_cast<const TUint8*>(fb2->Bits());
sl@0
  2407
	return(DoFastBlendBitmap(aDest, aSrcRect, srcBase, srcPitch, aSrcDrawDevice->DisplayMode(), aSrcDrawDevice->SizeInPixels()));
sl@0
  2408
	}
sl@0
  2409
sl@0
  2410
TInt CDrawBitmap::FastBlendBitmap(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
sl@0
  2411
	{
sl@0
  2412
	if (!FastBlendSupported(aDisplayMode, aDrawMode, aShadowMode, aSrcStride))
sl@0
  2413
		return(KErrNotSupported);
sl@0
  2414
	return(DoFastBlendBitmap(aDest, aSrcRect, reinterpret_cast<const TUint8*>(aSrcBase), aSrcStride, aDisplayMode, aSrcSize));
sl@0
  2415
	}
sl@0
  2416
sl@0
  2417
TInt CDrawBitmap::FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode, const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize, const TPoint &aMaskSrcPos, TBool aInvertMask, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode)
sl@0
  2418
	{
sl@0
  2419
	if (!FastBlendSupported(aSrcDisplayMode, aDrawMode, aShadowMode, aSrcStride) ||
sl@0
  2420
		!FastBlendMaskSupported(aMaskDisplayMode, aMaskStride))
sl@0
  2421
		return(KErrNotSupported);
sl@0
  2422
	TRect srcRect;
sl@0
  2423
	GetBlendPosAndRect(srcRect,aSrcRect,aSrcSize,TPoint(0,0));
sl@0
  2424
	const TInt KDestModeShift=8;
sl@0
  2425
	const TInt KMaskModeShift=16;
sl@0
  2426
	TInt dstStride=iScanLineWords*4;
sl@0
  2427
#define MASKED_MODE_SWITCH(src,dest,mask) case src|(dest<<KDestModeShift)|(mask<<KMaskModeShift)
sl@0
  2428
	TInt switchValue=aSrcDisplayMode|(iDispMode<<KDestModeShift);
sl@0
  2429
	switchValue|=aMaskDisplayMode<<KMaskModeShift;
sl@0
  2430
	const TUint8* srcBase=reinterpret_cast<const TUint8*>(aSrcBase);
sl@0
  2431
	TUint8 *dstBits=(TUint8*)iBits;
sl@0
  2432
	const TUint8 *maskBits=reinterpret_cast<const TUint8*>(aMaskBase);
sl@0
  2433
	if (iOrientation==EOrientationNormal)
sl@0
  2434
		{
sl@0
  2435
		switch (switchValue)
sl@0
  2436
			{
sl@0
  2437
// 16MA source
sl@0
  2438
			MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray2):
sl@0
  2439
				UnscaledFastBlitMaskedG2<TMaToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2440
				break;
sl@0
  2441
			MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray2):
sl@0
  2442
				UnscaledFastBlitMaskedG2<TMaToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2443
				break;
sl@0
  2444
			MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray2):
sl@0
  2445
				UnscaledFastBlitMaskedG2<TMaTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2446
				break;
sl@0
  2447
			MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
sl@0
  2448
				UnscaledFastBlitMaskedG256<TMaToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2449
				break;
sl@0
  2450
			MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
sl@0
  2451
				UnscaledFastBlitMaskedG256<TMaToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2452
				break;
sl@0
  2453
			MASKED_MODE_SWITCH(EColor16MA,EColor64K,EGray256):
sl@0
  2454
				UnscaledFastBlitMaskedG256<TMaTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2455
				break;
sl@0
  2456
// 16MU source
sl@0
  2457
			MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray2):
sl@0
  2458
				UnscaledFastBlitMaskedG2<TMuToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2459
				break;
sl@0
  2460
			MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray2):
sl@0
  2461
				UnscaledFastBlitMaskedG2<TMuToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2462
				break;
sl@0
  2463
			MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray2):
sl@0
  2464
				UnscaledFastBlitMaskedG2<TMuTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2465
				break;
sl@0
  2466
			MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray2):
sl@0
  2467
				UnscaledFastBlitMaskedG2<TMTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2468
				break;
sl@0
  2469
			MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
sl@0
  2470
				UnscaledFastBlitMaskedG256<TMuToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2471
				break;
sl@0
  2472
			MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
sl@0
  2473
				UnscaledFastBlitMaskedG256<TMuToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2474
				break;
sl@0
  2475
			MASKED_MODE_SWITCH(EColor16MU,EColor64K,EGray256):
sl@0
  2476
				UnscaledFastBlitMaskedG256<TMuTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2477
				break;
sl@0
  2478
			MASKED_MODE_SWITCH(EColor16M,EColor64K,EGray256):
sl@0
  2479
				UnscaledFastBlitMaskedG256<TMTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2480
				break;
sl@0
  2481
// 16MAP source
sl@0
  2482
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray2):
sl@0
  2483
				UnscaledFastBlitMaskedG2<TMapToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2484
				break;
sl@0
  2485
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray2):
sl@0
  2486
				UnscaledFastBlitMaskedG2<TMapToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2487
				break;
sl@0
  2488
			MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray2):
sl@0
  2489
				UnscaledFastBlitMaskedG2<TMapTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2490
				break;
sl@0
  2491
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
sl@0
  2492
				UnscaledFastBlitMaskedG256<TMapToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2493
				break;
sl@0
  2494
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
sl@0
  2495
				UnscaledFastBlitMaskedG256<TMapToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2496
				break;
sl@0
  2497
			MASKED_MODE_SWITCH(EColor16MAP,EColor64K,EGray256):
sl@0
  2498
				UnscaledFastBlitMaskedG256<TMapTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2499
				break;
sl@0
  2500
// 64K source
sl@0
  2501
			MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray2):
sl@0
  2502
				UnscaledFastBlitMaskedG2<T64KToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2503
				break;
sl@0
  2504
			MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray2):
sl@0
  2505
				UnscaledFastBlitMaskedG2<T64KToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2506
				break;
sl@0
  2507
			MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray2):
sl@0
  2508
				UnscaledFastBlitMaskedG2<T64KTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2509
				break;
sl@0
  2510
			MASKED_MODE_SWITCH(EColor64K,EColor16MU,EGray256):
sl@0
  2511
				UnscaledFastBlitMaskedG256<T64KToMu>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2512
				break;
sl@0
  2513
			MASKED_MODE_SWITCH(EColor64K,EColor16MAP,EGray256):
sl@0
  2514
				UnscaledFastBlitMaskedG256<T64KToMap>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2515
				break;
sl@0
  2516
			MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
sl@0
  2517
				UnscaledFastBlitMaskedG256<T64KTo64K>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2518
				break;
sl@0
  2519
#if defined(__SUPPORT_16MA_TARGET__)
sl@0
  2520
			MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray2):
sl@0
  2521
				UnscaledFastBlitMaskedG2<TMaToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2522
				break;
sl@0
  2523
			MASKED_MODE_SWITCH(EColor16MA,EColor16MA,EGray256):
sl@0
  2524
				UnscaledFastBlitMaskedG256<TMaToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2525
				break;
sl@0
  2526
			MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray2):
sl@0
  2527
				UnscaledFastBlitMaskedG2<TMuToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2528
				break;
sl@0
  2529
			MASKED_MODE_SWITCH(EColor16MU,EColor16MA,EGray256):
sl@0
  2530
				UnscaledFastBlitMaskedG256<TMuToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2531
				break;
sl@0
  2532
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray2):
sl@0
  2533
				UnscaledFastBlitMaskedG2<TMapToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2534
				break;
sl@0
  2535
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MA,EGray256):
sl@0
  2536
				UnscaledFastBlitMaskedG256<TMapToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2537
				break;
sl@0
  2538
			MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray2):
sl@0
  2539
				UnscaledFastBlitMaskedG2<T64KToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, aInvertMask, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2540
				break;
sl@0
  2541
			MASKED_MODE_SWITCH(EColor64K,EColor16MA,EGray256):
sl@0
  2542
				UnscaledFastBlitMaskedG256<T64KToMa>(srcBase, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, aMaskSrcPos, aMaskSize);
sl@0
  2543
				break;
sl@0
  2544
#endif
sl@0
  2545
			default:
sl@0
  2546
				return KErrNotSupported;
sl@0
  2547
			}
sl@0
  2548
		}
sl@0
  2549
	else
sl@0
  2550
		{
sl@0
  2551
		switch (switchValue)
sl@0
  2552
			{
sl@0
  2553
	// 16MA Source
sl@0
  2554
			MASKED_MODE_SWITCH(EColor16MA,EColor16MU,EGray256):
sl@0
  2555
				UnscaledFastBlitMaskedRotG256<TMaToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2556
				break;
sl@0
  2557
			MASKED_MODE_SWITCH(EColor16MA,EColor16MAP,EGray256):
sl@0
  2558
				UnscaledFastBlitMaskedRotG256<TMaToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2559
				break;
sl@0
  2560
	// 16MAP Source
sl@0
  2561
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MU,EGray256):
sl@0
  2562
				UnscaledFastBlitMaskedRotG256<TMapToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2563
				break;
sl@0
  2564
			MASKED_MODE_SWITCH(EColor16MAP,EColor16MAP,EGray256):
sl@0
  2565
				UnscaledFastBlitMaskedRotG256<TMapToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2566
				break;
sl@0
  2567
	// 16MU Source
sl@0
  2568
			MASKED_MODE_SWITCH(EColor16MU,EColor16MU,EGray256):
sl@0
  2569
				UnscaledFastBlitMaskedRotG256<TMuToMu>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2570
				break;
sl@0
  2571
			MASKED_MODE_SWITCH(EColor16MU,EColor16MAP,EGray256):
sl@0
  2572
				UnscaledFastBlitMaskedRotG256<TMuToMap>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2573
				break;
sl@0
  2574
	// 64K Source
sl@0
  2575
			MASKED_MODE_SWITCH(EColor64K,EColor64K,EGray256):
sl@0
  2576
				UnscaledFastBlitMaskedRotG256<T64KTo64K>(srcBase, iOrientation, aSrcStride, srcRect, maskBits, aMaskStride, dstBits, dstStride, aDest, iSize, aMaskSrcPos, aMaskSize);
sl@0
  2577
				break;
sl@0
  2578
			default:
sl@0
  2579
				return KErrNotSupported;
sl@0
  2580
			}
sl@0
  2581
		}
sl@0
  2582
	return KErrNone;
sl@0
  2583
	}