Update contrib.
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include "BitDrawScaling.h"
22 #include "BitDrawOrigin.h"
23 #include "BmAlphaBlend.h"
24 #include "BitDrawOrientation.h"
27 #define FORCEINLINE __forceinline
29 #define FORCEINLINE inline
33 Outline colour index used to get percentage of outline colour to be used to get
34 the final colour from lookup table
37 const TInt KOutlineColorIndex = 0;
40 Shadow colour index used to get percentage of shadow colour to be used to get
41 the final colour from lookup table
44 const TInt KShadowColorIndex = 1;
47 Fill colour index used to get percentage of fill colour to be used to get
48 the final colour from lookup table
51 const TInt KFillColorIndex = 2;
54 Background colour index used to get percentage of background colour to be used to get
55 the final colour from lookup table
58 const TInt KBackgroundColorIndex = 3;
61 Lookup table used for outline and shadow fonts.
64 GLREF_D const TInt FourColorBlendLookup[256][4];
66 TRgb AlphaBlend(TRgb aPrimary, TRgb aSecondary, TInt aAlphaValue);
68 //Scaling settings. MScalingSettings interface operates with them.
69 struct TScalingSettings
71 inline TScalingSettings() :
84 // Drawing device origin. MDrawDeviceOrigin interface operates with it.
85 typedef TPoint TOrigin;
87 //This class is used as a template argument by CDrawEightBppBitmapCommon::SetPixels()
88 //and CDrawSixteenBppBitmapCommon::SetPixels()
89 //Each of its methods (EvalInc() and EvalDec()) has two arguments -
90 //aAddr and aValue, and it is used to set *aAddr with aValue and to increment/decrement
92 template <class TPixelType> class TPixelSet
95 inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
99 inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
105 //This class is used as a template argument by CDrawEightBppBitmapCommon::XORPixels().
106 //and CDrawSixteenBppBitmapCommon::XORPixels()
107 //Each of its methods (EvalInc() and EvalDec()) has two arguments -
108 //aAddr and aValue, and it is used to XOR *aAddr with aValue and to increment/decrement
109 //respectively aAddr.
110 template <class TPixelType> class TPixelXor
113 inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
117 inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
123 //This class is used as a template argument by CDrawEightBppBitmapCommon::ANDPixels().
124 //and CDrawSixteenBppBitmapCommon::ANDPixels()
125 //Each of its methods (EvalInc() and EvalDec()) has two arguments -
126 //aAddr and aValue, and it is used to AND *aAddr with aValue and to increment/decrement
127 //respectively aAddr.
128 template <class TPixelType> class TPixelAnd
131 inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
135 inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
141 //This class is used as a template argument by CDrawEightBppBitmapCommon::ORPixels().
142 //and CDrawSixteenBppBitmapCommon::ORPixels()
143 //Each of its methods (EvalInc() and EvalDec()) has two arguments -
144 //aAddr and aValue, and it is used to OR *aAddr with aValue and to increment/decrement
145 //respectively aAddr.
146 template <class TPixelType> class TPixelOr
149 inline void EvalInc(TPixelType*& aAddr, TPixelType aValue) const
153 inline void EvalDec(TPixelType*& aAddr, TPixelType aValue) const
159 //This template function should be used every time when a rectangle has to be drawn instead of
160 //a single pixel in EColor256/EColor64K scaled device.
161 //aPixelPtr - points to the pixel memory address, which contains top-left corner of the rectangle.
162 //aValue - the pixel value - EColor256.
163 //aPixelPtrRowLimit - the right end address of the scalline.
164 //aBitsStart - beginning address of the pixel memory.
165 //aBitsEnd - end address of the pixel memory.
166 //aLongWidth - aligned scanline width in pixels.
167 //aFx - X-axis scaling factor.
168 //aFy - Y-axis scaling factor.
169 //aOrientation - device's orientation.
170 //aOp - the operation, which must be applied to every pixel from the rectangle - template parameter.
171 template <class TPixelOp, class TPixelType>
172 inline void FillScaledRect(TPixelType* aPixelPtr,
173 const TPixelType aValue,
174 const TPixelType* aPixelPtrRowLimit,
175 const TPixelType* aBitsStart,
176 const TPixelType* aBitsEnd,
177 const TInt aLongWidth,
180 const CFbsDrawDevice::TOrientation aOrientation,
183 if(aOrientation == CFbsDrawDevice::EOrientationNormal)
185 //for example: if aFx = 3 and aFy = 2 then
186 //the following pixel values have to be evaluated:
187 // (aPixelPtr), (aPixelPtr + 1), (aPixelPtr + 2)
188 // (aPixelPtr + aLongWidth), (aPixelPtr + 1 + aLongWidth), (aPixelPtr + 2 + aLongWidth)
189 const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value
190 if(nextStop > aPixelPtrRowLimit)
191 {//If the address is after the end of the current row, set it to the end of row.
192 nextStop = aPixelPtrRowLimit;
194 do //Fill pixel rectangle [aFx,aFy]
196 while(aPixelPtr < nextStop)
197 {//Fill a row of up to aFx pixels.
198 aOp.EvalInc(aPixelPtr, aValue);
200 aPixelPtr += (aLongWidth - aFx);//Move aPixelPtr to the next row
201 if(aPixelPtr >= aBitsEnd)
202 {//If aPixelPtr points after the end of video memory - stop the operation!
205 nextStop += aLongWidth;//Move nextPixelAddr to the next row
210 if(aOrientation == CFbsDrawDevice::EOrientationRotated90)
212 //for example: if aFy = 3 and aFx = 2 then
213 //the following pixel values have to be evaluated:
214 // (aPixelPtr), (aPixelPtr - 1),
215 // (aPixelPtr + aLongWidth), (aPixelPtr - 1 + aLongWidth),
216 // (aPixelPtr + 2 * aLongWidth), (aPixelPtr - 1 + 2 * aLongWidth),
217 const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth;
218 const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value
219 if(nextStop < pixelPtrPrevRowLimit)
220 {//If the address is before the beginning of the current row, set it to the beginning of row.
221 nextStop = pixelPtrPrevRowLimit;
223 do //Fill pixel rectangle [aFx,aFy]
225 while(aPixelPtr > nextStop)
226 {//Fill a row of up to aFy pixels.
227 aOp.EvalDec(aPixelPtr, aValue);
229 aPixelPtr += (aLongWidth + aFx);//Move aPixelPtr to the next row
230 if(aPixelPtr >= aBitsEnd)
231 {//If aPixelPtr points after the end of video memory - stop the operation!
234 nextStop += aLongWidth;//Move nextPixelAddr to the next row
239 if(aOrientation == CFbsDrawDevice::EOrientationRotated180)
241 //for example: if aFx = 3 and aFy = 2 then
242 //the following pixel values have to be evaluated:
243 // (aPixelPtr), (aPixelPtr - 1), (aPixelPtr - 2)
244 // (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth), (aPixelPtr + 2 - aLongWidth)
245 const TPixelType* pixelPtrPrevRowLimit = aPixelPtrRowLimit - aLongWidth;
246 const TPixelType* nextStop = aPixelPtr - aFx;//the address of next scaled pixel value
247 if(nextStop < pixelPtrPrevRowLimit)
248 {//If the address is before the beginning of the current row, set it to the beginning of row.
249 nextStop = pixelPtrPrevRowLimit;
251 do //Fill pixel rectangle [aFx,aFy]
253 while(aPixelPtr > nextStop)
254 {//Fill a row of up to aFx pixels.
255 aOp.EvalDec(aPixelPtr, aValue);
257 aPixelPtr -= (aLongWidth - aFx);//Move aPixelPtr to the prev row
258 if(aPixelPtr < aBitsStart)
259 {//If aPixelPtr points before the beginning of video memory - stop the operation!
262 nextStop -= aLongWidth;//Move nextPixelAddr to the prev row
267 else //if(aOrientation == CFbsDrawDevice::EOrientationRotated270)
269 //for example: if aFy = 3 and aFx = 2 then
270 //the following pixel values have to be evaluated:
271 // (aPixelPtr), (aPixelPtr + 1)
272 // (aPixelPtr - aLongWidth), (aPixelPtr + 1 - aLongWidth)
273 // (aPixelPtr - 2 * aLongWidth), (aPixelPtr + 1 - 2 * aLongWidth)
274 const TPixelType* nextStop = aPixelPtr + aFx;//the address of next scaled pixel value
275 if(nextStop > aPixelPtrRowLimit)
276 {//If the address is after the end of the current row, set it to the end of row.
277 nextStop = aPixelPtrRowLimit;
279 do //Fill pixel rectangle [aFx,aFy]
281 while(aPixelPtr < nextStop)
282 {//Fill a row of up to aFy pixels.
283 aOp.EvalInc(aPixelPtr, aValue);
285 aPixelPtr += (-aLongWidth - aFx);//Move aPixelPtr to the prev row
286 if(aPixelPtr < aBitsStart)
287 {//If aPixelPtr points befor the beginning of video memory - stop the operation!
290 nextStop -= aLongWidth;//Move nextPixelAddr to the prev row
300 NONSHARABLE_CLASS(CDrawBitmap) : public CFbsDrawDevice,
301 public MScalingSettings,
302 public MDrawDeviceOrigin,
304 public MOutlineAndShadowBlend,
305 public MDrawDeviceOrientation,
309 virtual ~CDrawBitmap();
310 // From CFbsDrawDevice
311 virtual TDisplayMode DisplayMode() const { return iDispMode; }
312 virtual TInt LongWidth() const;
313 virtual void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards);
314 virtual TRgb ReadPixel(TInt aX,TInt aY) const;
315 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer,TDisplayMode aDispMode) const;
316 virtual TUint32* ScanLineBuffer() const;
317 virtual TInt ScanLineBytes() const;
318 virtual TDisplayMode ScanLineDisplayMode() const { return iDispMode; }
319 virtual TSize SizeInPixels() const;
320 virtual TInt HorzTwipsPerThousandPixels() const { return 0; }
321 virtual TInt VertTwipsPerThousandPixels() const { return 0; }
322 virtual void OrientationsAvailable(TBool aOrientation[4]);
323 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
324 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
325 virtual void WriteBinaryLine(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
326 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode,TBool aUp);
327 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer ,CGraphicsContext::TDrawMode);
328 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor,CGraphicsContext::TDrawMode);
329 virtual void SetBits(TAny* aBits);
330 virtual void SetDitherOrigin(const TPoint& aPoint);
331 virtual void SetShadowMode(TShadowMode aShadowMode) { iShadowMode = aShadowMode; }
332 virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);
333 virtual void SetUserDisplayMode(TDisplayMode aDisplayMode) { iUserDispMode = aDisplayMode; }
334 virtual TBool SetOrientation(TOrientation aOrientation);
335 virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength,
336 TUint8* aRgbBuffer, TUint8* aMaskBuffer,
337 CGraphicsContext::TDrawMode aDrawMode);
338 virtual void WriteRgbAlphaLine(TInt aX,TInt aY,TInt aLength,
339 const TUint8* aRgbBuffer1,
340 const TUint8* aBuffer2,
341 const TUint8* aMaskBuffer,
342 CGraphicsContext::TDrawMode aDrawMode);
343 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
344 virtual void GetDrawRect(TRect& aDrawRect) const;
345 virtual void SwapWidthAndHeight();
346 // From MScalingSettings
347 virtual TInt Set(TInt aFactorX, TInt aFactorY, TInt aDivisorX, TInt aDivisorY);
348 virtual void Get(TInt& aFactorX, TInt& aFactorY, TInt& aDivisorX, TInt& aDivisorY);
349 virtual TBool IsScalingOff();
350 // From MDrawDeviceOrigin
351 virtual TInt Set(const TPoint& aOrigin);
352 virtual void Get(TPoint& aOrigin);
353 // From MDrawDeviceOrientation
354 virtual CFbsDrawDevice::TOrientation Orientation();
356 virtual TInt FastBlendBitmap(const TPoint& aDest,CFbsDrawDevice* aSrcDrawDevice, const TRect& aSrcRect, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
357 virtual TInt FastBlendBitmap(const TPoint& aDest,const TUint32* aSrcBase, TInt aSrcStride, const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
358 virtual TInt FastBlendBitmapMasked(const TPoint& aDest, const TUint32* aSrcBase, TInt aSrcStride,
359 const TSize& aSrcSize, const TRect& aSrcRect, TDisplayMode aSrcDisplayMode,
360 const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,const TPoint &aMaskSrcPos,TBool aInvertMask,
361 CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
362 virtual TInt 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);
363 virtual TInt FastBlendBitmapMaskedScaled(const TRect &aClipRect, const TRect& aDest,
364 const TRect& aSrcRect, const TUint32 *aSrcBase, TInt aSrcLinePitch,
365 TDisplayMode aSrcDisplayMode, const TSize &aSrcSize,
366 const TUint32* aMaskBase, TInt aMaskStride, TDisplayMode aMaskDisplayMode, const TSize &aMaskSize,TBool aInvertMask,
367 CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode);
370 static TInt BitsPerPixel(TDisplayMode aDispMode);
372 void CopyOldSettings(CFbsDrawDevice* aDrawDevice);
373 void DeOrientate(TInt& aX,TInt& aY) const;
374 TPoint DeOrientate(const TPoint& aPoint) const;
375 TRect DeOrientate(const TRect& aRect) const;
376 virtual void Shadow(TRgb& aColor) = 0;
377 TRgb FadeRgb(TRgb aColor);
378 TUint32 FadeRgb(TUint32 aColor);
379 void FadeRgb(TInt& aRed, TInt& aGreen, TInt& aBlue);
380 TUint8 FadeGray(TInt aGray256);
381 TUint32 Hash(TUint32 aValue,TInt aX,TInt aY) const;
382 TUint32 PasteInt(TUint32 aFirst,TUint32 aSecond,TInt aOffset) const;
383 static TAny* CopyOffset(TAny* aDestination,const TAny* aSource,TInt aWordsToCopy,TInt aSourceBitOffset);
384 static void ReadLineCommon(TUint32* aPixelPtr,TUint32* aBufferPtr,TInt aWordsCnt,TInt aRestPixels,TInt aBytesCnt,TInt aStartDiffBits);
385 virtual void SetSize(const TSize& aSize);
387 TBool CanBeScaled() const;
388 TInt PixelAddressIncrement() const;
389 TInt LogicalPixelAddressIncrement() const;
390 void SetPixelInc(TInt& aPixelInc, TInt& aRowInc) const;
391 void IncScaledY(TInt& aY) const;
392 void IncScaledY(TInt& aY, TInt aYOrg) const;
393 //Generic set pixels operations, has to be defined here to make it compiled in VC++6.0
394 template <class TPixelType>
395 void SetPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
396 const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
398 TPixelSet<TPixelType> op;
399 ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
400 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
402 template <class TPixelType>
403 void XORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
404 const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
406 TPixelXor<TPixelType> op;
407 ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
408 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
410 template <class TPixelType>
411 void ANDPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
412 const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
414 TPixelAnd<TPixelType> op;
415 ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
416 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
418 template <class TPixelType>
419 void ORPixels(TPixelType* aPixelPtr, TPixelType aValue, const TPixelType* aPixelPtrRowLimit,
420 const TPixelType* aBitsStart, const TPixelType* aBitsEnd) const
422 TPixelOr<TPixelType> op;
423 ::FillScaledRect(aPixelPtr, aValue, aPixelPtrRowLimit, aBitsStart, aBitsEnd, iLongWidth,
424 iScalingSettings.iFactorX, iScalingSettings.iFactorY, iOrientation, op);
427 TBool CanOriginBeMoved() const;
428 void MapColorToUserDisplayMode(TInt& red,TInt& green,TInt& blue);
430 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer) = 0;
431 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const = 0;
432 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const = 0;
433 virtual TUint32* ScanLine(TInt aY) const;
434 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
435 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
436 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
437 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
438 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
439 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
440 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor) = 0;
441 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor) = 0;
442 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode) = 0;
443 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp) = 0;
444 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor) = 0;
445 virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
446 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer) = 0;
447 virtual void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
448 virtual void MapColorToUserDisplayMode(TRgb& /*aColor*/) {}
449 virtual void MapBufferToUserDisplayMode(TInt /*aLength*/,TUint32* /*aBuffer*/) {}
451 void GetBlendPosAndRect(TRect &aSrcRect, const TRect &aSrcRectIn, const TSize &aSrcSize, const TPoint &aDestOffset);
452 void GetBlendPosAndRect(TRect &aDstRect, TRect &aSrcRect, const TRect &aDestRectIn, const TRect &aSrcRectIn, const TSize &aSrcSize);
453 TBool FastBlendSupported(TDisplayMode aSrcDisplayMode, CGraphicsContext::TDrawMode aDrawMode, TInt aShadowMode, TInt aSrcLinePitch);
454 TBool FastBlendMaskSupported(TDisplayMode aMaskDisplayMode, TInt aMaskStride);
455 void DoCopyOldSettings(CFbsDrawDevice* aDrawDevice);
456 TInt DoFastBlendBitmap(const TPoint &aDest, const TRect& aSrcRect, const TUint8 *aSrcBase, TInt aSrcLinePitch, TDisplayMode aSrcDisplayMode, const TSize &aSrcSize);
458 void InitLogicalCoordinates();
459 void PreWriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, CGraphicsContext::TDrawMode aDrawMode);
460 void WriteRgb(TInt& aWidth, TInt& aHeight, TInt& aX, TInt& aY, TRgb aColor, CGraphicsContext::TDrawMode aDrawMode);
462 inline TInt Origin(TInt aPhysOrg, TInt aScale) const;
463 inline TInt OtherSide(TInt aPhysOrg, TInt aPhysSize, TInt aScale) const;
465 TDisplayMode iDispMode;
466 TInt iLongWidth; // aligned scanline width in pixels
467 TPoint iDitherOrigin;
468 TUint32* iScanLineBuffer;
470 TShadowMode iShadowMode;
471 TSize iSize; // (0, 0, iSize.iWidth, iSize.iHeight) - drawing rectangle - physical coordinates
473 TDisplayMode iUserDispMode;
474 TOrientation iOrientation; // 0, 90, 180, 270 degrees
477 TScalingSettings iScalingSettings; // X-axis and Y-axis scaling factors
478 TOrigin iOrigin; // drawing device origin
479 TBool iScalingOff; // ETrue, if the scaling is off.
480 TBool iOriginIsZero; // ETrue, if the origin is (0, 0).
481 TRect iDrawRect; // drawing rectangle - logical coordinates
482 MAlphaBlend* iAlphaBlend; // Alphablending interface
488 NONSHARABLE_CLASS(CDrawOneBppBitmap) : public CDrawBitmap
491 TInt Construct(TSize aSize);
492 TInt Construct(TSize aSize, TInt aStride);
493 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
494 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
495 virtual void ShadowArea(const TRect& aRect);
496 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
497 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
498 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
499 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
500 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
501 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
502 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
503 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
504 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
505 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
506 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
507 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
508 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
510 virtual void SetSize(const TSize& aSize);
511 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
512 virtual void Shadow(TRgb& aColor);
513 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
515 TUint32 ColorWord(TRgb aColor) const;
516 virtual void WriteRgbAlphaLine(TInt aX,
519 const TUint8* aRgbBuffer,
520 const TUint8* aMaskBuffer,
521 MAlphaBlend::TShadowing aShadowing,
522 CGraphicsContext::TDrawMode aDrawMode);
523 // From MOutlineAndShadowBlend
524 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
525 TUint32 aOutlinePenColor, TUint32 aShadowColor,
526 TUint32 aFillColor, const TUint8* aDataBuffer);
532 NONSHARABLE_CLASS(CDrawTwoBppBitmap) : public CDrawBitmap
535 TInt Construct(TSize aSize);
536 TInt Construct(TSize aSize, TInt aStride);
537 TUint32 ColorInt(TRgb aColor) const;
538 void HashInt(TUint32& aInt1,TUint32& aInt2,TRgb aColor,TInt aX,TInt aY) const;
539 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
540 void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards);
541 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
542 virtual void ShadowArea(const TRect& aRect);
543 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
544 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
545 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
546 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
547 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
548 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
549 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
550 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
551 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
552 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
553 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
554 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
555 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
556 virtual void MapColorToUserDisplayMode(TRgb& aColor);
557 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
559 virtual void SetSize(const TSize& aSize);
560 TUint32 MapInt(TUint32 aInt,TUint32* aColorMap) const;
561 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
562 virtual void Shadow(TRgb& aColor);
563 TUint32 ShadowWord(TUint32 aWord);
564 TUint32 FadeWord(TUint32 aWord);
565 void ShadeBuffer(TInt aLength,TUint32* aBuffer);
566 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
568 virtual void WriteRgbAlphaLine(TInt aX,
571 const TUint8* aRgbBuffer,
572 const TUint8* aMaskBuffer,
573 MAlphaBlend::TShadowing aShadowing,
574 CGraphicsContext::TDrawMode aDrawMode);
575 // From MOutlineAndShadowBlend
576 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
577 TUint32 aOutlinePenColor, TUint32 aShadowColor,
578 TUint32 aFillColor, const TUint8* aDataBuffer);
584 NONSHARABLE_CLASS(CDrawFourBppBitmapGray) : public CDrawBitmap
587 TInt Construct(TSize aSize);
588 TInt Construct(TSize aSize, TInt aStride);
589 TUint32 ColorInt(TRgb aColor) const;
590 TUint32 HashInt(TRgb aColor,TInt aX,TInt aY) const;
591 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
592 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
593 virtual void ShadowArea(const TRect& aRect);
594 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
595 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
596 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
597 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
598 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
599 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
600 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
601 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
602 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
603 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
604 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
605 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
606 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
607 virtual void MapColorToUserDisplayMode(TRgb& aColor);
608 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
610 virtual void SetSize(const TSize& aSize);
611 void DitherBuffer(TInt x,TInt y,TInt aLength,TUint32* aBuffer);
612 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
613 virtual void Shadow(TRgb& aColor);
614 TUint8 ShadowAndFadeGray16(TInt aGray16);
615 TUint32 FadeWord(TUint32 aWord);
616 void ShadeBuffer(TInt aLength,TUint32* aBuffer);
617 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
619 virtual void WriteRgbAlphaLine(TInt aX,
622 const TUint8* aRgbBuffer,
623 const TUint8* aMaskBuffer,
624 MAlphaBlend::TShadowing aShadowing,
625 CGraphicsContext::TDrawMode aDrawMode);
626 // From MOutlineAndShadowBlend
627 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
628 TUint32 aOutlinePenColor, TUint32 aShadowColor,
629 TUint32 aFillColor, const TUint8* aDataBuffer);
630 TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor,
631 TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor,
632 TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor,
633 TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor,
634 TRgb aBackgroundColor, TUint8 aIndex) const;
640 NONSHARABLE_CLASS(CDrawFourBppBitmapColor) : public CDrawBitmap
643 TInt Construct(TSize aSize);
644 TInt Construct(TSize aSize, TInt aStride);
645 TUint32 ColorInt(TRgb aColor) const;
646 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
647 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
648 virtual void ShadowArea(const TRect& aRect);
649 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
650 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
651 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
652 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
653 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
654 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
655 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
656 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
657 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
658 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
659 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
660 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
661 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
662 virtual void MapColorToUserDisplayMode(TRgb& aColor);
663 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
665 virtual void SetSize(const TSize& aSize);
666 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
667 virtual void Shadow(TRgb& aColor);
668 TUint32 ShadowWord(TUint32 aWord);
669 TUint32 FadeWord(TUint32 aWord);
670 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
672 virtual void WriteRgbAlphaLine(TInt aX,
675 const TUint8* aRgbBuffer,
676 const TUint8* aMaskBuffer,
677 MAlphaBlend::TShadowing aShadowing,
678 CGraphicsContext::TDrawMode aDrawMode);
679 // From MOutlineAndShadowBlend
680 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
681 TUint32 aOutlinePenColor, TUint32 aShadowColor,
682 TUint32 aFillColor, const TUint8* aDataBuffer);
683 TRgb BlendFourColors(TUint32 aOutlinePenColor, TUint32 aShadowColor, TUint32 aFillColor,
684 TInt aRedOutlinePenColor,TInt aRedShadowColor,TInt aRedFillColor,
685 TInt aGreenOutlinePenColor, TInt aGreenShadowColor, TInt aGreenFillColor,
686 TInt aBlueOutlinePenColor, TInt aBlueShadowColor, TInt aBlueFillColor,
687 TRgb aBackgroundColor, TUint8 aIndex) const;
690 const TInt KInvalidValue = 0xABCDABCD;
695 NONSHARABLE_CLASS(CDrawEightBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
698 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
699 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
700 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
701 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
702 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
703 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
705 virtual TInt WriteBitmapBlock(const TPoint& aDest,
706 CFbsDrawDevice* aSrcDrawDevice,
707 const TRect& aSrcRect);
708 virtual TInt WriteBitmapBlock(const TPoint& aDest,
709 const TUint32* aSrcBase,
711 const TSize& aSrcSize,
712 const TRect& aSrcRect);
713 virtual const TUint32* Bits() const;
715 virtual void SetSize(const TSize& aSize);
716 TInt Construct(TSize aSize, TInt aStride);
717 TUint8* PixelAddress(TInt aX,TInt aY) const;
718 void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
719 void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel);
720 void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint8 aPixel,CGraphicsContext::TDrawMode aDrawMode);
721 void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint8 aPixel,TBool aUp);
722 void WriteRgb(TInt aX,TInt aY,TUint8 aPixel);
723 void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
724 void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
725 void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
726 void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint8 aPixel);
732 NONSHARABLE_CLASS(CDrawEightBppBitmapGray) : public CDrawEightBppBitmapCommon
735 TInt Construct(TSize aSize);
736 TInt Construct(TSize aSize, TInt aStride);
737 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
738 virtual void ShadowArea(const TRect& aRect);
739 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
740 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
741 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
742 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
743 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
744 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
745 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
746 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
747 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
748 virtual void MapColorToUserDisplayMode(TRgb& aColor);
749 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
751 virtual void Shadow(TRgb& aColor);
752 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
753 TUint8 ShadowAndFade(TInt aGray256);
755 virtual void WriteRgbAlphaLine(TInt aX,
758 const TUint8* aRgbBuffer,
759 const TUint8* aMaskBuffer,
760 MAlphaBlend::TShadowing aShadowing,
761 CGraphicsContext::TDrawMode aDrawMode);
762 // From MOutlineAndShadowBlend
763 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
764 TUint32 aOutlinePenColor, TUint32 aShadowColor,
765 TUint32 aFillColor, const TUint8* aDataBuffer);
771 NONSHARABLE_CLASS(CDrawEightBppBitmapColor) : public CDrawEightBppBitmapCommon
774 ~CDrawEightBppBitmapColor();
775 TInt Construct(TSize aSize);
776 TInt Construct(TSize aSize, TInt aStride);
777 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
778 virtual TInt SetCustomPalette(const CPalette* aPalette);
779 virtual TInt GetCustomPalette(CPalette*& aPalette);
780 virtual void ShadowArea(const TRect& aRect);
781 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
782 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
783 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
784 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
785 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
786 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
787 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
788 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
789 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
790 virtual void MapColorToUserDisplayMode(TRgb& aColor);
791 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
792 // From MOutlineAndShadowBlend
793 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
794 TUint32 aOutlinePenColor, TUint32 aShadowColor,
795 TUint32 aFillColor, const TUint8* aDataBuffer);
797 TUint8 ColorToIndex(TRgb aColor) const;
798 TRgb IndexToColor(TInt aIndex) const;
799 virtual void Shadow(TRgb& aColor);
800 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
802 virtual void WriteRgbAlphaLine(TInt aX,
805 const TUint8* aRgbBuffer,
806 const TUint8* aMaskBuffer,
807 MAlphaBlend::TShadowing aShadowing,
808 CGraphicsContext::TDrawMode aDrawMode);
811 TUint8* iColor4KIndex;
812 TUint8* iShadowIndex;
818 NONSHARABLE_CLASS(CDrawSixteenBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
821 TInt Construct(TSize aSize, TInt aStride);
822 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
823 virtual void ShadowArea(const TRect& aRect);
824 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
825 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
826 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
827 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
828 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
829 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
830 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor);
831 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TUint16 aColor,CGraphicsContext::TDrawMode aDrawMode);
832 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TUint16 aColor,TBool aUp);
833 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TUint16 aColor);
834 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
835 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
837 virtual TInt WriteBitmapBlock(const TPoint& aDest,
838 CFbsDrawDevice* aSrcDrawDevice,
839 const TRect& aSrcRect);
840 virtual TInt WriteBitmapBlock(const TPoint& aDest,
841 const TUint32* aSrcBase,
843 const TSize& aSrcSize,
844 const TRect& aSrcRect);
845 virtual const TUint32* Bits() const;
847 virtual void SetSize(const TSize& aSize);
848 TUint16* PixelAddress(TInt aX,TInt aY) const;
849 virtual void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
850 virtual TUint16 ShadowIndex(TUint16 aColor64KIndex) = 0;
851 virtual TUint16 FadeIndex(TUint16 aColor4KIndex) = 0;
852 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
858 NONSHARABLE_CLASS(CDrawTwelveBppBitmap) : public CDrawSixteenBppBitmapCommon
861 TInt Construct(TSize aSize);
862 TInt Construct(TSize aSize, TInt aStride);
863 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
864 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
865 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
866 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
867 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
868 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
869 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
870 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
871 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
872 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
873 virtual void MapColorToUserDisplayMode(TRgb& aColor);
874 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
875 // From MOutlineAndShadowBlend
876 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
877 TUint32 aOutlinePenColor, TUint32 aShadowColor,
878 TUint32 aFillColor, const TUint8* aDataBuffer);
880 virtual void Shadow(TRgb& aColor);
881 virtual TUint16 ShadowIndex(TUint16 aColor4KIndex);
882 virtual TUint16 FadeIndex(TUint16 aColor4KIndex);
884 virtual void WriteRgbAlphaLine(TInt aX,
887 const TUint8* aRgbBuffer,
888 const TUint8* aMaskBuffer,
889 MAlphaBlend::TShadowing aShadowing,
890 CGraphicsContext::TDrawMode aDrawMode);
896 NONSHARABLE_CLASS(CDrawSixteenBppBitmap) : public CDrawSixteenBppBitmapCommon
899 TInt Construct(TSize aSize);
900 TInt Construct(TSize aSize, TInt aStride);
901 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
902 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
903 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
904 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
905 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
906 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
907 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
908 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
909 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
910 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
911 virtual void MapColorToUserDisplayMode(TRgb& aColor);
912 FORCEINLINE void MapColorToUserDisplayMode(TUint16& aColor64K);
913 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
914 virtual void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
915 // From MOutlineAndShadowBlend
916 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
917 TUint32 aOutlinePenColor, TUint32 aShadowColor,
918 TUint32 aFillColor, const TUint8* aDataBuffer);
920 virtual void Shadow(TRgb& aColor);
921 FORCEINLINE void Shadow(TInt& aRed, TInt& aGreen, TInt& aBlue);
922 FORCEINLINE void Shadow(TUint16& a64KColor);
923 virtual TUint16 ShadowIndex(TUint16 aColor64KIndex);
924 FORCEINLINE void ShadowIndex(TInt& aRed, TInt& aGreen, TInt& aBlue);
925 virtual TUint16 FadeIndex(TUint16 aColor64KIndex);
927 virtual void WriteRgbAlphaLine(TInt aX,
930 const TUint8* aRgbBuffer,
931 const TUint8* aMaskBuffer,
932 MAlphaBlend::TShadowing aShadowing,
933 CGraphicsContext::TDrawMode aDrawMode);
939 NONSHARABLE_CLASS(CDrawTwentyFourBppBitmap) : public CDrawBitmap
942 TInt Construct(TSize aSize);
943 TInt Construct(TSize aSize, TInt aStride);
944 virtual void Shadow(TRgb& aColor);
945 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
946 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
947 virtual void ShadowArea(const TRect& aRect);
948 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
949 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
950 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
951 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
952 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
953 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
954 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
955 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
956 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
957 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
958 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
959 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
960 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
961 virtual void MapColorToUserDisplayMode(TRgb& aColor);
962 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
963 // From MOutlineAndShadowBlend
964 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
965 TUint32 aOutlinePenColor, TUint32 aShadowColor,
966 TUint32 aFillColor, const TUint8* aDataBuffer);
967 void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
969 virtual void SetSize(const TSize& aSize);
970 TUint8* PixelAddress(TInt aX,TInt aY) const;
971 TInt PixelAddressIncrement() const;
972 void PixelAddressIncrement(TInt& aPixelInc,TInt& aRowInc) const;
973 void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
974 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
975 TUint8 ShadowComponent(TInt aRgbComponent);
976 TUint8 FadeComponent(TInt aRgbComponent);
977 TUint8 ShadowAndFade(TInt aComponent);
979 FORCEINLINE void FadeRgb(TInt& red,TInt& green,TInt& blue);
980 FORCEINLINE void Shadow(TInt& red,TInt& green,TInt& blue);
981 FORCEINLINE TUint8 ShadowComponentInl(TInt aRgbComponent);
982 virtual void WriteRgbAlphaLine(TInt aX,
985 const TUint8* aRgbBuffer,
986 const TUint8* aMaskBuffer,
987 MAlphaBlend::TShadowing aShadowing,
988 CGraphicsContext::TDrawMode aDrawMode);
993 inline TUint8* CDrawTwentyFourBppBitmap::PixelAddress(TInt aX,TInt aY) const
995 return ((TUint8*)iBits) + (aY * iScanLineBytes) + (aX * 3);
1001 NONSHARABLE_CLASS(CDrawThirtyTwoBppBitmapCommon) : public CDrawBitmap, public MFastBlit2
1004 TInt Construct(TSize aSize, TInt aStride);
1005 virtual void Shadow(TRgb& aColor);
1006 virtual void Shadow(TUint32& aColor);
1007 virtual void InvertBuffer(TInt aLength,TUint32* aBuffer);
1008 virtual TRgb ReadRgbNormal(TInt aX,TInt aY) const;
1009 virtual void ShadowArea(const TRect& aRect);
1010 virtual void WriteRgb(TInt aX,TInt aY,TRgb aColor);
1011 virtual void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
1012 virtual void WriteBinaryOp(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode);
1013 virtual void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
1014 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1015 virtual void WriteLineXOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1016 virtual void WriteLineAND(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1017 virtual void WriteLineOR(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1018 virtual void WriteRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
1019 virtual void WriteRgbMultiXOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
1020 virtual void WriteRgbMultiAND(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
1021 virtual void WriteRgbMultiOR(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
1022 virtual void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
1023 virtual void MapColorToUserDisplayMode(TRgb& aColor);
1024 virtual void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
1025 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
1027 virtual TInt WriteBitmapBlock(const TPoint& aDest,
1028 CFbsDrawDevice* aSrcDrawDevice,
1029 const TRect& aSrcRect);
1030 virtual TInt WriteBitmapBlock(const TPoint& aDest,
1031 const TUint32* aSrcBase,
1033 const TSize& aSrcSize,
1034 const TRect& aSrcRect);
1035 virtual const TUint32* Bits() const;
1037 virtual TUint32 Color(const TRgb& aColor) = 0;
1038 virtual TRgb RgbColor(TUint32 aColor) const = 0;
1039 virtual void SetSize(const TSize& aSize);
1040 FORCEINLINE TUint32* PixelAddress(TInt aX,TInt aY) const;
1041 FORCEINLINE TInt PixelAddressIncrement() const;
1042 void ReadLine(TInt aX,TInt aY,TInt aLength,TAny* aBuffer) const;
1043 void ShadowBuffer(TInt aLength,TUint32* aBuffer);
1044 FORCEINLINE TUint8 ShadowComponent(TInt aRgbComponent);
1045 TUint8 FadeComponent(TInt aRgbComponent);
1046 TUint8 ShadowAndFade(TInt aComponent);
1048 virtual void WriteRgbAlphaLine(TInt aX,
1051 const TUint8* aRgbBuffer,
1052 const TUint8* aMaskBuffer,
1053 MAlphaBlend::TShadowing aShadowing,
1054 CGraphicsContext::TDrawMode aDrawMode);
1057 FORCEINLINE TUint32* CDrawThirtyTwoBppBitmapCommon::PixelAddress(TInt aX,TInt aY) const
1059 return iBits + aY * iScanLineWords + aX;
1062 FORCEINLINE TInt CDrawThirtyTwoBppBitmapCommon::PixelAddressIncrement() const
1064 switch (iOrientation)
1066 case EOrientationNormal:
1068 case EOrientationRotated90:
1069 return iScanLineWords;
1070 case EOrientationRotated180:
1072 case EOrientationRotated270:
1073 return -iScanLineWords;
1083 NONSHARABLE_CLASS(CDrawUTwentyFourBppBitmap) : public CDrawThirtyTwoBppBitmapCommon, MFastBlit
1086 TInt Construct(TSize aSize);
1087 TInt Construct(TSize aSize, TInt aStride);
1088 virtual TDisplayMode ScanLineDisplayMode() const { return EColor16MAP; }
1089 virtual void ReadLine(TInt aX, TInt aY, TInt aLength, TAny* aBuffer, TDisplayMode aDispMode) const;
1090 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
1092 virtual void WriteAlphaLineEx(TInt aX,
1096 const TUint32* aSrcPtr,
1097 TDisplayMode aSrcFormat,
1099 const TUint32* aMaskPtr,
1100 MAlphaBlend::TShadowing aShadowing);
1101 virtual void WriteMaskLineEx(TInt aX,
1105 const TUint32* aSrcPtr,
1106 TDisplayMode aSrcFormat,
1108 const TUint32* aMaskPtr,
1110 void BlendRgbMulti(TInt aX,TInt aY,TInt aLength,TInt aHeight,TRgb aColor);
1111 void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1112 // From MOutlineAndShadowBlend
1113 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
1114 TUint32 aOutlinePenColor, TUint32 aShadowColor,
1115 TUint32 aFillColor, const TUint8* aDataBuffer);
1117 virtual TUint32 Color(const TRgb& aColor);
1118 virtual TRgb RgbColor(TUint32 aColor) const;
1120 virtual void WriteRgbAlphaLine(TInt aX,
1123 const TUint8* aRgbBuffer,
1124 const TUint8* aMaskBuffer,
1125 MAlphaBlend::TShadowing aShadowing,
1126 CGraphicsContext::TDrawMode aDrawMode);
1133 class CDrawThirtyTwoBppBitmapAlpha : public CDrawThirtyTwoBppBitmapCommon
1136 TInt Construct(TSize aSize);
1137 TInt Construct(TSize aSize, TInt aStride);
1138 // from CDrawThirtyTwoBppBitmap
1139 void WriteRgb(TInt aX,TInt aY,TRgb aColor);
1140 void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
1141 void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
1142 void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
1143 void MapBufferToUserDisplayMode(TInt aLength,TUint32* aBuffer);
1144 void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
1145 void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1146 void ShadowArea(const TRect& aRect);
1147 // From MOutlineAndShadowBlend
1148 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
1149 TUint32 aOutlinePenColor, TUint32 aShadowColor,
1150 TUint32 aFillColor, const TUint8* aDataBuffer);
1152 virtual TUint32 Color(const TRgb& aColor);
1153 virtual TRgb RgbColor(TUint32 aColor) const;
1154 using CDrawThirtyTwoBppBitmapCommon::Shadow;
1155 void Shadow(TUint32& aColor);
1157 virtual void WriteRgbAlphaLine(TInt aX,
1160 const TUint8* aRgbBuffer,
1161 const TUint8* aMaskBuffer,
1162 MAlphaBlend::TShadowing aShadowing,
1163 CGraphicsContext::TDrawMode aDrawMode);
1170 class CDrawThirtyTwoBppBitmapAlphaPM : public CDrawThirtyTwoBppBitmapCommon
1173 TInt Construct(TSize aSize);
1174 TInt Construct(TSize aSize, TInt aStride);
1175 // from CDrawThirtyTwoBppBitmap
1176 void WriteRgb(TInt aX,TInt aY,TRgb aColor);
1177 void WriteBinary(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TInt aHeight,TRgb aColor);
1178 void WriteBinaryLineVertical(TInt aX,TInt aY,TUint32* aBuffer,TInt aLength,TRgb aColor,TBool aUp);
1179 void WriteRgbAlphaMulti(TInt aX,TInt aY,TInt aLength,TRgb aColor,const TUint8* aMaskBuffer);
1180 void BlendRgbMulti(TInt aX,TInt aY,TInt aWidth,TInt aLength,TRgb aColor);
1181 void BlendLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer);
1182 void ShadowArea(const TRect& aRect);
1183 virtual void WriteLine(TInt aX,TInt aY,TInt aLength,TUint32* aBuffer,
1184 CGraphicsContext::TDrawMode aDrawMode);
1185 // From MOutlineAndShadowBlend
1186 virtual TInt WriteRgbOutlineAndShadow(TInt aX, TInt aY, const TInt aLength,
1187 TUint32 aOutlinePenColor, TUint32 aShadowColor,
1188 TUint32 aFillColor, const TUint8* aDataBuffer);
1190 virtual TUint32 Color(const TRgb& aColor);
1191 virtual TRgb RgbColor(TUint32 aColor) const;
1193 virtual void WriteRgbAlphaLine(TInt aX,
1196 const TUint8* aRgbBuffer,
1197 const TUint8* aMaskBuffer,
1198 MAlphaBlend::TShadowing aShadowing,
1199 CGraphicsContext::TDrawMode aDrawMode);
1204 #include "CoordTransformation.inl"
1206 /** DO NOT have a declaration as the compiler will think the source is in the .cpp and make this non-inline
1208 Made a global inline to force the compiler to inline so as to gain performance.
1209 A member inlines are not guarenteed to be inline.
1211 ASSERT Primary Color >= 0 && Primary Color <= 255
1212 If <0 or >255, after a shift right of 8-bits should prove true.
1213 00000001 00000000 = 256 >> 8 = 00000000 00000001 = TRUE
1214 11111111 11111111 = -1 >> 8 = 00000000 11111111 = TRUE
1215 00000000 11111111 = 255 >> 8 = 00000000 00000000 = FALSE
1218 Initial AlphaValue = 0...1.0
1220 R = APs + (1 - A)Pd ...so if A=0 the destination pixel is more dominant
1221 and if A=1 the sourec pixel is more dominant
1229 Passed-in AlphaValue = 0...255
1230 AlphaValue = 257 * Passed-in AlphaValue = 0...65536
1232 NOTE: AlphaValue is now a 16-bit number. the colours are 8-bit, so we shouldn't
1233 have overflow problems.
1234 NOTE: Negative values (Ps-Pd) shouldn't be a problem as the shifting right of
1235 signed values duplicates the signed bit in the msb.
1241 R = (A(Ps-Pd)) >> 16) + Pd
1243 inline TRgb AlphaBlend(TInt aPrimaryRed, TInt aPrimaryGreen, TInt aPrimaryBlue, TInt aSecondaryRed,
1244 TInt aSecondaryGreen, TInt aSecondaryBlue, TInt aAlphaValue)
1246 __ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8) &&
1247 !(aSecondaryRed>>8) && !(aSecondaryGreen>>8) && !(aSecondaryBlue>>8),
1248 Panic(EScreenDriverPanicAlphaBlendInvariant));
1250 const TInt alphaValue = aAlphaValue * 257;
1251 return TRgb(((alphaValue * (aPrimaryRed - aSecondaryRed)) >> 16) + aSecondaryRed,
1252 ((alphaValue * (aPrimaryGreen - aSecondaryGreen)) >> 16) + aSecondaryGreen,
1253 ((alphaValue * (aPrimaryBlue - aSecondaryBlue)) >> 16) + aSecondaryBlue);
1256 inline TRgb AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue,TRgb aSecondary,TInt aAlphaValue)
1258 return AlphaBlend(aPrimaryRed,aPrimaryGreen,aPrimaryBlue,aSecondary.Red(), aSecondary.Green(), aSecondary.Blue(), aAlphaValue);
1262 It unpacks the 16 bit colour in to the red, green and blue colour components.
1263 @param aColor64K The 16 bit colour which needs to be unpacked.
1264 @param aRed Red component of aColor64K is returned into this.
1265 @param aGreen Green component of aColor64K is returned into this.
1266 @param aBlue Blue component of aColor64K is returned into this.
1268 FORCEINLINE void UnpackColor64K(TUint16 aColor64K, TInt& aRed, TInt& aGreen, TInt& aBlue)
1270 aRed = (aColor64K&0xF800)>>8;
1272 aGreen = (aColor64K&0x07E0)>>3;
1273 aGreen += aGreen>>6;
1274 aBlue = (aColor64K&0x001F)<<3;
1279 It creates the 16 bit colour from the red, green and blue colour components.
1280 @param aRed The Red component for creating 16 bit colour.
1281 @param aGreen The Green component for creating 16 bit colour.
1282 @param aBlue The Blue component for creating 16 bit colour.
1283 @return TUint16 The 16 bit colour created from the colour components.
1285 FORCEINLINE TUint16 PackColor64K(TInt aRed, TInt aGreen, TInt aBlue)
1287 TUint16 color64K = (aBlue & 0xF8) >> 3;
1288 color64K |= (aGreen & 0xFc) << 3;
1289 color64K |= (aRed & 0xF8) << 8;
1294 It is an overloaded function for alpha bending which does blending for 16 bit colour.
1295 @param aPrimaryColor64K The foreground pixel colour in 16 bit format.
1296 @param aSecondaryColor64K The background pixel colour in 16 bit format.
1297 @param aAlphaValue The alpha value used for blending.
1298 @return The 16 bit blended colour.
1300 FORCEINLINE TUint16 AlphaBlend(TUint16 aPrimaryColor64K, TUint16 aSecondaryColor64K,TInt aAlphaValue)
1306 TInt secondaryGreen;
1309 UnpackColor64K(aPrimaryColor64K, primaryRed, primaryGreen, primaryBlue);
1310 UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue);
1312 __ASSERT_DEBUG(!(primaryRed>>8) && !(primaryGreen>>8) && !(primaryBlue>>8) && !(aAlphaValue>>8),
1313 Panic(EScreenDriverPanicAlphaBlendInvariant));
1315 const TInt alphaValue = aAlphaValue * 257;
1316 return PackColor64K(((alphaValue * (primaryRed - secondaryRed)) >> 16) + secondaryRed,
1317 ((alphaValue * (primaryGreen - secondaryGreen)) >> 16) + secondaryGreen,
1318 ((alphaValue * (primaryBlue - secondaryBlue)) >> 16) + secondaryBlue);
1322 It is an overloaded function for alpha bending which does blending for 16 bit colour.
1323 @param aPrimaryRed Red component of foreground pixel colour.
1324 @param aPrimaryGreen Green component of foreground pixel colour.
1325 @param aPrimaryBlue Blue component of foreground pixel colour.
1326 @param aSecondaryColor64K The background pixel colour in 16 bit format.
1327 @param aAlphaValue The alpha value used for blending.
1328 @return The 16 bit blended colour.
1330 FORCEINLINE TUint16 AlphaBlend(TInt aPrimaryRed,TInt aPrimaryGreen,TInt aPrimaryBlue, TUint16 aSecondaryColor64K,TInt aAlphaValue)
1332 __ASSERT_DEBUG(!(aPrimaryRed>>8) && !(aPrimaryGreen>>8) && !(aPrimaryBlue>>8) && !(aAlphaValue>>8),
1333 Panic(EScreenDriverPanicAlphaBlendInvariant));
1335 if (aAlphaValue==0xFF)
1336 return(PackColor64K(aPrimaryRed, aPrimaryGreen, aPrimaryBlue));
1338 TInt secondaryGreen;
1341 UnpackColor64K(aSecondaryColor64K, secondaryRed, secondaryGreen, secondaryBlue);
1343 const TInt alphaValue = aAlphaValue * 257;
1344 return PackColor64K(((alphaValue * (aPrimaryRed - secondaryRed)) >> 16) + secondaryRed,
1345 ((alphaValue * (aPrimaryGreen - secondaryGreen)) >> 16) + secondaryGreen,
1346 ((alphaValue * (aPrimaryBlue - secondaryBlue)) >> 16) + secondaryBlue);
1349 FORCEINLINE LOCAL_C TUint16 Conv32To16(TUint32 col)
1351 TUint b = (col&0x000000ff)>>3;
1352 TUint g = (col&0x0000fc00)>>5;
1353 TUint r = (col&0x00f80000)>>8;
1354 return TUint16(r|g|b);
1357 // Alpha-blends an EColor16MA pixel to an EColor64K screen using a fixed mask value.
1358 FORCEINLINE LOCAL_C TUint16 Blend32To16(TUint32 aSrc32, TUint aMask, TUint16 aDest16)
1360 __ASSERT_DEBUG(aMask < 256, Panic(EScreenDriverPanicInvalidParameter));
1365 return Conv32To16(aSrc32);
1367 // blend red and blue channel in one go
1368 TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
1369 d_rb |= (d_rb>>5) & 0x00ff00ff;
1370 const TUint32 s_rb = aSrc32 & 0x00FF00FF;
1371 const TUint32 mask2 = aMask | (aMask << 16);
1372 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
1374 // do the green channel normally
1375 TInt32 d_g = (aDest16 & 0x07E0)>>3;
1377 const TInt32 s_g = (aSrc32 & 0xFF00) >> 8;
1378 TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF;
1380 return (Conv32To16(rb | g<<8));
1386 // As for Blend32To16, but assumes 0xFF and 0 alpha checks already done elsewhere
1387 FORCEINLINE LOCAL_C TUint16 Blend32To16NoChecks(TUint32 aSrc32, TUint aMask, TUint16 aDest16)
1389 // blend red and blue channel in one go
1390 TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
1391 d_rb |= (d_rb>>5) & 0x00ff00ff;
1392 const TUint32 s_rb = aSrc32 & 0x00FF00FF;
1393 const TUint32 mask2 = aMask | (aMask << 16);
1394 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
1396 // do the green channel normally
1397 TInt32 d_g = (aDest16 & 0x07E0)>>3;
1399 const TInt32 s_g = (aSrc32 & 0xFF00) >> 8;
1400 TInt g = (((aMask * (s_g - d_g)) >> 8) + d_g) & 0xFF;
1402 return (Conv32To16(rb | g<<8));
1405 // Alpha-blends to an EColor64K screen using a fixed mask value.
1406 // The source values are pre-split from a 32 bit source into the two following components:
1408 // aSrcRB=aSrc32 & 0x00FF00FF;
1409 // aSrcG=(aSrc32 & 0xFF00) >> 8;
1411 // Mask is assumed not to be 0 or 255, these should be pre-checked for and never arrive here
1413 FORCEINLINE LOCAL_C TUint16 BlendTo16(const TUint32 aSrcRB, const TUint32 aSrcG, TUint aMask, TUint16 aDest16)
1415 // blend red and blue channel in one go
1416 TUint32 d_rb = (aDest16 & 0xF800)<<8 | (aDest16 & 0x001F)<<3;
1417 d_rb |= (d_rb>>5) & 0x00ff00ff;
1418 const TUint32 mask2 = aMask | (aMask << 16);
1419 const TUint32 rb = ((((aMask * ((0x01000100 + aSrcRB) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
1421 // do the green channel normally
1422 TInt32 d_g = (aDest16 & 0x07E0)>>3;
1424 const TInt32 g = (((aMask * (aSrcG - d_g)) >> 8) + d_g) & 0xFF;
1426 // inline conversion to 16 bit
1427 return TUint16(((rb&0x00f80000)>>8)|((g&0x0000fc)<<3)|((rb&0x000000ff)>>3));
1430 // Alpha-blends an EColor16MA pixel to an EColor16MU screen using a fixed mask value.
1431 FORCEINLINE LOCAL_C TUint32 CalcAlphaPixel(const TUint32 aSrcPixel, const TUint8 aMask, TUint32 aDestPixel)
1433 // (a) (mask * src + (255 - mask) * dest) / 255 This ideal formula
1434 // (b) ((mask * (src - dest)) >> 8) + dest A faster approximation to (a)
1435 // (c) ((mask * (256 + src - dest) >> 8) + dest - mask Equivalent to (b) but can be used on multiple colors at a time
1440 return 0xff000000|aSrcPixel;
1442 const TUint32 s_rb = aSrcPixel & 0x00FF00FF;
1443 const TUint32 d_rb = aDestPixel & 0x00FF00FF;
1444 const TUint32 mask2 = aMask | (aMask << 16);
1445 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF;
1447 const TInt s_g = (aSrcPixel & 0xFF00) >> 8;
1448 const TInt d_g = (aDestPixel & 0xFF00) >> 8;
1449 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g;
1451 return(rb | (g<<8) | 0xff000000);
1458 // Alpha-blends an EColor16MA rgb to an EColor16MU screen using a fixed mask value.
1459 FORCEINLINE LOCAL_C void AlphaBlendPixelToDest(TUint32 aSrcValue, const TUint8 aSourceAlpha, TUint32* aDestPtr)
1461 *aDestPtr = CalcAlphaPixel(aSrcValue, aSourceAlpha, *aDestPtr);
1464 void MemFillTUint32(TUint32* tempWordPtr, TInt aCount, const TUint32 aValue);