|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of CHuiCanvasWsHwGc. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUICANVASWSHWGC_H__ |
|
21 #define __HUICANVASWSHWGC_H__ |
|
22 |
|
23 #include <uiacceltk/HuiVisual.h> |
|
24 #include "uiacceltk/HuiTextMesh.h" |
|
25 #include "huicanvaswsgc.h" |
|
26 #include "huicanvaspainter.h" |
|
27 #include "huicanvasrenderbuffer.h" |
|
28 |
|
29 const TInt KHuiCanvasWsHwGcRegionGranularity = 10; |
|
30 |
|
31 /** |
|
32 * This class is used internally by the toolkit and thus should |
|
33 * not be used by the applications directly. |
|
34 */ |
|
35 NONSHARABLE_CLASS(CHuiCanvasWsHwGc) : public CHuiCanvasWsGc |
|
36 { |
|
37 |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Constructor. |
|
42 */ |
|
43 static CHuiCanvasWsHwGc* NewL(); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CHuiCanvasWsHwGc(); |
|
49 |
|
50 public: |
|
51 |
|
52 // CFbsBitGc functionality |
|
53 virtual void WsBitBltL(TInt aBitmapHandle, TPoint aPoint); |
|
54 virtual void WsBitBltRectL(TInt aBitmapHandle, TPoint aPoint, TRect aRect) ; |
|
55 virtual void WsBitBltMaskedL(TInt aBitmapHandle, TInt aMaskHandle, TInt aInvertMask, TPoint aPoint, TRect aRect) ; |
|
56 virtual void WsBitBltMaskedPointL(TInt aBitmapHandle, TInt aMaskHandle, TPoint aPoint1, TPoint aPoint2, TRect aRect) ; |
|
57 virtual void WsResetClippingRegionL() ; |
|
58 virtual void WsClearL(); |
|
59 virtual void WsClearRectL(TRect& aRect) ; |
|
60 virtual void WsResetBrushPatternL() ; |
|
61 virtual void WsResetFontL() ; |
|
62 virtual void WsDrawArcL(TPoint aPoint1, TPoint aPoint2, TRect aRect) ; |
|
63 virtual void WsDrawPieL(TPoint aPoint1, TPoint aPoint2, TRect aRect) ; |
|
64 virtual void WsDrawBitmap1L(TInt aBitmapHandle, TRect aRect) ; |
|
65 virtual void WsDrawBitmap2L(TInt aBitmapHandle, TRect aRect1, TRect aRect2) ; |
|
66 virtual void WsDrawBitmap3L(TInt aBitmapHandle, TPoint aPoint) ; |
|
67 virtual void WsDrawBitmapMaskedL(TInt aBitmapHandle, TInt aMaskHandle, TInt aInvertMask, TRect& aRect1, TRect& aRect2) ; |
|
68 virtual void WsDrawRoundRectL(TPoint aPoint, TRect& aRect) ; |
|
69 virtual void WsDrawPolyLineL(CArrayFix<TPoint>* aPointerArray) ; |
|
70 virtual void WsDrawPolyLineNoEndPointL(TPoint* aPointerArray, TInt aCount); |
|
71 virtual void WsDrawPolygonL(CArrayFix<TPoint>* aPointerArray, TInt aFillRule ) ; |
|
72 virtual void WsDrawEllipseL(TRect& aRect) ; |
|
73 virtual void WsDrawLineL(TPoint& aStart, TPoint& aEnd) ; |
|
74 virtual void WsDrawLineToL(TPoint& aPoint); |
|
75 virtual void WsDrawLineByL(TPoint& aPoint) ; |
|
76 virtual void WsDrawRectL(TRect& aRect) ; |
|
77 virtual void WsDrawText1L(TPtr& aTextValue, THuiCanvasTextParameters& aTextParameters) ; |
|
78 virtual void WsDrawText2L(TPtr& aTextValue, TPoint& aPoint,THuiCanvasTextParameters& aTextParameters) ; |
|
79 virtual void WsDrawText3L(TPtr& aTextValue, TRect& aRect, THuiCanvasTextParameters& aTextParameters) ; |
|
80 virtual void WsDrawText4L(TPtr& aTextValue, TRect& aRect, TInt aBaselineOffset, TInt aTextAlign, TInt aTextMargin,THuiCanvasTextParameters& aTextParameters) ; |
|
81 virtual void WsDrawText5L(TPtr& aTextValue, TRect& aRect, TInt aBaselineOffset, TInt aTextAlign, TInt aTextMargin,TInt aTextWidth, THuiCanvasTextParameters& aTextParameters) ; |
|
82 virtual void WsDrawTextVertical1L(TPtr& aTextValue, TInt aTextUp, THuiCanvasTextParameters& aTextParameters) ; |
|
83 virtual void WsDrawTextVertical2L(TPtr& aTextValue, TInt aTextUp,TPoint& aPoint, THuiCanvasTextParameters& aTextParameters) ; |
|
84 virtual void WsDrawTextVertical3L(TPtr& aTextValue, TInt aTextUp, TRect& aRect, THuiCanvasTextParameters& aTextParameters) ; |
|
85 virtual void WsDrawTextVertical4L(TPtr& aTextValue, TRect& aRect, TInt aBaselineOffset, TInt aTextUp, TInt aTextAlign, TInt aTextMargin, THuiCanvasTextParameters& aTextParameters) ; |
|
86 virtual void WsDrawTextVertical5L(TPtr& aTextValue, TRect& aRect, TInt aBaselineOffset, TInt aTextUp, TInt aTextAlign, TInt aTextMargin, TInt aTextWidth, THuiCanvasTextParameters& aTextParameters) ; |
|
87 virtual void WsMoveToL( TPoint& aPoint) ; |
|
88 virtual void WsMoveByL( TPoint& aPoint) ; |
|
89 virtual void WsPlotL(TPoint& aPoint) ; |
|
90 virtual void WsResetL() ; |
|
91 virtual void WsSetBrushColorL( TRgb aColor) ; |
|
92 virtual void WsSetBrushOriginL( TPoint& aPoint) ; |
|
93 virtual void WsSetBrushStyleL( TInt aStyle) ; |
|
94 virtual void WsSetClippingRegionL( RRegion& aRegion) ; |
|
95 virtual void WsSetDrawModeL( TInt aDrawModew) ; |
|
96 virtual void WsSetOriginL( TPoint& aOrigin); |
|
97 virtual void WsSetPenColorL( TRgb aColor) ; |
|
98 virtual void WsSetPenStyleL( TInt aStyle) ; |
|
99 virtual void WsSetPenSizeL( TInt aWidth, TInt aHeight) ; |
|
100 virtual void WsSetTextShadowColorL( TRgb aColor) ; |
|
101 virtual void WsSetCharJustificationL( TInt aExcessiveWidth, TInt aNumGap) ; |
|
102 virtual void WsSetWordJustificationL( TInt aExcessiveWidth, TInt aNumGap) ; |
|
103 virtual void WsSetUnderlineStyleL( TInt aValue) ; |
|
104 virtual void WsSetBrushPatternL( TInt aValue) ; |
|
105 virtual void WsSetFontL( TInt aFontId) ; |
|
106 virtual void WsCopyRectL( TPoint& aPoint, TRect& aRect) ; |
|
107 virtual void WsCopySettingsL() ; |
|
108 virtual void WsUpdateJustificationL( TPtr& aTextValue) ; |
|
109 virtual void WsUpdateJustificationVerticalL( TInt aValue, TPtr& aTextValue) ; |
|
110 virtual void WsSetFontNoDuplicateL( TInt aCurrentFont) ; |
|
111 virtual void WsSetClippingRectL( TRect& aRect) ; |
|
112 virtual void WsCancelClippingRectL() ; |
|
113 virtual void WsSetFadedL( TInt& aFaded) ; |
|
114 virtual void WsSetFadingParametersL( TInt aFaded1, TInt aFaded2) ; |
|
115 virtual void WsFadeAreaL( RRegion& aRegion) ; |
|
116 virtual void WsMapColorsL() ; |
|
117 virtual void WsSetUserDisplayModeL( TInt aMode) ; |
|
118 virtual void WsUseFontL(TInt aCurrentFont) ; |
|
119 |
|
120 // Extended CFbsBitGc functionality |
|
121 virtual void WsCombinedBitBltMaskedL(TRect aDestinationRect, const RArray<THuiCachedCombinedImageParams>& aBlits); |
|
122 |
|
123 // Canvas functionality |
|
124 |
|
125 virtual void BeginActionL(TInt aAction, TRect aDisplayRect,const CHuiCanvasVisual& aUser, TBool aIsCachePrepared, const TRegion& aUpdateRegion); |
|
126 virtual void EnableUpdateRegion(const TRegion& aUpdateRegion, TBool aClear); |
|
127 virtual void DisableUpdateRegion(); |
|
128 virtual void EndActionL(const TRegion& aUpdateRegion, TBool aUpdateDisplay); |
|
129 virtual TInt SetCapturingBufferL(CFbsBitmap* aTarget); |
|
130 virtual CHuiCanvasGc& CanvasGc() const; |
|
131 virtual void SetPositionDelta( TPoint& aPoint ); |
|
132 virtual void ClearCache(); |
|
133 |
|
134 virtual void SetRelativeOrientation(CHuiGc::TOrientation aOrientation); |
|
135 |
|
136 virtual TBool IsRenderBufferEnabled() const; |
|
137 virtual TBool IsRenderBufferPrepared() const; |
|
138 virtual TBool IsRenderBufferInitialized() const; |
|
139 |
|
140 virtual TInt EnableRenderbuffer(TBool aEnable = ETrue); |
|
141 virtual THuiCanvasWsGcType Type() const; |
|
142 |
|
143 void BeginDrawL(TRect aDisplayRect,const CHuiCanvasVisual& aUser, TBool aIsCachePrepared, const TRegion& aUpdateRegion); |
|
144 void EndDrawL(const TRegion& aUpdateRegion, TBool aUpdateDisplay); |
|
145 void BeginScanL(TRect aDisplayRect,const CHuiCanvasVisual& aUser, TBool aIsCachePrepared, const TRegion& aUpdateRegion); |
|
146 void EndScanL(const TRegion& aUpdateRegion, TBool aUpdateDisplay); |
|
147 |
|
148 public: |
|
149 |
|
150 void DoWsClearRectL(const THuiRealRect& aRect ); |
|
151 |
|
152 private: |
|
153 |
|
154 /** |
|
155 * Constructor. |
|
156 */ |
|
157 CHuiCanvasWsHwGc(); |
|
158 |
|
159 /** |
|
160 * Second-phase constructor. |
|
161 */ |
|
162 void ConstructL(); |
|
163 |
|
164 |
|
165 THuiCachedGcParams CachedGcParams(); |
|
166 |
|
167 void ExpandDirtyRegion(TRect aNewRect); |
|
168 |
|
169 void AdjustCoordinates(TRect& aRect, TBool aUseWsOrigin = ETrue ); |
|
170 |
|
171 void AdjustCoordinates(TPoint& aPoint , TBool aUseWsOrigin = ETrue ); |
|
172 |
|
173 void DrawTextBrush( THuiRealRect& aRect ); |
|
174 |
|
175 TRect RoundedDisplayRect(); |
|
176 |
|
177 TBool IsRenderingEnabled() const; |
|
178 |
|
179 TBool IsRenderBufferUpdateOngoing() const; |
|
180 |
|
181 THuiCanvasDrawMode SelectCanvasDrawMode(TInt aWsDrawMode); |
|
182 |
|
183 void BindRenderBuffer(CHuiCanvasRenderBuffer* aRenderbuffer, const TRegion& aUpdateRegion); |
|
184 |
|
185 void UnBindRenderBuffer(CHuiCanvasRenderBuffer* aRenderbuffer); |
|
186 |
|
187 void UseBrushPattern(); |
|
188 |
|
189 void DiscardBrushPattern(); |
|
190 |
|
191 TBool IsDifferent(const TRgb& aFirst, const TRgb& aSecond, TBool aIgnoreAlpha); |
|
192 |
|
193 /** |
|
194 * UseCanvasState |
|
195 * |
|
196 * Saves canvas state for color, opacity, drawmode, pen width and polygon drawmode |
|
197 */ |
|
198 void UseCanvasState(); |
|
199 |
|
200 /** |
|
201 * UseWsState |
|
202 * |
|
203 * Restores canvas state (stored by the call of UseCanvasState) for color, |
|
204 * opacity, drawmode, pen width and polygon drawmode |
|
205 */ |
|
206 void UseWsState(); |
|
207 |
|
208 private: |
|
209 |
|
210 /** |
|
211 * CFbsBitGc attributes |
|
212 */ |
|
213 TInt iWsCurrentFont; |
|
214 TPoint iWsPenPosition; |
|
215 TPoint iWsOrigin; |
|
216 TRgb iWsFadeColor; |
|
217 TRgb iWsPenColor; |
|
218 TRgb iWsBrushColor; |
|
219 TInt iWsPenStyle; |
|
220 TInt iWsDrawMode; |
|
221 TInt iWsBrushStyle; |
|
222 TInt iWsShadowMode; |
|
223 TInt iWsStrikethrough; |
|
224 TInt iWsUnderline; |
|
225 TInt iWsUserDisplayMode; |
|
226 TRgb iWsShadowColor; |
|
227 TSize iWsPenSize; |
|
228 TInt iWsBrushPattern; |
|
229 TPoint iWsBrushOrigin; |
|
230 |
|
231 /** |
|
232 * RRegionBuf is used instead of RRegion for better performance. |
|
233 */ |
|
234 RRegionBuf<KHuiCanvasWsHwGcRegionGranularity> iWsClipRegion; |
|
235 RRegionBuf<KHuiCanvasWsHwGcRegionGranularity> iTempRegion; |
|
236 |
|
237 /** |
|
238 * Canvas internal misc attributes |
|
239 */ |
|
240 TInt iAction; |
|
241 CHuiCanvasGc* iCanvasGc; |
|
242 CHuiCanvasVisual* iVisual; |
|
243 TBool iAllCommandsSupported; |
|
244 |
|
245 /** |
|
246 * The difference between the original position (when first drawn) of the |
|
247 * window and the current position after visual position has been changed |
|
248 */ |
|
249 TPoint iPosDelta; |
|
250 |
|
251 /** |
|
252 * Render buffer is (or is not) ready to be drawn into display |
|
253 */ |
|
254 TBool iRenderBufferPrepared; |
|
255 |
|
256 /** |
|
257 * Render buffer is (or is not) used when drawing |
|
258 */ |
|
259 TBool iRenderBufferEnabled; |
|
260 |
|
261 /** |
|
262 * Render buffer is (or is not) available when drawing. It may be unavailable for |
|
263 * various reasons, e.g. when memory is low. |
|
264 */ |
|
265 TBool iRenderBufferAvailable; |
|
266 |
|
267 /** |
|
268 * Render buffer is (or is not) initalized. It has just been created, resized or recycled. |
|
269 */ |
|
270 TBool iRenderBufferInitialized; |
|
271 |
|
272 /** |
|
273 * Relative orientation to display orientation. E.g. after layout switch display is in |
|
274 * EOrientationCCW90 but stored old drawing commands have orientation EOrientationNormal. In that |
|
275 * case setting iRelativeOrientation to EOrientationCW90 causes drawing commands to appear |
|
276 * at their original orientation in the physical screen. |
|
277 * |
|
278 */ |
|
279 CHuiGc::TOrientation iRelativeOrientation; |
|
280 |
|
281 TRgb iOldColor; |
|
282 TReal32 iOldOpacity; |
|
283 THuiCanvasDrawMode iOldDrawMode; |
|
284 TInt iOldPenWidth; |
|
285 THuiFillMode iOldPolygonDrawMode; |
|
286 #ifdef __WINS__ |
|
287 TInt iPushCount; |
|
288 #endif |
|
289 }; |
|
290 #endif // __HUICANVASWSHWGC_H__ |