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 "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.
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
45 /** The display mode of the bitmap. */
46 TDisplayMode iDisplayMode;
48 /** The address of the start of the bitmap. */
51 /** The width and height of the bitmap in pixels. */
54 /** The address offset (in bytes) between successive lines in a bitmap.
55 If the bitmap is compressed the line pitch has no meaning so this data
56 member is set to the negation of the compression type. In the case of
57 an extended bitmap it is -EProprietaryCompression. */
60 /** The shift required to obtain the number of bits needed to represent one pixel
61 in the bitmap. The number of bits per pixel is calculated as 1 << iPixelShift.
62 In the case of an extended bitmap this data member is set to the bitmap type UID. */
67 /** The physical address of the start of the bitmap. This is the address which a
68 hardware graphics accelerator will use and is zero if the bitmap is not accessible
69 to hardware graphics accelerators. Invalid in the case of an extended bitmap. */
70 TUint8* iPhysicalAddress;
71 /** In the case of an extended bitmap, the size of the raw bitmap data. */
77 The interface to a hardware bitmap.
79 This is a bitmap that can be drawn to by graphics acceleration hardware. It
80 is stored in a contiguous area of physical memory.
82 After creating the hardware bitmap, it can be passed to CHardwareGraphicsAccelerator::NewL().
84 @see CHardwareGraphicsAccelerator::NewL()
90 friend class CBitwiseBitmap;
91 friend class CFbsScreenDevice;
94 /** Default constructor. */
95 inline RHardwareBitmap();
97 /** Constructor taking the handle of an existing RHardwareBitmap to duplicate it. */
98 inline RHardwareBitmap(TInt aHandle);
101 Gets the information needed for accessing a bitmap directly into TAcceleratedBitmapInfo structure.
103 @param aInfo On return, holds the information needed to directly access the bitmap.
104 @return KErrNone if sucessful, otherwise one of the system error codes, including
105 KErrUnknown if the object's type is ENoBitmap.
107 IMPORT_C TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const;
109 IMPORT_C TInt SetAsScreenReference(TInt aScreen=-1);
110 IMPORT_C TInt Create(TDisplayMode aDisplayMode, TSize aSize, TUid aCreatorUid);
111 IMPORT_C void Destroy();
114 /** The bitmap's handle; assigned during construction. This is used to identify
116 TInt iHandle; // Must be only member data
119 /** Default constructor. Initialises the handle to zero. */
120 inline RHardwareBitmap::RHardwareBitmap()
124 /** Constructor taking the handle of an existing RHardwareBitmap to duplicate.
125 @param aHandle The RHardwareBitmap handle to duplicate. */
126 inline RHardwareBitmap::RHardwareBitmap(TInt aHandle)
131 Maintains a count of the number of locks made on a bitmap through a TAcceleratedBitmapSpec
134 Passed as a parameter to TAcceleratedBitmapSpec::Lock() and TAcceleratedBitmapSpec::Unlock().
136 @see TAcceleratedBitmapSpec
140 class TBitmapLockCount
142 friend class TAcceleratedBitmapSpec;
145 /** Default constructor. Initialises the lock count to zero. */
146 inline TBitmapLockCount() : iCount(0) {}
148 inline TInt Inc() { return iCount++; }
149 inline TInt Dec() { return --iCount; }
156 A utility class that provides access to the contents of a bitmap.
158 The bitmap can be a hardware bitmap (RHardwareBitmap), or an ordinary bitmap
159 (CFbsBitmap). An object of this class is used as a parameter by several accelerated
160 graphics operations, e.g. TGopBitBlt, to specify the source bitmap for the
165 class TAcceleratedBitmapSpec
169 inline TAcceleratedBitmapSpec();
170 IMPORT_C TAcceleratedBitmapSpec(CFbsBitmap* aBitmap);
171 IMPORT_C TAcceleratedBitmapSpec(RHardwareBitmap aBitmap);
172 // Bitmap access (use with caution, see documentation)
174 IMPORT_C TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const;
175 inline void Lock(TBitmapLockCount& aCount);
176 inline void Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo);
177 inline void Unlock(TBitmapLockCount& aCount);
180 /** Identifies the type of the bitmap.
182 Type() returns this value.
185 enum TAcceleratedBitmapType
187 /** The object was created using the default constructor, and has no type. */
190 /** The bitmap is of type CFbsBitmap.
195 /** The bitmap is of type RHardwareBitmap.
197 @see RHardwareBitmap */
200 enum TAcceleratedBitmapLock
206 inline TAcceleratedBitmapType Type() const;
207 inline TInt Handle() const;
209 IMPORT_C void DoLock(TBitmapLockCount& aCount);
210 IMPORT_C void DoLock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo);
211 IMPORT_C void DoUnlock(TBitmapLockCount& aCount);
213 TUint8 iType; // TAcceleratedBitmapType
214 TUint8 iLockStatus; // TAcceleratedBitmapLock
220 /** Default constructor.
221 Use one of the other constructor overloads instead. */
222 inline TAcceleratedBitmapSpec::TAcceleratedBitmapSpec()
223 : iType(ENoBitmap), iLockStatus(EBitmapIsStatic)
226 /** Prevents a bitmap from moving in memory. Lock() should be called before accessing
227 the bitmap and Unlock() immediately afterwards. Although it is not necessary
228 to lock and unlock some types of bitmap, it is a small overhead, and it is
229 recommended that you always do it.
231 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
232 within the same thread must use the same TBitmapLockCount object, even if
233 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
235 @param aCount Maintains a count of the number of locks made on the bitmap. */
236 inline void TAcceleratedBitmapSpec::Lock(TBitmapLockCount& aCount)
237 { if(iLockStatus==EBitmapNeedsLocking) DoLock(aCount); }
239 /** Prevents a bitmap from moving in memory. Lock() should be called before accessing
240 the bitmap and Unlock() immediately afterwards. Although it is not necessary
241 to lock and unlock some types of bitmap, it is a small overhead, and it is
242 recommended that you always do it. Also updates a TAcceleratedBitmapInfo structure
243 with any information that may have changed, (typically the bitmap's memory
246 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
247 within the same thread must use the same TBitmapLockCount object, even if
248 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
250 @param aCount Maintains a count of the number of locks made on the bitmap.
251 @param aInfo On return, contains the new address of the start of the bitmap. */
252 inline void TAcceleratedBitmapSpec::Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo)
253 { if(iLockStatus==EBitmapNeedsLocking) DoLock(aCount,aInfo); }
255 /** Frees a bitmap after a call to Lock(). A call to Unlock() must be made for each corresponding
256 call to Lock(). This function should be called as soon as any bitmap access has finished. If, after
257 the Unlock() operation, no more calls to Lock() are outstanding on the bitmap, the bitmap is free to
258 be moved in memory again.
260 If a bitmap is already locked, all uses of the Lock() and Unlock() methods
261 within the same thread must use the same TBitmapLockCount object, even if
262 Lock() and Unlock() are called by different instances of TAcceleratedBitmapSpec.
264 @param aCount Maintains a count of the number of locks made on the bitmap. */
265 inline void TAcceleratedBitmapSpec::Unlock(TBitmapLockCount& aCount)
266 { if(iLockStatus==EBitmapNeedsLocking) DoUnlock(aCount); }
268 /** Returns the type of the bitmap. The type is assigned during construction.
270 @return The type of bitmap. */
271 inline TAcceleratedBitmapSpec::TAcceleratedBitmapType TAcceleratedBitmapSpec::Type() const
272 { return (TAcceleratedBitmapSpec::TAcceleratedBitmapType)iType; }
274 /** Returns the handle to the bitmap.
276 @return The handle to the bitmap. */
277 inline TInt TAcceleratedBitmapSpec::Handle() const
281 // Accelerator capabilities
286 Enumerates the four transparency types.
288 ETransparentPixel and ETransparentColor are used with a pixel value or a TRgb
291 @see TGopTransparency
292 @see TGraphicsAcceleratorCaps::iTransparency
296 enum TTransparencyType
299 /** Any pixel that has all bits equal to zero is treated as transparent. */
300 ETransparentPixelZero,
302 /** Any pixel that is equal to the pixel value passed to the TGopTransparency constructor
303 is treated as transparent. */
306 /** Any pixel that is equal to the TRgb value passed to the TGopTransparency constructor
307 is treated as transparent. */
310 /** In 16 bits per pixel display mode, which uses 5 bits each for red, green and
311 blue, the most significant bit is an Alpha value. Alpha=0 means the pixel
312 is transparent, Alpha=1 means the pixel is fully opaque. */
317 Stores the capabilities of a graphics accelerator.
319 All of the member enums except TMaskBitmapCaps define flags that are stored
320 as public data of type TUint. Only TMaskBitmapCaps takes sequential values,
321 so its values are mutually exclusive.
323 An object of this class is returned by CGraphicsAccelerator::Capabilities()
324 or by GenericCapabilities(), which is implemented by CSoftwareGraphicsAccelerator
325 and CHardwareGraphicsAccelerator.
327 @see CGraphicsAccelerator::Capabilities()
331 class TGraphicsAcceleratorCaps
334 /** Clipping capabilities. Used by the iClipping member.
336 @see CGraphicsAccelerator::Operation() */
337 enum TClipCaps // Bit flags
339 EClipToBitmap = 1, // Will always clip all operations to the bitmap
341 /** The accelerator supports the Operation() methods which take clipping rectangles
344 @see CGraphicsAccelerator::Operation() */
345 EClipping = 2 // Is able to clip operations to a region
348 /** Enumerates the capabilities relating to operations taking a bitmap mask parameter,
349 for instance TGopBitBltMasked. These are mutually exclusive values used by
350 the iMaskType member. */
351 enum TMaskBitmapCaps // Enum
353 /** No masked operations are supported. */
356 /** The mask bitmap can be in any display mode at all. */
357 EMaskBitmapAnyDisplayMode,
359 /** The mask bitmap must be in the same display mode as the destination bitmap. */
360 EMaskBitmapMatchingDisplayMode,
362 /** The mask bitmap must be in EGray2 display mode. */
366 /** Bit flags for the capabilities relating to operations that use an alpha channel
367 (TGopBitBltAlphaChannel and TGopScaledBitBltAlphaChannel). These flags are
368 used by the iAlphaChannel member. */
369 enum TAlphaChannelCaps //Bit flags
371 /** The accelerator can draw bitmaps with 4 bits each for the alpha value and the
372 red, green and blue components. */
373 EAlpha4444 = 1, // Bitmaps with 4 bits for Alpha value and Red, Green, Blue components
375 /** The accelerator can draw bitmaps with 8 bits each for the alpha value and the
376 red, green and blue components. */
377 EAlpha8888 = 2, // Bitmaps with 8 bits for Alpha value and Red, Green, Blue components
379 /** The accelerator can draw bitmaps with 1 bit for the alpha value and and 5 bits
380 for the red, green and blue components. */
381 EAlpha1555 = 4, // Bitmaps with 1 bit for Alpha value and 5 bits for Red, Green, and Blue
384 /** Bit flags for the capabilities relating to operations which take an alpha bitmap
385 parameter, for instance TGopBitBltAlphaBitmap. These flags are used by the
386 iAlphaBitmap member. */
387 enum TAlphaBitmapCaps //Bit flags
389 /** For 256 greyscale bitmaps, the value of each pixel in the alpha bitmap (from
390 0 to 255) is used as the alpha value. */
391 EAlphaBitmapGray256 = 1,
393 /** An EColor16M bitmap may be used as the alpha bitmap. The red, green and blue
394 values for each pixel in this bitmap are used as the alpha values for the
395 red, green and blue components of the corresponding pixel in the source bitmap. */
396 EAlphaBitmapColor16M = 2,
398 /** The alpha bitmap must have the same display mode as the source bitmap. */
399 EAlphaBitmapMatchingMode = 4, // Alpha bitmap must be same mode as source
402 /** Indicates whether there is a restriction on the sizes of bitmaps that can be
403 used in bitmap patterns.
405 This is one of the possible values for the iPatternSizes member.
407 @see TGopFillPattern */
408 enum TPatternSizeCaps //Bit flags
410 /** There is no restriction on the dimensions of bitmap patterns. */
411 EPatternSizeAny = 0xFFFFFFFF,
414 /** Bit flags for the capabilities relating to operations that draw a fill pattern
415 using a bitmap, for instance TGopFilledRectWithPatern. They are used in the
417 enum TPatternCaps //Bit flags
419 /** The pattern bitmap can be in any display mode. */
420 EPatternAnyDisplayMode = 1, // Patterns can be in any supported display mode
422 /** The pattern bitmap must be in the same display mode as the destination. */
423 EPatternMatchingDisplayMode = 2, // Pattern must be in same displ mode as target
425 /** The pattern bitmap must be square (width==height). */
426 EPatternMustBeSquare = 4, // The pattern must be square (width==height)
429 /** Bit flags for how self-crossing polygons are filled.
431 @see CGraphicsContext::TFillRule */
432 enum TPolygonCaps // Bit flags for fill rules (see CGraphicsContext::TFillRule)
434 /** Only areas with odd winding numbers are filled. */
435 EPolygonFillAlternate = 1,
437 /** All areas with a winding number greater than zero are filled.
439 @see CGraphicsContext::TFillRule */
440 EPolygonFillWinding = 2,
444 /** Bit flags for the specifying the supported rendering orientations.
445 @see CFbsBitGc::TGraphicsOrientation */
446 enum TOrientationCaps
448 /** Normal orientation is supported. */
449 EOrientationCapNormal = 1,
450 /** A 90 degree rotation is supported. */
451 EOrientationCapRotated90 = 2,
452 /** A 180 degree rotation is supported. */
453 EOrientationCapRotated180 = 4,
454 /** A 270 degree rotation is supported. */
455 EOrientationCapRotated270 = 8,
456 /** All orientations are supported. */
457 EOrientationCapAll = EOrientationCapNormal|EOrientationCapRotated90|EOrientationCapRotated180|EOrientationCapRotated270
460 /** The size of this class in bytes. */
461 TInt iStructureSize; // The size of this class
463 /** The version number of the API. */
464 TInt iVersion; // == 1 to specify current API
466 /** Optional UID to identify the vendor of the graphics accelerator. This UID can
467 be used to recognise a particular accelerator, enabling code to use any custom
468 graphics operations and capabilities that it knows the accelerator provides. */
469 TUid iVendorUid; // Optional ID
471 /** A bit mask of the supported display modes for the bitmap passed to the graphics
472 accelerator's NewL(). Uses the least significant 11 bits as flags for each
473 TDisplayMode supported. For instance, to check whether the EColor256 display
474 mode is available, use the expression iDisplayModes & (1 << EColor256).
477 TUint iDisplayModes; // One bit for each TDisplayMode enumeration
479 /** Indicates whether the Operation() methods which take clipping rectangles as
480 parameters are supported.
483 TUint iClipping; // TClipCaps bit flags
485 /** Specifies the display mode restrictions for bitmap masks. These are mutually
488 @see TMaskBitmapCaps */
489 TMaskBitmapCaps iMaskType; // Mask type used
491 /** Specifies the transparency types supported. Uses a bit flag for each TTransparencyType
494 @see TTransparencyType */
495 TUint iTransparency; // Bit flag for each TTransparencyType supported
497 /** Specifies the capabilities relating to operations that use an alpha channel. Uses a bit flag for
498 each TAlphaChannelCaps supported.
500 @see TAlphaChannelCaps */
501 TUint iAlphaChannel; // TAlphaChannelCaps bit flags
503 /** Specifies the supported alpha bitmap types. Uses a bit flag for each TAlphaBitmapCaps
506 @see TAlphaBitmapCaps */
507 TUint iAlphaBitmap; // TAlphaBitmapCaps bit flags
509 /** Specifies the sizes of bitmaps that can be used in bitmap patterns.
511 This is a bitmask for each power of 2, or EPatternSizeAny. For example, if
512 bitmaps used in patterns can only have a width or height of 16 pixels then
513 this value should be set to 16. If patterns can have dimensions of 16, 32,
514 64, 128 or 256, then this value would equal the sum of these, (i.e. bits 4,
515 5, 6, 7 and 8 would be set). If this value is equal to EPatternSizeAny, there
516 are no restrictions on the size of patterns that can be used.
518 @see TPatternSizeCaps */
519 TUint iPatternSizes; // a mask bit for each power of 2, or EPatternSizeAny
521 /** Specifies the supported bitmap types for fill patterns. Uses a bit flag for
522 each TPatternCaps supported.
525 TUint iPattern; // TPatternCaps bit flags
527 /** Specifies the supported fill rules for self crossing polygons. Uses a bit flag
528 for each TPolygonCaps supported.
531 TUint iPolygon; // TPolygonCaps bit flags
534 iReserved[0] specifies the supported rendering orientations.Uses a bit flags
535 for each TOrientationCaps supported.
536 @see TOrientationCaps
537 iReserved[1]-iReserved[3] are reserved for future use. All should be set to zero.
544 // TGraphicsOperation
548 Abstract base class for all graphics operations.
550 Derived classes encapsulate all the arguments needed by a given graphics operation.
551 An object of one of the derived classes is passed as a parameter to CGraphicsAccelerator::Operation().
552 The member functions and enum defined in this class are not used directly
555 @see CGraphicsAccelerator::Operation()
559 class TGraphicsOperation
563 { // Require arguments commented below here
565 EFilledRect, // (TRect,TRgb)
566 EFilledRectUsingDrawMode, // (TRect,TRgb,CGraphicsContext:TDrawMode)
567 EFilledRectWithPattern, // (TRect,TGopFillPattern)
568 EInvertRect, // (TRect)
569 EFadeRect, // (TRect,TGopFadeParams)
571 EBitBlt, // (TPoint,TAcceleratedBitmapSpec,TRect&)
572 EBitBltMasked, // (TPoint,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aMask)
573 EBitBltTransparent, // (TPoint,TAcceleratedBitmapSpec,TRect&,TGopTransparency)
574 EBitBltAlphaChannel, // (TPoint,TAcceleratedBitmapSpec,TRect&)
575 EBitBltAlphaBitmap, // (TPoint,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aAlpha)
577 EScaledBitBlt, // (TRect,TAcceleratedBitmapSpec,TRect&)
578 EScaledBitBltMasked, // (TRect,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aMask)
579 EScaledBitBltTransparent, // (TRect,TAcceleratedBitmapSpec,TRect&,TGopTransparency)
580 EScaledBitBltAlphaChannel, // (TRect,TAcceleratedBitmapSpec,TRect&)
581 EScaledBitBltAlphaBitmap, // (TRect,TAcceleratedBitmapSpec,TRect&,TAcceleratedBitmapSpec aAlpha)
583 EFilledPolygon, // (TRGb aColor,CGraphicsContext::TFillRule aFillRule,TInt aNumPoints,TPoint[])
584 EFilledPolygonWithPattern, // (TGopFillPattern,CGraphicsContext::TFillRule aFillRule,TInt aNumPoints,TPoint[])
585 EAlphaBlendTwoBitmaps, // (TPoint,TAcceleratedBitmapSpec aSrce1,TAcceleratedBitmapSpec aSrce2,TRect&,TAcceleratedBitmapSpec aAlpha)
586 EAlphaBlendOneBitmap, // (TPoint,TAcceleratedBitmapSpec aSrce,TRect&,TAcceleratedBitmapSpec aAlpha)
592 inline TGopFunction Function() const { return iFunction; }
593 inline TInt Size() const { return iSize; }
595 inline TGraphicsOperation* Next() const;
596 inline void Append(TInt aNumBytes,TAny* aData);
598 inline TGraphicsOperation(TGopFunction aFunction, TInt aArgSize);
599 inline TGraphicsOperation() {}
601 TGopFunction iFunction;
602 TInt iSize; // Total size of derived class
605 inline TGraphicsOperation::TGraphicsOperation(TGopFunction aFunction, TInt aSize)
606 : iFunction(aFunction) , iSize(aSize) {}
608 inline TGraphicsOperation* TGraphicsOperation::Next() const
609 { return (TGraphicsOperation*)((TUint8*)this+iSize); }
611 inline void TGraphicsOperation::Append(TInt aNumBytes,TAny* aData)
613 Mem::Copy(Next(),aData,aNumBytes);
619 // Graphics accelerator
623 Abstract base class for 2D graphics accelerators.
625 This class can be derived from to provide accelerated implementations of some
626 common 2D graphics algorithms. Support for accelerated 2D graphics has been
627 integrated into existing classes in the Graphics API for instance CFbsBitGc,
628 so that existing code does not need to be altered, but a graphics accelerator
629 can be used directly by applications. The accelerated 2D graphics operations
630 may be implemented in software, hardware, or both.
634 class CGraphicsAccelerator : public CBase
637 // Return the capabilities of this accelerator
639 /** Returns the capabilities of the graphics accelerator.
641 @return The capabilities of the accelerator. */
642 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
644 // Perform a graphics operation
646 /** Requests the graphics accelerator to perform a single graphics operation.
648 @param aOperation An instance of a TGraphicsOperation-derived class that identifies
649 the graphics operation to be performed.
650 @return KErrNone if successful, otherwise one of the system error codes. The
651 function should return KErrNotSupported if the accelerator does not support
652 the requested operation. */
653 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
655 /** Requests the graphics accelerator perform a single graphics operation within
656 a clipping region. This version is of Operation() is only usable if the
657 accelerator capabilities returned by Capabilities() indicate that clipping to a region
660 @param aOperation An instance of a TGraphicsOperation-derived class that identifies
661 the graphics operation to be performed.
662 @param aNumClipRects The number of rectangles in the clipping region.
663 @param aClipRects A pointer to the first rectangle in the clipping region.
664 @return KErrNone if successful, otherwise one of the system error codes. The
665 function should return KErrNotSupported if the accelerator does not support
666 the requested operation.
667 @see TGraphicsAcceleratorCaps::iClipping */
668 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
670 // Process a buffer of TGraphicsOperation. (Each operation immediately follows the
671 // one preceding it in the buffer)
673 /** Requests the graphics accelerator perform one or more graphics operations contained
676 The underlying implementation may be able to process a group of graphics operations
677 more efficiently than if Operation() was called for each individually.
679 This function should be implemented as if Operation() was called in turn for
680 each operation contained in the buffer. Each operation should be carried out
681 immediately after the one preceding it. If a method returns an error, the
682 length of aBuffer should be set to indicate the number of operations that
683 have been successfully processed. In this case, the operation in which the
684 error occurred will be indicated by the memory address &aBuffer[aBuffer.Length()].
686 @param aBuffer A descriptor which holds a concatenation of graphics operations
687 (TGraphicsOperation-derived objects).
688 @return KErrNone if successful, otherwise one of the system error codes. The
689 function should return KErrNotSupported if the accelerator does not support
690 any of the requested operations. */
691 virtual TInt Operation(TDes8& aBuffer) = 0;
693 /** Requests the graphics accelerator perform one or more graphics operations within
694 a clipping region. This version is of Operation() is only usable if the
695 accelerator capabilities returned by Capabilities() indicate that clipping to a region
698 The underlying implementation may be able to process a group of graphics operations
699 more efficiently than if Operation() was called for each individually.
701 This function should be implemented as if Operation() was called in turn for
702 each operation contained in the buffer. Each operation should be carried out
703 immediately after the one preceding it. If a method returns an error, the
704 length of aBuffer should be set to indicate the number of operations that
705 have been successfully processed. In this case, the operation in which the
706 error occurred will be indicated by the memory address &aBuffer[aBuffer.Length()].
708 @param aBuffer A descriptor which holds a concatenation of graphics operations
709 (TGraphicsOperation objects).
710 @param aNumClipRects The number of rectangles in the clipping region.
711 @param aClipRects A pointer to the first rectangle in the clipping region.
712 @return KErrNone if successful, otherwise one of the system error codes. The
713 function should return KErrNotSupported if the accelerator does not support
714 any of the requested operations.
715 @see TGraphicsAcceleratorCaps::iClipping */
716 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
718 // Reserved virtual functions for future use
719 virtual void Reserved_1() = 0;
720 virtual void Reserved_2() = 0;
721 virtual void Reserved_3() = 0;
722 virtual void Reserved_4() = 0;
728 A factory for creating 2D graphics accelerator objects whose graphics operations
729 are implemented in software.
731 Objects of derived classes can write to all types of bitmap, not just hardware
732 bitmaps. Note that graphics accelerators may support only a subset of all
737 class CSoftwareGraphicsAccelerator : public CGraphicsAccelerator
740 // Create a new CSoftwareGraphicsAccelerator for use with a given bitmap
741 IMPORT_C static CSoftwareGraphicsAccelerator* NewL(CFbsBitmap* aBitmap);
743 // Get the non-bitmap-specific capabilities of the hardware accelerator.
744 IMPORT_C static const TGraphicsAcceleratorCaps* GenericCapabilities();
746 // From CGraphicsAccelerator
747 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
748 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
749 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
750 virtual TInt Operation(TDes8& aBuffer) = 0;
751 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
752 // From CGraphicsAccelerator
753 virtual void Reserved_1() = 0;
754 virtual void Reserved_2() = 0;
755 virtual void Reserved_3() = 0;
756 virtual void Reserved_4() = 0;
761 A factory for creating 2D graphics accelerator objects whose graphics operations
762 are implemented in hardware, software or a mixture of both.
764 Objects of derived classes can only write to hardware bitmaps (RHardwareBitmap).
765 Note that graphics accelerators may support only a subset of all graphics
772 class CHardwareGraphicsAccelerator : public CGraphicsAccelerator
776 Create a new CHardwareGraphicsAccelerator for use with a given hardware bitmap.
778 Do not use, link against scdv.lib.
780 @param aBitmap A bitmap that can be drawn by graphics acceleration hardware.
781 It can be any bitmap.
782 @return Reference to hardware graphics accelerator object.
784 IMPORT_C static CHardwareGraphicsAccelerator* NewL(RHardwareBitmap aBitmap);
787 Gets the generic capabilities of the accelerator, including the supported display modes
788 for the bitmap passed to NewL().
790 Do not use, link against scdv.lib.
792 @return Generic capabilities for software graphics accelerators.
794 IMPORT_C static const TGraphicsAcceleratorCaps* GenericCapabilities();
796 // From CGraphicsAccelerator
797 virtual const TGraphicsAcceleratorCaps* Capabilities() = 0;
798 virtual TInt Operation(const TGraphicsOperation& aOperation) = 0;
799 virtual TInt Operation(const TGraphicsOperation& aOperation,TInt aNumClipRects,TRect* aClipRects) = 0;
800 virtual TInt Operation(TDes8& aBuffer) = 0;
801 virtual TInt Operation(TDes8& aBuffer,TInt aNumClipRects,TRect* aClipRects) = 0;
802 // From CGraphicsAccelerator
803 virtual void Reserved_1() = 0;
804 virtual void Reserved_2() = 0;
805 virtual void Reserved_3() = 0;
806 virtual void Reserved_4() = 0;
810 // Classes used as arguments to graphics operations
814 A pattern represented by a bitmap that is used by a graphics accelerator to
815 fill a rectangle or polygon.
817 An object of this class is specified when constructing a TGopFilledRectWithPattern
818 or TGopFilledPolygonWithPattern. The types and sizes of fill pattern bitmaps
819 supported by the accelerator are given by TGraphicsAcceleratorCaps::iPattern
820 and TGraphicsAcceleratorCaps::iPatternSizes respectively.
822 @see TGopFilledRectWithPattern
823 @see TGopFilledPolygonWithPattern
824 @see TGraphicsAcceleratorCaps::iPatternSizes
825 @see TGraphicsAcceleratorCaps::iPattern
829 class TGopFillPattern
833 /** Provides a handle to the bitmap, and other information needed to draw it. */
834 TAcceleratedBitmapSpec iBitmap;
836 /** The origin of the pattern. This is the position at which to draw the pixel at
837 the top left hand corner of the bitmap around which copies of the bitmap are
838 "tiled" to form the pattern. It is relative to the top left hand corner of
839 the rectangle being filled, so specify 0,0 if you want the bitmaps drawn flush
840 with the top and left hand sides of the rectangle. */
845 Specifies the amount of fading for all the pixels in a rectangular area.
847 Fading changes colours so that they are closer to white or closer to black.
848 To make colours whiter, increase iOffset; to use a smaller range of colours,
849 reduce iScale. Fading uses the following formula (where C is a red, green
850 or blue value in a TRgb):
852 colour component C = ( ( iScale * C ) / 256 )+iOffset;
855 - to fade to white, specify iScale=128, iOffset=128
856 - to fade to black, specify iScale=128, iOffset=0
857 - for no change, specify iScale=256, iOffset=0
859 An object of this class is specified when constructing a TGopFadeRect.
865 class TGopFadeParams // color component C = ( ( iScale * C ) >> 8 )+iOffset;
869 /** Specifies the degree of fading, maximum=256. */
872 /** The fading offset. Specifies whether to fade to black or to white. */
877 Specifies which pixels should be treated as transparent in a bitblt operation
878 that supports transparency.
880 This is used by the TGopBitBltTransparent and TGopScaledBitBltTransparent
883 For the possible transparency types, see the TTransparencyType enumeration.
885 An object of this class is specified when constructing a TGopBitBltTransparent or
886 TGopScaledBitBltTransparent.
888 @see TTransparencyType
889 @see TGopBitBltTransparent
890 @see TGopScaledBitBltTransparent
894 class TGopTransparency
898 /** Constructor with a transparency type. iParam is initialised to zero.
900 @param aType The transparency type. */
901 inline TGopTransparency(TTransparencyType aType) : iType(aType), iParam(0) {}
903 /** Constructor with a pixel value. The type is initialised to ETransparentPixel.
904 Any pixel that has a value equal to aPixelValue is treated as transparent.
905 aPixelValue is the bit pattern of the pixel as stored in the bitmap.
907 @param aPixelValue The pixel value. */
908 inline TGopTransparency(TInt aPixelValue) : iType(ETransparentPixel), iParam(aPixelValue) {}
910 /** Constructor with a TRgb value. The type is initialised to ETransparentColor.
911 Any pixel that has a color of aRgb is treated as transparent.
913 @param aRgb The TRgb value. */
914 inline TGopTransparency(TRgb aRgb) : iType(ETransparentColor), iParam(aRgb.Value()) {}
916 /** Gets the colour that is treated as transparent. This is the value of iParam
919 @return The colour that is treated as transparent. */
920 inline TRgb Color() const { return TRgb(iParam); }
922 /** Gets the value of the colour as a TInt that is treated as transparent. This
923 is the value of iParam.
925 @return The colour that is treated as transparent. This is the bit pattern
926 of the colour as stored in the bitmap. */
927 inline TInt Pixel() const { return iParam; }
930 /** The transparency type. */
931 TTransparencyType iType;
933 /** Holds the value of the colour/pixel that is treated as transparent. */
939 // Wrapper classes for graphics operation arguments
943 #pragma warning(disable : 4355) // Disable warning - 'this' : used in base member initializer list
947 An accelerated graphics operation that fills a rectangular area with a colour.
949 The data members are all initialised on construction. Objects of this class
950 can be passed to a graphics accelerator's Operation() function either individually,
955 class TGopFilledRect : public TGraphicsOperation
958 /** Constructor with a rectangle and a colour.
959 @param aRect The rectangle to fill.
960 @param aColor The fill colour. */
961 inline TGopFilledRect(const TRect& aRect,TRgb aColor)
962 : TGraphicsOperation(EFilledRect,sizeof(*this)), iRect(aRect) , iColor(aColor) {}
965 /** The rectangle to fill. */
968 /** The fill colour. */
973 An accelerated graphics operation that fills a rectangular area with a colour,
974 whilst performing a bitwise logical operation with the pixels in the region,
975 for instance AND, OR, Exclusive OR.
977 The bitwise logical operation is specified in the draw mode. The data members
978 are all initialised on construction. Objects of this class can be passed to
979 a graphics accelerator's Operation() function either individually, or in a
984 class TGopFilledRectUsingDrawMode : public TGraphicsOperation
987 /** Constructor with a rectangle, a colour and a draw mode.
988 @param aRect The rectangle to fill.
989 @param aColor The fill colour.
990 @param aDrawMode The draw mode. */
991 inline TGopFilledRectUsingDrawMode(const TRect& aRect,TRgb aColor,CGraphicsContext::TDrawMode aDrawMode)
992 : TGraphicsOperation(EFilledRectUsingDrawMode,sizeof(*this)), iRect(aRect) , iColor(aColor) , iDrawMode(aDrawMode) {}
995 /** The rectangle to fill. */
998 /** The fill colour. */
1001 /** The draw mode. */
1002 CGraphicsContext::TDrawMode iDrawMode;
1006 An accelerated graphics operation that fills a rectangular area with a pattern.
1008 The pattern consists of multiple copies of a bitmap, drawn tiled around an
1009 origin. Objects of this class can be passed to a graphics accelerator's Operation()
1010 function either individually, or in a buffer.
1012 @see TGopFillPattern
1016 class TGopFilledRectWithPattern : public TGraphicsOperation
1019 /** Constructor with a rectangle and a pattern.
1020 @param aRect The rectangle to fill.
1021 @param aPattern Specifies the handle to the bitmap to use for the pattern,
1022 and the origin for the pattern. */
1023 inline TGopFilledRectWithPattern(const TRect& aRect,TGopFillPattern aPattern)
1024 : TGraphicsOperation(EFilledRectWithPattern,sizeof(*this)), iRect(aRect) , iPattern(aPattern) {}
1027 /** The rectangle to fill. */
1030 /** Specifies the handle to the bitmap to use for the pattern and the origin for
1032 TGopFillPattern iPattern;
1036 An accelerated graphics operation that inverts the colour of all pixels in
1039 Objects of this class can be passed to a graphics accelerator's Operation()
1040 function either individually, or in a buffer.
1044 class TGopInvertRect : public TGraphicsOperation
1047 /** Constructor with a rectangle.
1048 @param aRect The rectangle in which to invert the colours. */
1049 inline TGopInvertRect(const TRect& aRect)
1050 : TGraphicsOperation(EInvertRect,sizeof(*this)), iRect(aRect) {}
1053 /** The rectangle in which to invert the colours. */
1058 An accelerated graphics operation that fades the pixels in a rectangular area.
1060 Objects of this class can be passed to a graphics accelerator's Operation()
1061 function either individually, or in a buffer.
1065 class TGopFadeRect : public TGraphicsOperation
1068 /** Constructor with a rectangle and fade parameters.
1069 @param aRect The rectangle to fade.
1070 @param aFade The fade parameters. */
1071 inline TGopFadeRect(const TRect& aRect, const TGopFadeParams aFade)
1072 : TGraphicsOperation(EFadeRect,sizeof(*this)), iRect(aRect), iFade(aFade) {}
1075 /** The rectangle to fade. */
1078 /** The fade parameters. */
1079 TGopFadeParams iFade;
1083 An accelerated graphics operation that copies a rectangular region of one bitmap
1086 The data members are all initialised on construction. Objects of this class
1087 can be passed to a graphics accelerator's Operation() function either individually,
1092 class TGopBitBlt : public TGraphicsOperation
1095 /** Constructor with a position, a source bitmap handle and a rectangle.
1096 @param aDestination The destination for the top left hand corner of the portion
1097 of the source bitmap.
1098 @param aSourceBitmap A handle to the source bitmap, and other information needed
1100 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1101 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1102 inline TGopBitBlt(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1103 : TGraphicsOperation(EBitBlt,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1106 /** The destination for the top left hand corner of the portion of the source bitmap. */
1107 TPoint iDestination;
1109 /** A handle to the source bitmap, and other information needed to draw it. */
1110 TAcceleratedBitmapSpec iSourceBitmap;
1112 /** A rectangle defining all or a part of the bitmap to be copied. */
1117 An accelerated graphics operation that copies a rectangular region of one bitmap
1118 into another, using a third bitmap as a mask.
1120 The mask must be the same size as the source bitmap. The parts of the source
1121 bitmap that are drawn are the areas that are black in the mask.
1123 The data members are all initialised on construction. Objects of this class
1124 can be passed to a graphics accelerator's Operation() function either individually,
1127 @see TGraphicsAcceleratorCaps::iMaskType
1131 class TGopBitBltMasked : public TGraphicsOperation
1134 /** Constructor with a position, a source bitmap handle, a rectangle and a mask bitmap handle.
1135 @param aDestination The destination for the top left hand corner of the portion
1136 of the source bitmap.
1137 @param aSourceBitmap A handle to the source bitmap, and other information needed
1139 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1140 to the top left of the bitmap. Defines the part of the source bitmap to be copied.
1141 @param aMask A handle to the mask bitmap. The parts of the source bitmap
1142 that are drawn are the areas that are black in the mask bitmap. */
1143 inline TGopBitBltMasked(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aMask)
1144 : TGraphicsOperation(EBitBltMasked,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iMask(aMask) {}
1147 /** The destination for the top left hand corner of the portion of the bitmap. */
1148 TPoint iDestination;
1150 /** A handle to the source bitmap, and other information needed to draw it. */
1151 TAcceleratedBitmapSpec iSourceBitmap;
1153 /** A rectangle defining all or a part of the bitmap to be copied. */
1156 /** A handle to the source bitmap mask. */
1157 TAcceleratedBitmapSpec iMask;
1161 An accelerated graphics operation that copies a rectangular region of one bitmap
1162 into another, with some transparent pixels in the bitmap.
1164 The data members are all initialised on construction. Objects of this class
1165 can be passed to a graphics accelerator's Operation() function either individually,
1168 @see TGraphicsAcceleratorCaps::iTransparency
1169 @see TGopTransparency
1173 class TGopBitBltTransparent : public TGraphicsOperation
1176 /** Constructor with a destination, a handle to the source bitmap, a rectangle
1177 and a specification for which pixels should be treated as transparent.
1179 @param aDestination The destination for the top left hand corner of the portion
1180 of the source bitmap.
1181 @param aSourceBitmap A handle to the source bitmap, and other information needed
1183 @param aSourceRect A rectangle within the source bitmap. Its coordinates are
1184 relative to the top left of the bitmap. Defines the part of the source bitmap to
1186 @param aTransparency A specification for which pixels in the source bitmap should
1187 be treated as transparent. */
1188 inline TGopBitBltTransparent(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TGopTransparency aTransparency)
1189 : TGraphicsOperation(EBitBltTransparent,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iTransparency(aTransparency) {}
1192 /** The destination for the top left hand corner of the portion of the bitmap. */
1193 TPoint iDestination;
1195 /** A handle to the source bitmap, and other information needed to draw it. */
1196 TAcceleratedBitmapSpec iSourceBitmap;
1198 /** A rectangle defining all or a part of the bitmap to be copied. */
1201 /** A specification for which pixels should be treated as transparent. */
1202 TGopTransparency iTransparency;
1206 An accelerated graphics operation that copies a rectangular region of one bitmap
1207 into another, using alpha blending.
1209 The alpha value is part of each pixel in the source bitmap. For instance,
1210 a 32 bits per pixel bitmap may have 8 bits for each of the alpha, red, green
1213 Supported bitmap formats with an alpha-channel are given in by
1214 TGraphicsAcceleratorCaps::iAlphaChannel.
1216 The data members are all initialised on construction. Objects of this class
1217 can be passed to a graphics accelerator's Operation() function either individually,
1220 @see TGraphicsAcceleratorCaps::iAlphaChannel
1224 class TGopBitBltAlphaChannel : public TGraphicsOperation
1227 /** Constructor with a position, a bitmap handle and a rectangle.
1228 @param aDestination The destination for the top left hand corner of the portion
1229 of the source bitmap.
1230 @param aSourceBitmap A handle to the source bitmap, and other information needed
1232 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1233 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1234 inline TGopBitBltAlphaChannel(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1235 : TGraphicsOperation(EBitBltAlphaChannel,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1238 /** The destination for the top left hand corner of the portion of the bitmap. */
1239 TPoint iDestination;
1241 /** A handle to the source bitmap, and other information needed to access it. */
1242 TAcceleratedBitmapSpec iSourceBitmap;
1244 /** A rectangle defining all or a part of the bitmap to be copied. */
1249 An accelerated graphics operation that copies a rectangular region of one bitmap
1250 into another using alpha blending values provided in a third bitmap.
1252 The way alpha blending works is as follows: if the alpha value is the maximum,
1253 the source pixel is opaque, in other words, the full colour of the pixel is
1254 written to the destination. If the alpha value is zero, the source pixel is
1255 fully transparent, and the destination is left unaltered. Values in-between
1256 cause blending with the following formula:
1258 Destination = Source*Alpha/max_Alpha + Destination*(max_Alpha-Alpha)/max_Alpha
1260 Colour alpha-bitmaps specify red, green and blue alpha values for each pixel,
1261 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1262 alpha value depends on the bitmap's display mode. For example, 255 is the
1263 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1264 which use fewer bits per colour component.
1266 Supported bitmap formats than can be used as alpha bitmaps are given in
1267 TGraphicsAcceleratorCaps::iAlphaBitmap.
1269 Objects of this class can be passed to a graphics accelerator's Operation()
1270 function either individually, or in a buffer.
1272 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1276 class TGopBitBltAlphaBitmap : public TGraphicsOperation
1279 /** Constructor with a position, two bitmap specs and a rectangle.
1280 @param aDestination The destination for the top left hand corner of the portion
1281 of the source bitmap.
1282 @param aSourceBitmap A handle to the source bitmap, and other information needed
1284 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1285 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1286 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1287 alpha blending values. */
1288 inline TGopBitBltAlphaBitmap(const TPoint& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aAlphaBitmap)
1289 : TGraphicsOperation(EBitBltAlphaBitmap,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iAlphaBitmap(aAlphaBitmap) {}
1292 /** The destination for the top left hand corner of the portion of the source bitmap. */
1293 TPoint iDestination;
1295 /** A handle to the source bitmap, and other information needed to access it. */
1296 TAcceleratedBitmapSpec iSourceBitmap;
1298 /** A rectangle defining the part of the source bitmap to be copied. */
1301 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1302 TAcceleratedBitmapSpec iAlphaBitmap;
1306 An accelerated graphics operation that copies a rectangular region of two bitmaps
1307 to a destination, using alpha blending values provided in a third bitmap to blend the
1308 corresponding entries in the first and second bitmaps.
1310 The way alpha blending works is as follows: if the alpha value is the maximum,
1311 the pixel from the first source is opaque, in other words, the full colour of
1312 the pixel is written to the destination. If the alpha value is zero, the pixel
1313 from the first source is fully transparent, in other words, the full colour of
1314 the pixel in the second source is used. Values in-between cause blending with
1315 the following formula:
1317 Destination = Source1*Alpha/max_Alpha + Source2*(max_Alpha-Alpha)/max_Alpha
1319 Colour alpha bitmaps specify red, green and blue alpha values for each pixel,
1320 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1321 alpha value depends on the bitmap's display mode. For example, 255 is the
1322 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1323 which use fewer bits per colour component.
1325 Supported bitmap formats than can be used as alpha bitmaps are given in
1326 TGraphicsAcceleratorCaps::iAlphaBitmap.
1328 Objects of this class can be passed to a graphics accelerator's Operation()
1329 function either individually, or in a buffer.
1331 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1335 class TGopAlphaBlendTwoBitmaps : public TGraphicsOperation
1339 Constructor with a position, three bitmap specs and a rectangle.
1340 @param aDestination The destination for the top left hand corner of the portion
1341 of the source bitmaps.
1342 @param aSourceBmp1 A handle to the first of the source bitmaps, and other information
1344 @param aSourceBmp2 A handle to the second of the source bitmaps, and other information
1346 @param aSourceRect A rectangle within the source bitmaps. Its coordinates are relative
1347 to the top left of the bitmap. Defines the part of the bitmap to be copied.
1348 @param aSourcePt2 The point in the second source bitmap from which we take pixels to blend
1349 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1350 alpha blending values.
1351 @param aAlphaPt The point in the alpha bitmap from which we take pixels to blend
1353 inline TGopAlphaBlendTwoBitmaps(const TPoint& aDestination,TAcceleratedBitmapSpec aSourceBmp1,TAcceleratedBitmapSpec aSourceBmp2,TRect& aSourceRect,const TPoint& aSrcPt2,TAcceleratedBitmapSpec aAlphaBmp, const TPoint& aAlphaPt)
1354 : TGraphicsOperation(EAlphaBlendTwoBitmaps,sizeof(*this)), iDestination(aDestination), iSourceBmp1(aSourceBmp1), iSourceBmp2(aSourceBmp2), iSourceRect(aSourceRect), iSrcPt2(aSrcPt2), iAlphaBmp(aAlphaBmp), iAlphaPt(aAlphaPt) {}
1357 /** The destination for the top left hand corner of the portion of the source bitmaps. */
1358 TPoint iDestination;
1360 /** A handle to the first source bitmap, and other information needed to access it. */
1361 TAcceleratedBitmapSpec iSourceBmp1;
1363 /** A handle to the second source bitmap, and other information needed to access it. */
1364 TAcceleratedBitmapSpec iSourceBmp2;
1366 /** A rectangle defining the part of the source bitmaps to be copied. */
1369 /** The point in the second source bitmap from which we take pixels to blend. */
1372 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1373 TAcceleratedBitmapSpec iAlphaBmp;
1375 /** The point in the alpha bitmap from which we take pixels to blend. */
1380 An accelerated graphics operation that copies a rectangular region of a bitmap blended
1381 with the screen image to the screen, using alpha blending values provided in an alpha bitmap
1382 to blend the corresponding entries in the bitmap and on the screen.
1384 The way alpha blending works is as follows: if the alpha value is the maximum,
1385 the pixel from the source bitmap is opaque, in other words, the full colour of
1386 the pixel is written to the destination. If the alpha value is zero, the pixel
1387 from the source bitmap is fully transparent, in other words, the full colour of
1388 the pixel on the screen is used. Values in-between cause blending with the
1391 Destination = Source*Alpha/max_Alpha + Screen*(max_Alpha-Alpha)/max_Alpha
1393 Colour alpha bitmaps specify red, green and blue alpha values for each pixel,
1394 greyscale bitmaps specify a single alpha value for each pixel. The maximum
1395 alpha value depends on the bitmap's display mode. For example, 255 is the
1396 maximum for an EGray256 or EColor16M bitmap. The maximum is less for bitmaps
1397 which use fewer bits per colour component.
1399 Supported bitmap formats than can be used as alpha bitmaps are given in
1400 TGraphicsAcceleratorCaps::iAlphaBitmap.
1402 Objects of this class can be passed to a graphics accelerator's Operation()
1403 function either individually, or in a buffer.
1405 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1409 class TGopAlphaBlendOneBitmap : public TGraphicsOperation
1413 Constructor with a position, two bitmap specs and a rectangle.
1414 @param aDestination The destination for the top left hand corner of the portion
1415 of the source bitmap.
1416 @param aSourceBmp A handle to the source bitmap, and other information needed
1418 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1419 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1420 @param aAlphaBitmap A handle to the alpha bitmap, the bitmap that contains
1421 alpha blending values.
1422 @param aAlphaPt The point in the alpha bitmap from which we take pixels to blend
1426 inline TGopAlphaBlendOneBitmap(const TPoint& aDestination,TAcceleratedBitmapSpec aSourceBmp,TRect& aSourceRect,TAcceleratedBitmapSpec aAlphaBmp, const TPoint& aAlphaPt)
1427 : TGraphicsOperation(EAlphaBlendOneBitmap,sizeof(*this)), iDestination(aDestination), iSourceBmp(aSourceBmp), iSourceRect(aSourceRect), iAlphaBmp(aAlphaBmp), iAlphaPt(aAlphaPt) {}
1430 /** The destination for the top left hand corner of the portion of the source bitmap. */
1431 TPoint iDestination;
1433 /** A handle to the source bitmap, and other information needed to access it. */
1434 TAcceleratedBitmapSpec iSourceBmp;
1436 /** A rectangle defining the part of the bitmap to be copied. */
1439 /** A handle to the alpha bitmap, the bitmap that contains alpha blending values. */
1440 TAcceleratedBitmapSpec iAlphaBmp;
1442 /** Position of the first pixel in the alpha bitmap to be used for alpha blending. */
1447 An accelerated graphics operation that copies a rectangular region of one bitmap
1448 into a different sized region of another.
1450 The data members are all initialised on construction. Objects of this class
1451 can be passed to a graphics accelerator's Operation() function either individually,
1456 class TGopScaledBitBlt : public TGraphicsOperation
1459 /** Constructor with a destination rectangle, a handle to the source bitmap and
1461 @param aDestination The destination for the portion of the source bitmap. If necessary,
1462 the source bitmap portion is resized to fit into this rectangle.
1463 @param aSourceBitmap A handle to the source bitmap, and other information needed
1465 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1466 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1467 inline TGopScaledBitBlt(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1468 : TGraphicsOperation(EScaledBitBlt,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1471 /** The destination rectangle for the portion of the source bitmap. */
1474 /** A handle to the source bitmap. */
1475 TAcceleratedBitmapSpec iSourceBitmap;
1477 /** A rectangle defining all or a part of the source bitmap to be copied. */
1482 An accelerated graphics operation that copies a rectangular region of one bitmap
1483 into a different sized region of another, using a third bitmap as a mask.
1485 The mask must be the same size as the source bitmap. The parts of the source
1486 bitmap that are drawn are the areas that are black in the mask.
1488 The data members are all initialised on construction. Objects of this class
1489 can be passed to a graphics accelerator's Operation() function either individually,
1492 @see TGraphicsAcceleratorCaps::iMaskType
1496 class TGopScaledBitBltMasked : public TGraphicsOperation
1499 /** Constructor with a source and destination rectangle, and handles to the source
1502 @param aDestination The destination for the portion of the source bitmap. If necessary,
1503 the source bitmap portion is resized to fit into this rectangle.
1504 @param aSourceBitmap A handle to the source bitmap, and other information needed
1506 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1507 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1508 @param aMask A handle to the mask bitmap. */
1509 inline TGopScaledBitBltMasked(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aMask)
1510 : TGraphicsOperation(EScaledBitBltMasked,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iMask(aMask) {}
1513 /** The destination rectangle for the portion of the bitmap. */
1516 /** A handle to the source bitmap. */
1517 TAcceleratedBitmapSpec iSourceBitmap;
1519 /** A rectangle defining all or a part of the source bitmap to be copied. */
1522 /** A handle to the source bitmap mask. */
1523 TAcceleratedBitmapSpec iMask;
1527 An accelerated graphics operation that copies a rectangular region of one bitmap
1528 into a different sized region of another, with some transparent pixels in
1531 The data members are all initialised on construction. Objects of this class
1532 can be passed to a graphics accelerator's Operation() function either individually,
1535 @see TGraphicsAcceleratorCaps::iTransparency
1536 @see TGopTransparency
1540 class TGopScaledBitBltTransparent : public TGraphicsOperation
1543 /** Constructor with destination and source rectangles, a handle to the source
1544 bitmap and a specification for which pixels should be treated as transparent.
1546 @param aDestination The destination for the portion of the source bitmap. If necessary,
1547 the source bitmap portion is resized to fit into this rectangle.
1548 @param aSourceBitmap A handle to the source bitmap, and other information needed
1550 @param aSourceRect A rectangle within the source bitmap. Its coordinates are
1551 relative to the top left of the source bitmap. Defines the part of the source bitmap to
1553 @param aTransparency A specification for which pixels in the source bitmap should be treated as
1555 inline TGopScaledBitBltTransparent(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TGopTransparency aTransparency)
1556 : TGraphicsOperation(EScaledBitBltTransparent,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iTransparency(aTransparency) {}
1559 /** The destination rectangle for the portion of the source bitmap. */
1562 /** A handle to the source bitmap. */
1563 TAcceleratedBitmapSpec iSourceBitmap;
1565 /** A rectangle defining all or a part of the source bitmap to be copied. */
1568 /** A specification for which pixels in the source bitmap should be treated as transparent. */
1569 TGopTransparency iTransparency;
1573 An accelerated graphics operation that copies a rectangular region of one bitmap
1574 into a different sized region of another using alpha blending. The alpha value
1575 is part of each pixel in the source bitmap.
1577 Supported bitmap formats with an alpha-channel are given in by
1578 TGraphicsAcceleratorCaps::iAlphaChannel.
1580 The data members are all initialised on construction. Objects of this class
1581 can be passed to a graphics accelerator's Operation() function either individually,
1584 @see TGraphicsAcceleratorCaps::iAlphaChannel
1588 class TGopScaledBitBltAlphaChannel : public TGraphicsOperation
1591 /** Constructor with a destination rectangle, a handle to the source bitmap and
1594 @param aDestination The destination for the portion of the source bitmap. If necessary,
1595 the source bitmap portion is resized to fit into this rectangle.
1596 @param aSourceBitmap A handle to the source bitmap, and other information needed
1598 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1599 to the top left of the source bitmap. Defines the part of the source bitmap to be copied. */
1600 inline TGopScaledBitBltAlphaChannel(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect)
1601 : TGraphicsOperation(EScaledBitBltAlphaChannel,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect) {}
1604 /** The destination for the portion of the source bitmap. */
1607 /** A handle to the source bitmap, and other information needed to draw it. */
1608 TAcceleratedBitmapSpec iSourceBitmap;
1610 /** A rectangle defining the part of the source bitmap to be copied. */
1615 An accelerated graphics operation that copies a rectangular region of one bitmap
1616 into a different sized region of another using alpha blending values provided
1619 The data members are all initialised on construction. Objects of this class
1620 can be passed to a graphics accelerator's Operation() function either individually,
1623 @see TGraphicsAcceleratorCaps::iAlphaBitmap
1627 class TGopScaledBitBltAlphaBitmap : public TGraphicsOperation
1630 /** Constructor with a source and destination rectangle and two bitmap handles.
1632 @param aDestination The destination for the portion of the source bitmap. If necessary,
1633 the source bitmap portion is resized to fit into this rectangle.
1634 @param aSourceBitmap A handle to the source bitmap, and other information needed
1636 @param aSourceRect A rectangle within the source bitmap. Its coordinates are relative
1637 to the top left of the source bitmap. Defines the part of the source bitmap to be copied.
1638 @param aAlphaBitmap A handle to the bitmap that contains alpha blending values. */
1639 inline TGopScaledBitBltAlphaBitmap(const TRect& aDestination, TAcceleratedBitmapSpec aSourceBitmap, TRect& aSourceRect, TAcceleratedBitmapSpec aAlphaBitmap)
1640 : TGraphicsOperation(EScaledBitBltAlphaBitmap,sizeof(*this)), iDestination(aDestination), iSourceBitmap(aSourceBitmap), iSourceRect(aSourceRect), iAlphaBitmap(aAlphaBitmap) {}
1643 /** The destination for the portion of the bitmap. */
1646 /** A handle to the source bitmap, and other information needed to draw it. */
1647 TAcceleratedBitmapSpec iSourceBitmap;
1649 /** A rectangle defining the part of the source bitmap to be copied. */
1652 /** A handle to the bitmap that contains alpha blending values. */
1653 TAcceleratedBitmapSpec iAlphaBitmap;
1657 An accelerated graphics operation that fills a polygon with a colour.
1659 AddPoints() must be called to specify the polygon to be filled. Objects of
1660 this class can be passed to a graphics accelerator's Operation() function
1661 either individually, or in a buffer.
1663 How a graphics accelerator can fill polygons is given by TGraphicsAcceleratorCaps::iPolygon.
1665 @see TGraphicsAcceleratorCaps::iPolygon
1669 class TGopFilledPolygon : public TGraphicsOperation
1672 /** Constructor with a fill rule and a fill colour. The number of points is initialised
1675 @param aColor The fill colour.
1676 @param aFillRule Bit flags for how self-crossing polygons are filled. */
1677 inline TGopFilledPolygon(TRgb aColor, CGraphicsContext::TFillRule aFillRule)
1678 : TGraphicsOperation(EFilledPolygon,sizeof(*this)), iColor(aColor), iFillRule(aFillRule), iNumPoints(0) {}
1679 inline void AddPoints(TInt aNumPoints, TPoint* aPoints);
1682 /** The fill colour. */
1685 /** Bit flags for how self-crossing polygons are filled.
1687 @see CGraphicsContext::TFillRule */
1688 CGraphicsContext::TFillRule iFillRule;
1690 /** The number of points in the polygon. */
1694 /** Specifies the polygon to be filled as a number of 2D point coordinates.
1696 AddPoints() should only be called once the TGopFilledPolygon object has been stored
1697 into a buffer. There must be enough room in the buffer after the TGopFilledPolygon
1698 object to hold aNumPoints TPoint sized structures. This is because the points are
1699 copied into the memory space directly following the TGopFilledPolygon object.
1701 @param aNumPoints The number of points in the polygon.
1702 @param aPoints Pointer to the first point in the polygon. */
1703 inline void TGopFilledPolygon::AddPoints(TInt aNumPoints, TPoint* aPoints)
1704 { Append(aNumPoints*sizeof(TPoint),aPoints); iNumPoints += aNumPoints; }
1707 An accelerated graphics operation that fills a polygon with a pattern held
1710 AddPoints() must be called to specify the polygon to be filled. Objects of
1711 this class can be passed to a graphics accelerator's Operation() function
1712 either individually, or in a buffer.
1714 @see TGraphicsAcceleratorCaps::iPolygon
1715 @see TGopFillPattern
1719 class TGopFilledPolygonWithPattern : public TGraphicsOperation
1722 /** Constructor with a fill pattern and a fill rule. The number of points is initialised
1725 @param aPattern The fill pattern.
1726 @param aFillRule Bit flags for how self-crossing polygons are filled. */
1727 inline TGopFilledPolygonWithPattern(TGopFillPattern aPattern, CGraphicsContext::TFillRule aFillRule)
1728 : TGraphicsOperation(EFilledPolygonWithPattern,sizeof(*this)), iPattern(aPattern), iFillRule(aFillRule), iNumPoints(0) {}
1729 inline void AddPoints(TInt aNumPoints, TPoint* aPoints);
1732 /** The pattern of bitmaps that is used to fill the polygon. */
1733 TGopFillPattern iPattern;
1735 /** Bit flags for how self-crossing polygons are filled.
1737 @see CGraphicsContext::TFillRule */
1738 CGraphicsContext::TFillRule iFillRule;
1740 /** The number of points in the polygon. */
1744 /** Specifies the polygon to be filled as a number of 2D point coordinates.
1746 AddPoints() should only be called once the TGopFilledPolygonWithPattern object has been stored
1747 into a buffer. There must be enough room in the buffer after the TGopFilledPolygonWithPattern
1748 object to hold aNumPoints TPoint sized structures. This is because the points are
1749 copied into the memory space directly following the TGopFilledPolygonWithPattern object.
1751 @param aNumPoints The number of points in the polygon.
1752 @param aPoints Pointer to the first point in the polygon. */
1753 inline void TGopFilledPolygonWithPattern::AddPoints(TInt aNumPoints, TPoint* aPoints)
1754 { Append(aNumPoints*sizeof(TPoint),aPoints); iNumPoints += aNumPoints; }