1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include <graphicsaccelerator.h>
27 /** Screen device orientations.
29 WARNING: Enumeration for internal use ONLY. Compatibility is not guaranteed in future releases.
34 enum TDeviceOrientation
36 EDeviceOrientationNormal = 1,
37 EDeviceOrientation90CW = 2,
38 EDeviceOrientation180 = 4,
39 EDeviceOrientation270CW = 8
42 /** Abstract base class for graphics devices to which bitmaps and fonts can be
45 The class implements the pure virtual CBitmapDevice functions and additionally
48 support for creating and enquiring about fonts
50 comparing two device rectangles
52 creating a graphics context for the device.
54 CFbsBitmapDevice and CFbsScreenDevice are derived fom this class.
61 class CFbsDevice : public CBitmapDevice
63 friend class CFbsBitGc;
65 IMPORT_C ~CFbsDevice();
66 IMPORT_C TInt CreateContext(CFbsBitGc*& aGc);
67 inline TInt CreateContext(CGraphicsContext*& aGc);
68 IMPORT_C TDisplayMode DisplayMode() const;
69 IMPORT_C TSize SizeInPixels() const;
70 IMPORT_C TBool RectCompare(const TRect& aSourceRect,const CFbsDevice& aDevice,const TRect& aDeviceRect) const;
71 IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId);
72 IMPORT_C void RemoveFile(TInt aId=0);
73 IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
74 IMPORT_C virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
75 IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
76 IMPORT_C virtual TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
77 IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
78 IMPORT_C virtual TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
79 IMPORT_C TInt GetFontById(CFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
80 inline TInt GetNearestFontInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
81 inline TInt GetNearestFontInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
82 inline TInt GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
83 inline TInt GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
84 inline TInt GetNearestFontToMaxHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
85 inline TInt GetNearestFontToMaxHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
86 inline TInt GetFontById(CFbsFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
87 IMPORT_C void ReleaseFont(CFont* aFont);
88 IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
89 IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
90 IMPORT_C TInt NumTypefaces() const;
91 IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
92 IMPORT_C TInt SetCustomPalette(const CPalette* aPalette);
93 inline CGraphicsAccelerator* GraphicsAccelerator() const;
94 inline CFbsBitGc::TGraphicsOrientation Orientation() const;
95 IMPORT_C static TDisplayMode DisplayMode16M();
96 IMPORT_C TInt SetScalingFactor(const TPoint& aOrigin,
97 TInt aFactorX, TInt aFactorY,
98 TInt aDivisorX, TInt aDivisorY);
99 IMPORT_C void GetDrawRect(TRect& aRect) const;
100 IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
101 IMPORT_C TInt SetDrawDeviceOffset(const TPoint& aOrigin);
105 virtual void DrawingBegin(TBool /*aAlways*/ = EFalse) {}
106 virtual void DrawingEnd(TBool /*aAlways*/ = EFalse) {}
111 virtual void SetBits() {}
114 This method has been deprecated. Sprites are no longer supported in BitGDI.
115 Calling this method has no effect.
118 virtual void CancelSprite() const {}
121 This method has been deprecated. Sprites are no longer supported in BitGDI.
122 Calling this method has no effect.
123 @return TSpriteBase* NULL.
126 virtual TSpriteBase* HideSprite() const {return(NULL);}
129 This method has been deprecated. Sprites are no longer supported in BitGDI.
130 Calling this method has no effect.
131 @param aRect Ignored.
132 @param aClippingRegion Ignored.
133 @return TSpriteBase* NULL.
136 virtual TSpriteBase* HideSprite(const TRect&,const TRegion*) const {return(NULL);}
139 This method has been deprecated. Sprites are no longer supported in BitGDI.
140 Calling this method has no effect.
141 @param aSprite Ignored.
144 virtual void ShowSprite(TSpriteBase*) const {}
147 This method has been deprecated. Sprites are no longer supported in BitGDI.
148 Calling this method has no effect.
149 @param aSprite Ignored.
150 @param aRect Ignored.
151 @param aClippingRegion Ignored.
154 virtual void ShowSprite(TSpriteBase*,const TRect&,const TRegion*) const {}
155 TInt GetNearestFbsFont(CFbsFont*& aFont,const TFontSpec& aFontSpec);
156 void DoGetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode);
157 void ReadLineDiffMode(TInt,TInt,TInt,TAny*,TDisplayMode) const;
158 void TruncateRect(TRect& aRect);
159 TBool SetOrientation(CFbsBitGc::TGraphicsOrientation aOrientation);
160 void DrawingBegin(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
161 void DrawingEnd(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
163 CFbsDrawDevice* iDrawDevice;
165 CFbsTypefaceStore* iTypefaceStore;
168 TUint8* iBitBltMaskedBuffer;
169 CGraphicsAccelerator* iGraphicsAccelerator;
170 CFbsBitGc::TGraphicsOrientation iOrientation;
173 /** A graphics device interface that provides direct access to the screen, without
174 the mediation of the window server.
179 class CFbsScreenDevice : public CFbsDevice
182 IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode);
183 IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode, TRgb aWhite);
184 IMPORT_C static CFbsScreenDevice* NewL(TInt aScreenNo, TDisplayMode aDispMode);
185 IMPORT_C virtual ~CFbsScreenDevice();
186 IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const;
187 IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
188 IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
189 IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
190 IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
191 IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
192 IMPORT_C void SetAutoUpdate(TBool aValue);
193 IMPORT_C void DrawSpriteBegin(); //< @deprecated
194 IMPORT_C void DrawSpriteEnd(); //< @deprecated
195 IMPORT_C void CancelSprite() const; //< @deprecated
196 IMPORT_C TSpriteBase* HideSprite() const; //< @deprecated
197 IMPORT_C TSpriteBase* HideSprite(const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated
198 IMPORT_C void ShowSprite(TSpriteBase* aSprite) const; //< @deprecated
199 IMPORT_C void ShowSprite(TSpriteBase* aSprite,const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated
200 IMPORT_C void ChangeScreenDevice(CFbsScreenDevice* aOldDevice);
201 IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
202 IMPORT_C void SetPalette(CPalette* aPalette);
203 IMPORT_C TInt GetPalette(CPalette*& aPalette) const;
204 IMPORT_C void Update();
205 IMPORT_C void Update(const TRegion& aRegion);
206 IMPORT_C TSize SizeInTwips() const;
207 IMPORT_C RHardwareBitmap HardwareBitmap();
208 IMPORT_C const TUint32* Bits() const;
209 IMPORT_C TInt Stride() const;
210 IMPORT_C TInt ScreenNo() const;
211 IMPORT_C TUint DeviceOrientationsAvailable() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */
212 IMPORT_C TBool SetDeviceOrientation(TDeviceOrientation aOrientation) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */
213 IMPORT_C void GetSurface(TSurfaceId& aSurface) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */
214 IMPORT_C TDeviceOrientation DeviceOrientation() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */
216 CFbsScreenDevice(TInt aScreenNo);
217 void ConstructL(TInt aScreenNo, TDisplayMode aDispMode);
219 TInt iSpare1_CFbsScreenDevice;
220 TInt iSpare2_CFbsScreenDevice;
224 /** A graphics device to which a bitmap managed by the font and bitmap server can
227 The class specialises the bitmap graphics device interface CBitmapDevice for
228 drawing to in-memory bitmaps.
232 class CFbsBitmapDevice : public CFbsDevice
235 IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap);
236 IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
237 IMPORT_C virtual ~CFbsBitmapDevice();
238 IMPORT_C TInt Resize(const TSize& aSize);
239 IMPORT_C virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode iDispMode) const;
240 IMPORT_C virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
241 IMPORT_C virtual TInt HorizontalPixelsToTwips(TInt aPixels) const;
242 IMPORT_C virtual TInt VerticalPixelsToTwips(TInt aPixels) const;
243 IMPORT_C virtual TInt HorizontalTwipsToPixels(TInt aTwips) const;
244 IMPORT_C virtual TInt VerticalTwipsToPixels(TInt aTwips) const;
245 IMPORT_C virtual TSize SizeInTwips() const;
246 IMPORT_C virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
247 IMPORT_C virtual void SetPalette(CPalette* aPalette);
248 IMPORT_C virtual TInt GetPalette(CPalette*& aPalette) const;
249 IMPORT_C virtual void DrawingBegin(TBool aAlways = EFalse);
250 IMPORT_C virtual void DrawingEnd(TBool aAlways = EFalse);
251 IMPORT_C TInt SwapWidthAndHeight();
255 virtual void SetBits();
256 void ConstructL(CFbsBitmap* aFbsBitmap);
257 void ConstructL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
259 CFbsBitGcBitmap* iFbsBmp;
262 #include <bitdev.inl>