1 // Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __GRAPHICSACCELERATOR_H__
17 #define __GRAPHICSACCELERATOR_H__
28 class TAcceleratedBitmapSpec;
31 A data structure that holds the information needed to directly access a bitmap.
33 The bitmap can be a hardware bitmap (RHardwareBitmap), or an ordinary bitmap
34 (CFbsBitmap). An object of this class is filled by calling TAcceleratedBitmapSpec::GetInfo().
38 @see TAcceleratedBitmapSpec::GetInfo()
42 class TAcceleratedBitmapInfo
46 /** The bitmap's display mode. */
47 TDisplayMode iDisplayMode;
49 /** The address of the start of the bitmap. */
52 /** The width and height of the bitmap in pixels. */
55 /** The address offset (in bytes) between successive lines in a bitmap. */
58 /** The shift required to obtain the number of bits needed to represent one pixel in the bitmap.
59 The number of bits per pixel is calculated as 1 << iPixelShift */
62 /** The physical address of the start of the bitmap. This is the address which a
63 hardware graphics accelerator will use and is zero if the bitmap is not accessible
64 to hardware graphics accelerators. */
65 TUint8* iPhysicalAddress;
69 The interface to a hardware bitmap.
71 This is a bitmap that can be drawn to by graphics acceleration hardware. It
72 is stored in a contiguous area of physical memory.
74 After creating the hardware bitmap, it can be passed to CHardwareGraphicsAccelerator::NewL().
76 @see CHardwareGraphicsAccelerator::NewL()
82 friend class CBitwiseBitmap;
83 friend class CFbsScreenDevice;
86 /** Default constructor. */
87 inline RHardwareBitmap();
89 /** Constructor taking the handle of an existing RHardwareBitmap to duplicate it. */
90 inline RHardwareBitmap(TInt aHandle);
93 Gets the information needed for accessing a bitmap directly into TAcceleratedBitmapInfo structure.
95 @param aInfo On return, holds the information needed to directly access the bitmap.
96 @return KErrNone if sucessful, otherwise one of the system error codes, including
97 KErrUnknown if the object's type is ENoBitmap.
99 IMPORT_C TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const;
101 IMPORT_C TInt SetAsScreenReference(TInt aScreen=-1);
102 IMPORT_C TInt Create(TDisplayMode aDisplayMode, TSize aSize, TUid aCreatorUid);
103 IMPORT_C void Destroy();
106 /** The bitmap's handle; assigned during construction. This is used to identify
108 TInt iHandle; // Must be only member data
111 /** Default constructor. Initialises the handle to zero. */
112 inline RHardwareBitmap::RHardwareBitmap()
116 /** Constructor taking the handle of an existing RHardwareBitmap to duplicate.
117 @param aHandle The RHardwareBitmap handle to duplicate. */
118 inline RHardwareBitmap::RHardwareBitmap(TInt aHandle)
123 Maintains a count of the number of locks made on a bitmap through a TAcceleratedBitmapSpec
126 Passed as a parameter to TAcceleratedBitmapSpec::Lock() and TAcceleratedBitmapSpec::Unlock().
128 @see TAcceleratedBitmapSpec
132 class TBitmapLockCount
134 friend class TAcceleratedBitmapSpec;
137 /** Default constructor. Initialises the lock count to zero. */
138 inline TBitmapLockCount() : iCount(0) {}
140 inline TInt Inc() { return iCount++; }
141 inline TInt Dec() { return --iCount; }
148 A utility class that provides access to the contents of a bitmap.
150 The bitmap can be a hardware bitmap (RHardwareBitmap), or an ordinary bitmap
151 (CFbsBitmap). An object of this class is used as a parameter by several accelerated
152 graphics operations, e.g. TGopBitBlt, to specify the source bitmap for the
157 class TAcceleratedBitmapSpec
161 inline TAcceleratedBitmapSpec();
162 IMPORT_C TAcceleratedBitmapSpec(CFbsBitmap* aBitmap);
163 IMPORT_C TAcceleratedBitmapSpec(RHardwareBitmap aBitmap);
164 // Bitmap access (use with caution, see documentation)
166 IMPORT_C TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const;
167 inline void Lock(TBitmapLockCount& aCount);
168 inline void Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo);
169 inline void Unlock(TBitmapLockCount& aCount);
172 /** Identifies the type of the bitmap.
174 Type() returns this value.
177 enum TAcceleratedBitmapType
179 /** The object was created using the default constructor, and has no type. */
182 /** The bitmap is of type CFbsBitmap.
187 /** The bitmap is of type RHardwareBitmap.
189 @see RHardwareBitmap */
192 enum TAcceleratedBitmapLock
198 inline TAcceleratedBitmapType Type() const;
199 inline TInt Handle() const;
201 IMPORT_C void DoLock(TBitmapLockCount& aCount);
202 IMPORT_C void DoLock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo);
203 IMPORT_C void DoUnlock(TBitmapLockCount& aCount);
205 TUint8 iType; // TAcceleratedBitmapType
206 TUint8 iLockStatus; // TAcceleratedBitmapLock
212 /** Default constructor.
213 Use one of the other constructor overloads instead. */
214 inline TAcceleratedBitmapSpec::TAcceleratedBitmapSpec()
215 : iType(ENoBitmap), iLockStatus(EBitmapIsStatic)
218 /** Prevents a bitmap from moving in memory. Lock() should be called before accessing
219 the bitmap and Unlock() immediately afterwards. Although it is not necessary
220 to lock and unlock some types of bitmap, it is a small overhead, and it is
221 recommended that you always do it.
223 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
224 within the same thread must use the same TBitmapLockCount object, even if
225 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
227 @param aCount Maintains a count of the number of locks made on the bitmap. */
228 inline void TAcceleratedBitmapSpec::Lock(TBitmapLockCount& aCount)
229 { if(iLockStatus==EBitmapNeedsLocking) DoLock(aCount); }
231 /** Prevents a bitmap from moving in memory. Lock() should be called before accessing
232 the bitmap and Unlock() immediately afterwards. Although it is not necessary
233 to lock and unlock some types of bitmap, it is a small overhead, and it is
234 recommended that you always do it. Also updates a TAcceleratedBitmapInfo structure
235 with any information that may have changed, (typically the bitmap's memory
238 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
239 within the same thread must use the same TBitmapLockCount object, even if
240 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
242 @param aCount Maintains a count of the number of locks made on the bitmap.
243 @param aInfo On return, contains the new address of the start of the bitmap. */
244 inline void TAcceleratedBitmapSpec::Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo)
245 { if(iLockStatus==EBitmapNeedsLocking) DoLock(aCount,aInfo); }
247 /** Frees a bitmap after a call to Lock(). A call to Unlock() must be made for each corresponding
248 call to Lock(). This function should be called as soon as any bitmap access has finished. If, after
249 the Unlock() operation, no more calls to Lock() are outstanding on the bitmap, the bitmap is free to
250 be moved in memory again.
252 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
253 within the same thread must use the same TBitmapLockCount object, even if
254 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
256 @param aCount Maintains a count of the number of locks made on the bitmap. */
257 inline void TAcceleratedBitmapSpec::Unlock(TBitmapLockCount& aCount)
258 { if(iLockStatus==EBitmapNeedsLocking) DoUnlock(aCount); }
260 /** Returns the type of the bitmap. The type is assigned during construction.
262 @return The type of bitmap. */
263 inline TAcceleratedBitmapSpec::TAcceleratedBitmapType TAcceleratedBitmapSpec::Type() const
264 { return (TAcceleratedBitmapSpec::TAcceleratedBitmapType)iType; }
266 /** Returns the handle to the bitmap.
268 @return The handle to the bitmap. */
269 inline TInt TAcceleratedBitmapSpec::Handle() const
273 // Accelerator capabilities
278 Enumerates the four transparency types.
280 ETransparentPixel and ETransparentColor are used with a pixel value or a TRgb
283 @see TGopTransparency
284 @see TGraphicsAcceleratorCaps::iTransparency
288 enum TTransparencyType
291 /** Any pixel that has all bits equal to zero is treated as transparent. */
292 ETransparentPixelZero,
294 /** Any pixel that is equal to the pixel value passed to the TGopTransparency constructor
295 is treated as transparent. */
298 /** Any pixel that is equal to the TRgb value passed to the TGopTransparency constructor
299 is treated as transparent. */
302 /** In 16 bits per pixel display mode, which uses 5 bits each for red, green and
303 blue, the most significant bit is an Alpha value. Alpha=0 means the pixel
304 is transparent, Alpha=1 means the pixel is fully opaque. */
309 Stores the capabilities of a graphics accelerator.
311 All of the member enums except TMaskBitmapCaps define flags that are stored
312 as public data of type TUint. Only TMaskBitmapCaps takes sequential values,
313 so its values are mutually exclusive.
315 An object of this class is returned by CGraphicsAccelerator::Capabilities()
316 or by GenericCapabilities(), which is implemented by CSoftwareGraphicsAccelerator
317 and CHardwareGraphicsAccelerator.
319 @see CGraphicsAccelerator::Capabilities()
323 class TGraphicsAcceleratorCaps
326 /** Clipping capabilities. Used by the iClipping member.
328 @see CGraphicsAccelerator::Operation() */
329 enum TClipCaps // Bit flags
331 EClipToBitmap = 1, // Will always clip all operations to the bitmap
333 /** The accelerator supports the Operation() methods which take clipping rectangles
336 @see CGraphicsAccelerator::Operation() */
337 EClipping = 2 // Is able to clip operations to a region
340 /** Enumerates the capabilities relating to operations taking a bitmap mask parameter,
341 for instance TGopBitBltMasked. These are mutually exclusive values used by
342 the iMaskType member. */
343 enum TMaskBitmapCaps // Enum
345 /** No masked operations are supported. */
348 /** The mask bitmap can be in any display mode at all. */
349 EMaskBitmapAnyDisplayMode,
351 /** The mask bitmap must be in the same display mode as the destination bitmap. */
352 EMaskBitmapMatchingDisplayMode,
354 /** The mask bitmap must be in EGray2 display mode. */
358 /** Bit flags for the capabilities relating to operations that use an alpha channel
359 (TGopBitBltAlphaChannel and TGopScaledBitBltAlphaChannel). These flags are
360 used by the iAlphaChannel member. */
361 enum TAlphaChannelCaps //Bit flags
363 /** The accelerator can draw bitmaps with 4 bits each for the alpha value and the
364 red, green and blue components. */
365 EAlpha4444 = 1, // Bitmaps with 4 bits for Alpha value and Red, Green, Blue components
367 /** The accelerator can draw bitmaps with 8 bits each for the alpha value and the
368 red, green and blue components. */
369 EAlpha8888 = 2, // Bitmaps with 8 bits for Alpha value and Red, Green, Blue components
371 /** The accelerator can draw bitmaps with 1 bit for the alpha value and and 5 bits
372 for the red, green and blue components. */
373 EAlpha1555 = 4, // Bitmaps with 1 bit for Alpha value and 5 bits for Red, Green, and Blue
376 /** Bit flags for the capabilities relating to operations which take an alpha bitmap
377 parameter, for instance TGopBitBltAlphaBitmap. These flags are used by the
378 iAlphaBitmap member. */
379 enum TAlphaBitmapCaps //Bit flags
381 /** For 256 greyscale bitmaps, the value of each pixel in the alpha bitmap (from
382 0 to 255) is used as the alpha value. */
383 EAlphaBitmapGray256 = 1,
385 /** An EColor16M bitmap may be used as the alpha bitmap. The red, green and blue
386 values for each pixel in this bitmap are used as the alpha values for the
387 red, green and blue components of the corresponding pixel in the source bitmap. */
388 EAlphaBitmapColor16M = 2,
390 /** The alpha bitmap must have the same display mode as the source bitmap. */
391 EAlphaBitmapMatchingMode = 4, // Alpha bitmap must be same mode as source
394 /** Indicates whether there is a restriction on the sizes of bitmaps that can be
395 used in bitmap patterns.
397 This is one of the possible values for the iPatternSizes member.
399 @see TGopFillPattern */
400 enum TPatternSizeCaps //Bit flags
402 /** There is no restriction on the dimensions of bitmap patterns. */
403 EPatternSizeAny = 0xFFFFFFFF,
406 /** Bit flags for the capabilities relating to operations that draw a fill pattern
407 using a bitmap, for instance TGopFilledRectWithPatern. They are used in the
409 enum TPatternCaps //Bit flags
411 /** The pattern bitmap can be in any display mode. */
412 EPatternAnyDisplayMode = 1, // Patterns can be in any supported display mode
414 /** The pattern bitmap must be in the same display mode as the destination. */
415 EPatternMatchingDisplayMode = 2, // Pattern must be in same displ mode as target
417 /** The pattern bitmap must be square (width==height). */
418 EPatternMustBeSquare = 4, // The pattern must be square (width==height)
421 /** Bit flags for how self-crossing polygons are filled.
423 @see CGraphicsContext::TFillRule */
424 enum TPolygonCaps // Bit flags for fill rules (see CGraphicsContext::TFillRule)
426 /** Only areas with odd winding numbers are filled. */
427 EPolygonFillAlternate = 1,
429 /** All areas with a winding number greater than zero are filled.
431 @see CGraphicsContext::TFillRule */
432 EPolygonFillWinding = 2,
435 /** Bit flags for the specifying the supported rendering orientations.
436 @see CFbsBitGc::TGraphicsOrientation */
437 enum TOrientationCaps
439 /** Normal orientation is supported. */
440 EOrientationCapNormal = 1,
441 /** A 90 degree rotation is supported. */
442 EOrientationCapRotated90 = 2,
443 /** A 180 degree rotation is supported. */
444 EOrientationCapRotated180 = 4,
445 /** A 270 degree rotation is supported. */
446 EOrientationCapRotated270 = 8,
447 /** All orientations are supported. */
448 EOrientationCapAll = EOrientationCapNormal|EOrientationCapRotated90|EOrientationCapRotated180|EOrientationCapRotated270,
451 /** The size of this class in bytes. */
452 TInt iStructureSize; // The size of this class
454 /** The version number of the API. */
455 TInt iVersion; // == 1 to specify current API
457 /** Optional UID to identify the vendor of the graphics accelerator. This UID can
458 be used to recognise a particular accelerator, enabling code to use any custom
459 graphics operations and capabilities that it knows the accelerator provides. */
460 TUid iVendorUid; // Optional ID
462 /** A bit mask of the supported display modes for the bitmap passed to the graphics
463 accelerator's NewL(). Uses the least significant 11 bits as flags for each
464 TDisplayMode supported. For instance, to check whether the EColor256 display
465 mode is available, use the expression iDisplayModes & (1 << EColor256).
468 TUint iDisplayModes; // One bit for each TDisplayMode enumeration
470 /** Indicates whether the Operation() methods which take clipping rectangles as
471 parameters are supported.
474 TUint iClipping; // TClipCaps bit flags
476 /** Specifies the display mode restrictions for bitmap masks. These are mutually
479 @see TMaskBitmapCaps */
480 TMaskBitmapCaps iMaskType; // Mask type used
482 /** Specifies the transparency types supported. Uses a bit flag for each TTransparencyType
485 @see TTransparencyType */
486 TUint iTransparency; // Bit flag for each TTransparencyType supported
488 /** Specifies the capabilities relating to operations that use an alpha channel. Uses a bit flag for
489 each TAlphaChannelCaps supported.
491 @see TAlphaChannelCaps */
492 TUint iAlphaChannel; // TAlphaChannelCaps bit flags
494 /** Specifies the supported alpha bitmap types. Uses a bit flag for each TAlphaBitmapCaps
497 @see TAlphaBitmapCaps */
498 TUint iAlphaBitmap; // TAlphaBitmapCaps bit flags
500 /** Specifies the sizes of bitmaps that can be used in bitmap patterns.
502 This is a bitmask for each power of 2, or EPatternSizeAny. For example, if
503 bitmaps used in patterns can only have a width or height of 16 pixels then
504 this value should be set to 16. If patterns can have dimensions of 16, 32,
505 64, 128 or 256, then this value would equal the sum of these, (i.e. bits 4,
506 5, 6, 7 and 8 would be set). If this value is equal to EPatternSizeAny, there
507 are no restrictions on the size of patterns that can be used.
509 @see TPatternSizeCaps */
510 TUint iPatternSizes; // a mask bit for each power of 2, or EPatternSizeAny
512 /** Specifies the supported bitmap types for fill patterns. Uses a bit flag for
513 each TPatternCaps supported.
516 TUint iPattern; // TPatternCaps bit flags
518 /** Specifies the supported fill rules for self crossing polygons. Uses a bit flag
519 for each TPolygonCaps supported.
522 TUint iPolygon; // TPolygonCaps bit flags
525 iReserved[0] specifies the supported rendering orientations.Uses a bit flags
526 for each TOrientationCaps supported.
527 @see TOrientationCaps
528 iReserved[1]-iReserved[3] are reserved for future use. All should be set to zero.
535 // TGraphicsOperation
539 Abstract base class for all graphics operations.
541 Derived classes encapsulate all the arguments needed by a given graphics operation.
542 An object of one of the derived classes is passed as a parameter to CGraphicsAccelerator::Operation().
543 The member functions and enum defined in this class are not used directly
546 @see CGraphicsAccelerator::Operation()
550 class TGraphicsOperation
554 { // Require arguments commented below here
556 EFilledRect, // (TRect,TRgb)
557 EFilledRectUsingDrawMode, // (TRect,TRgb,CGraphicsContext:TDrawMode)
558 EFilledRectWithPattern, // (TRect,TGopFillPattern)
559 EInvertRect, // (TRect)
560 EFadeRect, // (TRect,TGopFadeParams)
562 EBitBlt, // (TPoint,TAcceleratedBitmapSpec,TRect&)
563 EBitBltMasked, // (TPoint,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aMask)
564 EBitBltTransparent, // (TPoint,TAcceleratedBitmapSpec,TRect&,TGopTransparency)
565 EBitBltAlphaChannel, // (TPoint,TAcceleratedBitmapSpec,TRect&)
566 EBitBltAlphaBitmap, // (TPoint,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aAlpha)
568 EScaledBitBlt, // (TRect,TAcceleratedBitmapSpec,TRect&)
569 EScaledBitBltMasked, // (TRect,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aMask)
570 EScaledBitBltTransparent, // (TRect,TAcceleratedBitmapSpec,TRect&,TGopTransparency)
571 EScaledBitBltAlphaChannel, // (TRect,TAcceleratedBitmapSpec,TRect&)
572 EScaledBitBltAlphaBitmap, // (TRect,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aAlpha)
574 EFilledPolygon, // (TRGb aColor,CGraphicsContext::TFillRule aFillRule,TInt aNumPoints,TPoint[])
575 EFilledPolygonWithPattern, // (TGopFillPattern,CGraphicsContext::TFillRule aFillRule,TInt aNumPoints,TPoint[])
576 EAlphaBlendTwoBitmaps, // (TPoint,TAcceleratedBitmapSpec aSrce1,TAcceleratedBitmapSpec aSrce2,TRect&,TAcceleratedBitmapSpec aAlpha)
577 EAlphaBlendOneBitmap, // (TPoint,TAcceleratedBitmapSpec aSrce,TRect&,TAcceleratedBitmapSpec aAlpha)
583 inline TGopFunction Function() const { return iFunction; }
584 inline TInt Size() const { return iSize; }
586 inline TGraphicsOperation* Next() const;
587 inline void Append(TInt aNumBytes,TAny* aData);
589 inline TGraphicsOperation(TGopFunction aFunction, TInt aArgSize);
590 inline TGraphicsOperation() {}
592 TGopFunction iFunction;
593 TInt iSize; // Total size of derived class
596 inline TGraphicsOperation::TGraphicsOperation(TGopFunction aFunction, TInt aSize)
597 : iFunction(aFunction) , iSize(aSize) {}
599 inline TGraphicsOperation* TGraphicsOperation::Next() const
600 { return (TGraphicsOperation*)((TUint8*)this+iSize); }
602 inline void TGraphicsOperation::Append(TInt aNumBytes,TAny* aData)
604 Mem::Copy(Next(),aData,aNumBytes);
610 // Graphics accelerator
614 Abstract base class for 2D graphics accelerators.
616 This class can be derived from to provide accelerated implementations of some
617 common 2D graphics algorithms. Support for accelerated 2D graphics has been
618 integrated into existing classes in the Graphics API for instance CFbsBitGc,
619 so that existing code does not need to be altered, but a graphics accelerator
620 can be used directly by applications. The accelerated 2D graphics operations
621 may be implemented in software, hardware, or both.
625 class CGraphicsAccelerator : public CBase
628 // Return the capabilities of this accelerator
630 /** Returns the capabilities of the graphics accelerator.
632 @return The capabilities of the accelerator. */
633 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
635 // Perform a graphics operation
637 /** Requests the graphics accelerator to perform a single graphics operation.
639 @param aOperation An instance of a TGraphicsOperation-derived class that identifies
640 the graphics operation to be performed.
641 @return KErrNone if successful, otherwise one of the system error codes. The
642 function should return KErrNotSupported if the accelerator does not support
643 the requested operation. */
644 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
646 /** Requests the graphics accelerator perform a single graphics operation within
647 a clipping region. This version is of Operation() is only usable if the
648 accelerator capabilities returned by Capabilities() indicate that clipping to a region
651 @param aOperation An instance of a TGraphicsOperation-derived class that identifies
652 the graphics operation to be performed.
653 @param aNumClipRects The number of rectangles in the clipping region.
654 @param aClipRects A pointer to the first rectangle in the clipping region.
655 @return KErrNone if successful, otherwise one of the system error codes. The
656 function should return KErrNotSupported if the accelerator does not support
657 the requested operation.
658 @see TGraphicsAcceleratorCaps::iClipping */
659 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
661 // Process a buffer of TGraphicsOperation. (Each operation immediately follows the
662 // one preceding it in the buffer)
664 /** Requests the graphics accelerator perform one or more graphics operations contained
667 The underlying implementation may be able to process a group of graphics operations
668 more efficiently than if Operation() was called for each individually.
670 This function should be implemented as if Operation() was called in turn for
671 each operation contained in the buffer. Each operation should be carried out
672 immediately after the one preceding it. If a method returns an error, the
673 length of aBuffer should be set to indicate the number of operations that
674 have been successfully processed. In this case, the operation in which the
675 error occurred will be indicated by the memory address &aBuffer[aBuffer.Length()].
677 @param aBuffer A descriptor which holds a concatenation of graphics operations
678 (TGraphicsOperation-derived objects).
679 @return KErrNone if successful, otherwise one of the system error codes. The
680 function should return KErrNotSupported if the accelerator does not support
681 any of the requested operations. */
682 virtual TInt Operation(TDes8& aBuffer) = 0;
684 /** Requests the graphics accelerator perform one or more graphics operations within
685 a clipping region. This version is of Operation() is only usable if the
686 accelerator capabilities returned by Capabilities() indicate that clipping to a region
689 The underlying implementation may be able to process a group of graphics operations
690 more efficiently than if Operation() was called for each individually.
692 This function should be implemented as if Operation() was called in turn for
693 each operation contained in the buffer. Each operation should be carried out
694 immediately after the one preceding it. If a method returns an error, the
695 length of aBuffer should be set to indicate the number of operations that
696 have been successfully processed. In this case, the operation in which the
697 error occurred will be indicated by the memory address &aBuffer[aBuffer.Length()].
699 @param aBuffer A descriptor which holds a concatenation of graphics operations
700 (TGraphicsOperation objects).
701 @param aNumClipRects The number of rectangles in the clipping region.
702 @param aClipRects A pointer to the first rectangle in the clipping region.
703 @return KErrNone if successful, otherwise one of the system error codes. The
704 function should return KErrNotSupported if the accelerator does not support
705 any of the requested operations.
706 @see TGraphicsAcceleratorCaps::iClipping */
707 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
709 // Reserved virtual functions for future use
710 virtual void Reserved_1() = 0;
711 virtual void Reserved_2() = 0;
712 virtual void Reserved_3() = 0;
713 virtual void Reserved_4() = 0;
719 A factory for creating 2D graphics accelerator objects whose graphics operations
720 are implemented in software.
722 Objects of derived classes can write to all types of bitmap, not just hardware
723 bitmaps. Note that graphics accelerators may support only a subset of all
728 class CSoftwareGraphicsAccelerator : public CGraphicsAccelerator
731 // Create a new CSoftwareGraphicsAccelerator for use with a given bitmap
732 IMPORT_C static CSoftwareGraphicsAccelerator* NewL(CFbsBitmap* aBitmap);
734 // Get the non-bitmap-specific capabilities of the hardware accelerator.
735 IMPORT_C static const TGraphicsAcceleratorCaps* GenericCapabilities();
737 // From CGraphicsAccelerator
738 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
739 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
740 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
741 virtual TInt Operation(TDes8& aBuffer) = 0;
742 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
743 // From CGraphicsAccelerator
744 virtual void Reserved_1() = 0;
745 virtual void Reserved_2() = 0;
746 virtual void Reserved_3() = 0;
747 virtual void Reserved_4() = 0;
752 A factory for creating 2D graphics accelerator objects whose graphics operations
753 are implemented in hardware, software or a mixture of both.
755 Objects of derived classes can only write to hardware bitmaps (RHardwareBitmap).
756 Note that graphics accelerators may support only a subset of all graphics
763 class CHardwareGraphicsAccelerator : public CGraphicsAccelerator
767 Create a new CHardwareGraphicsAccelerator for use with a given hardware bitmap.
769 Do not use, link against scdv.lib.
771 @param aBitmap A bitmap that can be drawn by graphics acceleration hardware.
772 It can be any bitmap.
773 @return Reference to hardware graphics accelerator object.
775 IMPORT_C static CHardwareGraphicsAccelerator* NewL(RHardwareBitmap aBitmap);
778 Gets the generic capabilities of the accelerator, including the supported display modes
779 for the bitmap passed to NewL().
781 Do not use, link against scdv.lib.
783 @return Generic capabilities for software graphics accelerators.
785 IMPORT_C static const TGraphicsAcceleratorCaps* GenericCapabilities();
787 // From CGraphicsAccelerator
788 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
789 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
790 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
791 virtual TInt Operation(TDes8& aBuffer) = 0;
792 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
793 // From CGraphicsAccelerator
794 virtual void Reserved_1() = 0;
795 virtual void Reserved_2() = 0;
796 virtual void Reserved_3() = 0;
797 virtual void Reserved_4() = 0;
801 // Classes used as arguments to graphics operations
805 A pattern represented by a bitmap that is used by a graphics accelerator to
806 fill a rectangle or polygon.
808 An object of this class is specified when constructing a TGopFilledRectWithPattern
809 or TGopFilledPolygonWithPattern. The types and sizes of fill pattern bitmaps
810 supported by the accelerator are given by TGraphicsAcceleratorCaps::iPattern
811 and TGraphicsAcceleratorCaps::iPatternSizes respectively.
813 @see TGopFilledRectWithPattern
814 @see TGopFilledPolygonWithPattern
815 @see TGraphicsAcceleratorCaps::iPatternSizes
816 @see TGraphicsAcceleratorCaps::iPattern
820 class TGopFillPattern
824 /** Provides a handle to the bitmap, and other information needed to draw it. */
825 TAcceleratedBitmapSpec iBitmap;
827 /** The origin of the pattern. This is the position at which to draw the pixel at
828 the top left hand corner of the bitmap around which copies of the bitmap are
829 "tiled" to form the pattern. It is relative to the top left hand corner of
830 the rectangle being filled, so specify 0,0 if you want the bitmaps drawn flush
831 with the top and left hand sides of the rectangle. */
836 Specifies the amount of fading for all the pixels in a rectangular area.
838 Fading changes colours so that they are closer to white or closer to black.
839 To make colours whiter, increase iOffset; to use a smaller range of colours,
840 reduce iScale. Fading uses the following formula (where C is a red, green
841 or blue value in a TRgb):
843 colour component C = ( ( iScale * C ) / 256 )+iOffset;
846 - to fade to white, specify iScale=128, iOffset=128
847 - to fade to black, specify iScale=128, iOffset=0
848 - for no change, specify iScale=256, iOffset=0
850 An object of this class is specified when constructing a TGopFadeRect.
856 class TGopFadeParams // color component C = ( ( iScale * C ) >> 8 )+iOffset;
860 /** Specifies the degree of fading, maximum=256. */
863 /** The fading offset. Specifies whether to fade to black or to white. */
868 Specifies which pixels should be treated as transparent in a bitblt operation
869 that supports transparency.
871 This is used by the TGopBitBltTransparent and TGopScaledBitBltTransparent
874 For the possible transparency types, see the TTransparencyType enumeration.
876 An object of this class is specified when constructing a TGopBitBltTransparent or
877 TGopScaledBitBltTransparent.
879 @see TTransparencyType
880 @see TGopBitBltTransparent
881 @see TGopScaledBitBltTransparent
885 class TGopTransparency
889 /** Constructor with a transparency type. iParam is initialised to zero.
891 @param aType The transparency type. */
892 inline TGopTransparency(TTransparencyType aType) : iType(aType), iParam(0) {}
894 /** Constructor with a pixel value. The type is initialised to ETransparentPixel.
895 Any pixel that has a value equal to aPixelValue is treated as transparent.
896 aPixelValue is the bit pattern of the pixel as stored in the bitmap.
898 @param aPixelValue The pixel value. */
899 inline TGopTransparency(TInt aPixelValue) : iType(ETransparentPixel), iParam(aPixelValue) {}
901 /** Constructor with a TRgb value. The type is initialised to ETransparentColor.
902 Any pixel that has a color of aRgb is treated as transparent.
904 @param aRgb The TRgb value. */
905 inline TGopTransparency(TRgb aRgb) : iType(ETransparentColor), iParam(aRgb.Value()) {}
907 /** Gets the colour that is treated as transparent. This is the value of iParam
910 @return The colour that is treated as transparent. */
911 inline TRgb Color() const { return TRgb(iParam); }
913 /** Gets the value of the colour as a TInt that is treated as transparent. This
914 is the value of iParam.
916 @return The colour that is treated as transparent. This is the bit pattern
917 of the colour as stored in the bitmap. */
918 inline TInt Pixel() const { return iParam; }
921 /** The transparency type. */
922 TTransparencyType iType;
924 /** Holds the value of the colour/pixel that is treated as transparent. */
930 // Wrapper classes for graphics operation arguments
934 #pragma warning(disable : 4355) // Disable warning - 'this' : used in base member initializer list
938 An accelerated graphics operation that fills a rectangular area with a colour.
940 The data members are all initialised on construction. Objects of this class
941 can be passed to a graphics accelerator's Operation() function either individually,
946 class TGopFilledRect : public TGraphicsOperation
949 /** Constructor with a rectangle and a colour.
950 @param aRect The rectangle to fill.
951 @param aColor The fill colour. */
952 inline TGopFilledRect(const TRect& aRect,TRgb aColor)
953 : TGraphicsOperation(EFilledRect,sizeof(*this)), iRect(aRect) , iColor(aColor) {}
956 /** The rectangle to fill. */
959 /** The fill colour. */
964 An accelerated graphics operation that fills a rectangular area with a colour,
965 whilst performing a bitwise logical operation with the pixels in the region,
966 for instance AND, OR, Exclusive OR.
968 The bitwise logical operation is specified in the draw mode. The data members
969 are all initialised on construction. Objects of this class can be passed to
970 a graphics accelerator's Operation() function either individually, or in a
975 class TGopFilledRectUsingDrawMode : public TGraphicsOperation
978 /** Constructor with a rectangle, a colour and a draw mode.
979 @param aRect The rectangle to fill.
980 @param aColor The fill colour.
981 @param aDrawMode The draw mode. */
982 inline TGopFilledRectUsingDrawMode(const TRect& aRect,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode)
983 : TGraphicsOperation(EFilledRectUsingDrawMode,sizeof(*this)), iRect(aRect) , iColor(aColor) , iDrawMode(aDrawMode) {}
986 /** The rectangle to fill. */
989 /** The fill colour. */
992 /** The draw mode. */
993 CGraphicsContext::TDrawMode iDrawMode;
997 An accelerated graphics operation that fills a rectangular area with a pattern.
999 The pattern consists of multiple copies of a bitmap, drawn tiled around an
1000 origin. Objects of this class can be passed to a graphics accelerator's Operation()
1001 function either individually, or in a buffer.
1003 @see TGopFillPattern
1007 class TGopFilledRectWithPattern : public TGraphicsOperation
1010 /** Constructor with a rectangle and a pattern.
1011 @param aRect The rectangle to fill.
1012 @param aPattern Specifies the handle to the bitmap to use for the pattern,
1013 and the origin for the pattern. */
1014 inline TGopFilledRectWithPattern(const TRect& aRect,TGopFillPattern aPattern)
1015 : TGraphicsOperation(EFilledRectWithPattern,sizeof(*this)), iRect(aRect) , iPattern(aPattern) {}
1018 /** The rectangle to fill. */
1021 /** Specifies the handle to the bitmap to use for the pattern and the origin for
1023 TGopFillPattern iPattern;
1027 An accelerated graphics operation that inverts the colour of all pixels in
1030 Objects of this class can be passed to a graphics accelerator's Operation()
1031 function either individually, or in a buffer.
1035 class TGopInvertRect : public TGraphicsOperation
1038 /** Constructor with a rectangle.
1039 @param aRect The rectangle in which to invert the colours. */
1040 inline TGopInvertRect(const TRect& aRect)
1041 : TGraphicsOperation(EInvertRect,sizeof(*this)), iRect(aRect) {}
1044 /** The rectangle in which to invert the colours. */
1049 An accelerated graphics operation that fades the pixels in a rectangular area.
1051 Objects of this class can be passed to a graphics accelerator's Operation()
1052 function either individually, or in a buffer.
1056 class TGopFadeRect : public TGraphicsOperation
1059 /** Constructor with a rectangle and fade parameters.
1060 @param aRect The rectangle to fade.
1061 @param aFade The fade parameters. */
1062 inline TGopFadeRect(const TRect& aRect, const TGopFadeParams aFade)
1063 : TGraphicsOperation(EFadeRect,sizeof(*this)), iRect(aRect), iFade(aFade) {}
1066 /** The rectangle to fade. */
1069 /** The fade parameters. */
1070 TGopFadeParams iFade;
1074 An accelerated graphics operation that copies a rectangular region of one bitmap
1077 The data members are all initialised on construction. Objects of this class
1078 can be passed to a graphics accelerator's Operation() function either individually,
1083 class TGopBitBlt : public TGraphicsOperation
1086 /** Constructor with a position, a source bitmap handle and a rectangle.
1087 @param aDestination The destination for the top left hand corner of the portion
1088 of the source bitmap.
1089 @param aSourceBitmap A handle to the source bitmap, and other information needed
1091 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1092 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1093 inline TGopBitBlt(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1094 : TGraphicsOperation(EBitBlt,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1097 /** The destination for the top left hand corner of the portion of the source bitmap. */
1098 TPoint iDestination;
1100 /** A handle to the source bitmap, and other information needed to draw it. */
1101 TAcceleratedBitmapSpec iSourceBitmap;
1103 /** A rectangle defining all or a part of the bitmap to be copied. */
1108 An accelerated graphics operation that copies a rectangular region of one bitmap
1109 into another, using a third bitmap as a mask.
1111 The mask must be the same size as the source bitmap. The parts of the source
1112 bitmap that are drawn are the areas that are black in the mask.
1114 The data members are all initialised on construction. Objects of this class
1115 can be passed to a graphics accelerator's Operation() function either individually,
1118 @see TGraphicsAcceleratorCaps::iMaskType
1122 class TGopBitBltMasked : public TGraphicsOperation
1125 /** Constructor with a position, a source bitmap handle, a rectangle and a mask bitmap handle.
1126 @param aDestination The destination for the top left hand corner of the portion
1127 of the source bitmap.
1128 @param aSourceBitmap A handle to the source bitmap, and other information needed
1130 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1131 to the top left of the bitmap. Defines the part of the source bitmap to be copied.
1132 @param aMask A handle to the mask bitmap. The parts of the source bitmap
1133 that are drawn are the areas that are black in the mask bitmap. */
1134 inline TGopBitBltMasked(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aMask)
1135 : TGraphicsOperation(EBitBltMasked,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iMask(aMask) {}
1138 /** The destination for the top left hand corner of the portion of the bitmap. */
1139 TPoint iDestination;
1141 /** A handle to the source bitmap, and other information needed to draw it. */
1142 TAcceleratedBitmapSpec iSourceBitmap;
1144 /** A rectangle defining all or a part of the bitmap to be copied. */
1147 /** A handle to the source bitmap mask. */
1148 TAcceleratedBitmapSpec iMask;
1152 An accelerated graphics operation that copies a rectangular region of one bitmap
1153 into another, with some transparent pixels in the bitmap.
1155 The data members are all initialised on construction. Objects of this class
1156 can be passed to a graphics accelerator's Operation() function either individually,
1159 @see TGraphicsAcceleratorCaps::iTransparency
1160 @see TGopTransparency
1164 class TGopBitBltTransparent : public TGraphicsOperation
1167 /** Constructor with a destination, a handle to the source bitmap, a rectangle
1168 and a specification for which pixels should be treated as transparent.
1170 @param aDestination The destination for the top left hand corner of the portion
1171 of the source bitmap.
1172 @param aSourceBitmap A handle to the source bitmap, and other information needed
1174 @param aSourceRect A rectangle within the source bitmap. Its coordinates are
1175 relative to the top left of the bitmap. Defines the part of the source bitmap to
1177 @param aTransparency A specification for which pixels in the source bitmap should
1178 be treated as transparent. */
1179 inline TGopBitBltTransparent(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TGopTransparency aTransparency)
1180 : TGraphicsOperation(EBitBltTransparent,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iTransparency(aTransparency) {}
1183 /** The destination for the top left hand corner of the portion of the bitmap. */
1184 TPoint iDestination;
1186 /** A handle to the source bitmap, and other information needed to draw it. */
1187 TAcceleratedBitmapSpec iSourceBitmap;
1189 /** A rectangle defining all or a part of the bitmap to be copied. */
1192 /** A specification for which pixels should be treated as transparent. */
1193 TGopTransparency iTransparency;
1197 An accelerated graphics operation that copies a rectangular region of one bitmap
1198 into another, using alpha blending.
1200 The alpha value is part of each pixel in the source bitmap. For instance,
1201 a 32 bits per pixel bitmap may have 8 bits for each of the alpha, red, green
1204 Supported bitmap formats with an alpha-channel are given in by
1205 TGraphicsAcceleratorCaps::iAlphaChannel.
1207 The data members are all initialised on construction. Objects of this class
1208 can be passed to a graphics accelerator's Operation() function either individually,
1211 @see TGraphicsAcceleratorCaps::iAlphaChannel
1215 class TGopBitBltAlphaChannel : public TGraphicsOperation
1218 /** Constructor with a position, a bitmap handle and a rectangle.
1219 @param aDestination The destination for the top left hand corner of the portion
1220 of the source bitmap.
1221 @param aSourceBitmap A handle to the source bitmap, and other information needed
1223 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1224 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1225 inline TGopBitBltAlphaChannel(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1226 : TGraphicsOperation(EBitBltAlphaChannel,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1229 /** The destination for the top left hand corner of the portion of the bitmap. */
1230 TPoint iDestination;
1232 /** A handle to the source bitmap, and other information needed to access it. */
1233 TAcceleratedBitmapSpec iSourceBitmap;
1235 /** A rectangle defining all or a part of the bitmap to be copied. */
1240 An accelerated graphics operation that copies a rectangular region of one bitmap
1241 into another using alpha blending values provided in a third bitmap.
1243 The way alpha blending works is as follows: if the alpha value is the maximum,
1244 the source pixel is opaque, in other words, the full colour of the pixel is
1245 written to the destination. If the alpha value is zero, the source pixel is
1246 fully transparent, and the destination is left unaltered. Values in-between
1247 cause blending with the following formula:
1249 Destination = Source*Alpha/max_Alpha + Destination*(max_Alpha-Alpha)/max_Alpha
1251 Colour alpha-bitmaps specify red, green and blue alpha values for each pixel,
1252 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1253 alpha value depends on the bitmap's display mode. For example, 255 is the
1254 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1255 which use fewer bits per colour component.
1257 Supported bitmap formats than can be used as alpha bitmaps are given in
1258 TGraphicsAcceleratorCaps::iAlphaBitmap.
1260 Objects of this class can be passed to a graphics accelerator's Operation()
1261 function either individually, or in a buffer.
1263 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1267 class TGopBitBltAlphaBitmap : public TGraphicsOperation
1270 /** Constructor with a position, two bitmap specs and a rectangle.
1271 @param aDestination The destination for the top left hand corner of the portion
1272 of the source bitmap.
1273 @param aSourceBitmap A handle to the source bitmap, and other information needed
1275 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1276 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1277 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1278 alpha blending values. */
1279 inline TGopBitBltAlphaBitmap(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aAlphaBitmap)
1280 : TGraphicsOperation(EBitBltAlphaBitmap,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iAlphaBitmap(aAlphaBitmap) {}
1283 /** The destination for the top left hand corner of the portion of the source bitmap. */
1284 TPoint iDestination;
1286 /** A handle to the source bitmap, and other information needed to access it. */
1287 TAcceleratedBitmapSpec iSourceBitmap;
1289 /** A rectangle defining the part of the source bitmap to be copied. */
1292 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1293 TAcceleratedBitmapSpec iAlphaBitmap;
1297 An accelerated graphics operation that copies a rectangular region of two bitmaps
1298 to a destination, using alpha blending values provided in a third bitmap to blend the
1299 corresponding entries in the first and second bitmaps.
1301 The way alpha blending works is as follows: if the alpha value is the maximum,
1302 the pixel from the first source is opaque, in other words, the full colour of
1303 the pixel is written to the destination. If the alpha value is zero, the pixel
1304 from the first source is fully transparent, in other words, the full colour of
1305 the pixel in the second source is used. Values in-between cause blending with
1306 the following formula:
1308 Destination = Source1*Alpha/max_Alpha + Source2*(max_Alpha-Alpha)/max_Alpha
1310 Colour alpha bitmaps specify red, green and blue alpha values for each pixel,
1311 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1312 alpha value depends on the bitmap's display mode. For example, 255 is the
1313 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1314 which use fewer bits per colour component.
1316 Supported bitmap formats than can be used as alpha bitmaps are given in
1317 TGraphicsAcceleratorCaps::iAlphaBitmap.
1319 Objects of this class can be passed to a graphics accelerator's Operation()
1320 function either individually, or in a buffer.
1322 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1326 class TGopAlphaBlendTwoBitmaps : public TGraphicsOperation
1330 Constructor with a position, three bitmap specs and a rectangle.
1331 @param aDestination The destination for the top left hand corner of the portion
1332 of the source bitmaps.
1333 @param aSourceBmp1 A handle to the first of the source bitmaps, and other information
1335 @param aSourceBmp2 A handle to the second of the source bitmaps, and other information
1337 @param aSourceRect A rectangle within the source bitmaps. Its coordinates are relative
1338 to the top left of the bitmap. Defines the part of the bitmap to be copied.
1339 @param aSourcePt2 The point in the second source bitmap from which we take pixels to blend
1340 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1341 alpha blending values.
1342 @param aAlphaPt The point in the alpha bitmap from which we take pixels to blend
1344 inline TGopAlphaBlendTwoBitmaps(const TPoint& aDestination,TAcceleratedBitmapSpec aSourceBmp1,TAcceleratedBitmapSpec aSourceBmp2,TRect& aSourceRect,const TPoint& aSrcPt2,TAcceleratedBitmapSpec aAlphaBmp, const TPoint& aAlphaPt)
1345 : TGraphicsOperation(EAlphaBlendTwoBitmaps,sizeof(*this)), iDestination(aDestination), iSourceBmp1(aSourceBmp1), iSourceBmp2(aSourceBmp2), iSourceRect(aSourceRect), iSrcPt2(aSrcPt2), iAlphaBmp(aAlphaBmp), iAlphaPt(aAlphaPt) {}
1348 /** The destination for the top left hand corner of the portion of the source bitmaps. */
1349 TPoint iDestination;
1351 /** A handle to the first source bitmap, and other information needed to access it. */
1352 TAcceleratedBitmapSpec iSourceBmp1;
1354 /** A handle to the second source bitmap, and other information needed to access it. */
1355 TAcceleratedBitmapSpec iSourceBmp2;
1357 /** A rectangle defining the part of the source bitmaps to be copied. */
1360 /** The point in the second source bitmap from which we take pixels to blend. */
1363 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1364 TAcceleratedBitmapSpec iAlphaBmp;
1366 /** The point in the alpha bitmap from which we take pixels to blend. */
1371 An accelerated graphics operation that copies a rectangular region of a bitmap blended
1372 with the screen image to the screen, using alpha blending values provided in an alpha bitmap
1373 to blend the corresponding entries in the bitmap and on the screen.
1375 The way alpha blending works is as follows: if the alpha value is the maximum,
1376 the pixel from the source bitmap is opaque, in other words, the full colour of
1377 the pixel is written to the destination. If the alpha value is zero, the pixel
1378 from the source bitmap is fully transparent, in other words, the full colour of
1379 the pixel on the screen is used. Values in-between cause blending with the
1382 Destination = Source*Alpha/max_Alpha + Screen*(max_Alpha-Alpha)/max_Alpha
1384 Colour alpha bitmaps specify red, green and blue alpha values for each pixel,
1385 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1386 alpha value depends on the bitmap's display mode. For example, 255 is the
1387 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1388 which use fewer bits per colour component.
1390 Supported bitmap formats than can be used as alpha bitmaps are given in
1391 TGraphicsAcceleratorCaps::iAlphaBitmap.
1393 Objects of this class can be passed to a graphics accelerator's Operation()
1394 function either individually, or in a buffer.
1396 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1400 class TGopAlphaBlendOneBitmap : public TGraphicsOperation
1404 Constructor with a position, two bitmap specs and a rectangle.
1405 @param aDestination The destination for the top left hand corner of the portion
1406 of the source bitmap.
1407 @param aSourceBmp A handle to the source bitmap, and other information needed
1409 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1410 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1411 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1412 alpha blending values.
1413 @param aAlphaPt The point in the alpha bitmap from which we take pixels to blend
1417 inline TGopAlphaBlendOneBitmap(const TPoint& aDestination,TAcceleratedBitmapSpec aSourceBmp,TRect& aSourceRect,TAcceleratedBitmapSpec aAlphaBmp, const TPoint& aAlphaPt)
1418 : TGraphicsOperation(EAlphaBlendOneBitmap,sizeof(*this)), iDestination(aDestination), iSourceBmp(aSourceBmp), iSourceRect(aSourceRect), iAlphaBmp(aAlphaBmp), iAlphaPt(aAlphaPt) {}
1421 /** The destination for the top left hand corner of the portion of the source bitmap. */
1422 TPoint iDestination;
1424 /** A handle to the source bitmap, and other information needed to access it. */
1425 TAcceleratedBitmapSpec iSourceBmp;
1427 /** A rectangle defining the part of the bitmap to be copied. */
1430 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1431 TAcceleratedBitmapSpec iAlphaBmp;
1433 /** Position of the first pixel in the alpha bitmap to be used for alpha blending. */
1438 An accelerated graphics operation that copies a rectangular region of one bitmap
1439 into a different sized region of another.
1441 The data members are all initialised on construction. Objects of this class
1442 can be passed to a graphics accelerator's Operation() function either individually,
1447 class TGopScaledBitBlt : public TGraphicsOperation
1450 /** Constructor with a destination rectangle, a handle to the source bitmap and
1452 @param aDestination The destination for the portion of the source bitmap. If necessary,
1453 the source bitmap portion is resized to fit into this rectangle.
1454 @param aSourceBitmap A handle to the source bitmap, and other information needed
1456 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1457 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1458 inline TGopScaledBitBlt(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1459 : TGraphicsOperation(EScaledBitBlt,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1462 /** The destination rectangle for the portion of the source bitmap. */
1465 /** A handle to the source bitmap. */
1466 TAcceleratedBitmapSpec iSourceBitmap;
1468 /** A rectangle defining all or a part of the source bitmap to be copied. */
1473 An accelerated graphics operation that copies a rectangular region of one bitmap
1474 into a different sized region of another, using a third bitmap as a mask.
1476 The mask must be the same size as the source bitmap. The parts of the source
1477 bitmap that are drawn are the areas that are black in the mask.
1479 The data members are all initialised on construction. Objects of this class
1480 can be passed to a graphics accelerator's Operation() function either individually,
1483 @see TGraphicsAcceleratorCaps::iMaskType
1487 class TGopScaledBitBltMasked : public TGraphicsOperation
1490 /** Constructor with a source and destination rectangle, and handles to the source
1493 @param aDestination The destination for the portion of the source bitmap. If necessary,
1494 the source bitmap portion is resized to fit into this rectangle.
1495 @param aSourceBitmap A handle to the source bitmap, and other information needed
1497 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1498 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1499 @param aMask A handle to the mask bitmap. */
1500 inline TGopScaledBitBltMasked(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aMask)
1501 : TGraphicsOperation(EScaledBitBltMasked,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iMask(aMask) {}
1504 /** The destination rectangle for the portion of the bitmap. */
1507 /** A handle to the source bitmap. */
1508 TAcceleratedBitmapSpec iSourceBitmap;
1510 /** A rectangle defining all or a part of the source bitmap to be copied. */
1513 /** A handle to the source bitmap mask. */
1514 TAcceleratedBitmapSpec iMask;
1518 An accelerated graphics operation that copies a rectangular region of one bitmap
1519 into a different sized region of another, with some transparent pixels in
1522 The data members are all initialised on construction. Objects of this class
1523 can be passed to a graphics accelerator's Operation() function either individually,
1526 @see TGraphicsAcceleratorCaps::iTransparency
1527 @see TGopTransparency
1531 class TGopScaledBitBltTransparent : public TGraphicsOperation
1534 /** Constructor with destination and source rectangles, a handle to the source
1535 bitmap and a specification for which pixels should be treated as transparent.
1537 @param aDestination The destination for the portion of the source bitmap. If necessary,
1538 the source bitmap portion is resized to fit into this rectangle.
1539 @param aSourceBitmap A handle to the source bitmap, and other information needed
1541 @param aSourceRect A rectangle within the source bitmap. Its coordinates are
1542 relative to the top left of the source bitmap. Defines the part of the source bitmap to
1544 @param aTransparency A specification for which pixels in the source bitmap should be treated as
1546 inline TGopScaledBitBltTransparent(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TGopTransparency aTransparency)
1547 : TGraphicsOperation(EScaledBitBltTransparent,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iTransparency(aTransparency) {}
1550 /** The destination rectangle for the portion of the source bitmap. */
1553 /** A handle to the source bitmap. */
1554 TAcceleratedBitmapSpec iSourceBitmap;
1556 /** A rectangle defining all or a part of the source bitmap to be copied. */
1559 /** A specification for which pixels in the source bitmap should be treated as transparent. */
1560 TGopTransparency iTransparency;
1564 An accelerated graphics operation that copies a rectangular region of one bitmap
1565 into a different sized region of another using alpha blending. The alpha value
1566 is part of each pixel in the source bitmap.
1568 Supported bitmap formats with an alpha-channel are given in by
1569 TGraphicsAcceleratorCaps::iAlphaChannel.
1571 The data members are all initialised on construction. Objects of this class
1572 can be passed to a graphics accelerator's Operation() function either individually,
1575 @see TGraphicsAcceleratorCaps::iAlphaChannel
1579 class TGopScaledBitBltAlphaChannel : public TGraphicsOperation
1582 /** Constructor with a destination rectangle, a handle to the source bitmap and
1585 @param aDestination The destination for the portion of the source bitmap. If necessary,
1586 the source bitmap portion is resized to fit into this rectangle.
1587 @param aSourceBitmap A handle to the source bitmap, and other information needed
1589 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1590 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1591 inline TGopScaledBitBltAlphaChannel(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1592 : TGraphicsOperation(EScaledBitBltAlphaChannel,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1595 /** The destination for the portion of the source bitmap. */
1598 /** A handle to the source bitmap, and other information needed to draw it. */
1599 TAcceleratedBitmapSpec iSourceBitmap;
1601 /** A rectangle defining the part of the source bitmap to be copied. */
1606 An accelerated graphics operation that copies a rectangular region of one bitmap
1607 into a different sized region of another using alpha blending values provided
1610 The data members are all initialised on construction. Objects of this class
1611 can be passed to a graphics accelerator's Operation() function either individually,
1614 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1618 class TGopScaledBitBltAlphaBitmap : public TGraphicsOperation
1621 /** Constructor with a source and destination rectangle and two bitmap handles.
1623 @param aDestination The destination for the portion of the source bitmap. If necessary,
1624 the source bitmap portion is resized to fit into this rectangle.
1625 @param aSourceBitmap A handle to the source bitmap, and other information needed
1627 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1628 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1629 @param aAlphaBitmap A handle to the bitmap that contains alpha blending values. */
1630 inline TGopScaledBitBltAlphaBitmap(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aAlphaBitmap)
1631 : TGraphicsOperation(EScaledBitBltAlphaBitmap,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iAlphaBitmap(aAlphaBitmap) {}
1634 /** The destination for the portion of the bitmap. */
1637 /** A handle to the source bitmap, and other information needed to draw it. */
1638 TAcceleratedBitmapSpec iSourceBitmap;
1640 /** A rectangle defining the part of the source bitmap to be copied. */
1643 /** A handle to the bitmap that contains alpha blending values. */
1644 TAcceleratedBitmapSpec iAlphaBitmap;
1648 An accelerated graphics operation that fills a polygon with a colour.
1650 AddPoints() must be called to specify the polygon to be filled. Objects of
1651 this class can be passed to a graphics accelerator's Operation() function
1652 either individually, or in a buffer.
1654 How a graphics accelerator can fill polygons is given by TGraphicsAcceleratorCaps::iPolygon.
1656 @see TGraphicsAcceleratorCaps::iPolygon
1660 class TGopFilledPolygon : public TGraphicsOperation
1663 /** Constructor with a fill rule and a fill colour. The number of points is initialised
1666 @param aColor The fill colour.
1667 @param aFillRule Bit flags for how self-crossing polygons are filled. */
1668 inline TGopFilledPolygon(TRgb aColor, CGraphicsContext::TFillRule aFillRule)
1669 : TGraphicsOperation(EFilledPolygon,sizeof(*this)), iColor(aColor), iFillRule(aFillRule), iNumPoints(0) {}
1670 inline void AddPoints(TInt aNumPoints, TPoint* aPoints);
1673 /** The fill colour. */
1676 /** Bit flags for how self-crossing polygons are filled.
1678 @see CGraphicsContext::TFillRule */
1679 CGraphicsContext::TFillRule iFillRule;
1681 /** The number of points in the polygon. */
1685 /** Specifies the polygon to be filled as a number of 2D point coordinates.
1687 AddPoints() should only be called once the TGopFilledPolygon object has been stored
1688 into a buffer. There must be enough room in the buffer after the TGopFilledPolygon
1689 object to hold aNumPoints TPoint sized structures. This is because the points are
1690 copied into the memory space directly following the TGopFilledPolygon object.
1692 @param aNumPoints The number of points in the polygon.
1693 @param aPoints Pointer to the first point in the polygon. */
1694 inline void TGopFilledPolygon::AddPoints(TInt aNumPoints, TPoint* aPoints)
1695 { Append(aNumPoints*sizeof(TPoint),aPoints); iNumPoints += aNumPoints; }
1698 An accelerated graphics operation that fills a polygon with a pattern held
1701 AddPoints() must be called to specify the polygon to be filled. Objects of
1702 this class can be passed to a graphics accelerator's Operation() function
1703 either individually, or in a buffer.
1705 @see TGraphicsAcceleratorCaps::iPolygon
1706 @see TGopFillPattern
1710 class TGopFilledPolygonWithPattern : public TGraphicsOperation
1713 /** Constructor with a fill pattern and a fill rule. The number of points is initialised
1716 @param aPattern The fill pattern.
1717 @param aFillRule Bit flags for how self-crossing polygons are filled. */
1718 inline TGopFilledPolygonWithPattern(TGopFillPattern aPattern, CGraphicsContext::TFillRule aFillRule)
1719 : TGraphicsOperation(EFilledPolygonWithPattern,sizeof(*this)), iPattern(aPattern), iFillRule(aFillRule), iNumPoints(0) {}
1720 inline void AddPoints(TInt aNumPoints, TPoint* aPoints);
1723 /** The pattern of bitmaps that is used to fill the polygon. */
1724 TGopFillPattern iPattern;
1726 /** Bit flags for how self-crossing polygons are filled.
1728 @see CGraphicsContext::TFillRule */
1729 CGraphicsContext::TFillRule iFillRule;
1731 /** The number of points in the polygon. */
1735 /** Specifies the polygon to be filled as a number of 2D point coordinates.
1737 AddPoints() should only be called once the TGopFilledPolygonWithPattern object has been stored
1738 into a buffer. There must be enough room in the buffer after the TGopFilledPolygonWithPattern
1739 object to hold aNumPoints TPoint sized structures. This is because the points are
1740 copied into the memory space directly following the TGopFilledPolygonWithPattern object.
1742 @param aNumPoints The number of points in the polygon.
1743 @param aPoints Pointer to the first point in the polygon. */
1744 inline void TGopFilledPolygonWithPattern::AddPoints(TInt aNumPoints, TPoint* aPoints)
1745 { Append(aNumPoints*sizeof(TPoint),aPoints); iNumPoints += aNumPoints; }