sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "directgdigcwrapper.h"
|
sl@0
|
17 |
#include <s32mem.h>
|
sl@0
|
18 |
#include <graphics/lookuptable.h>
|
sl@0
|
19 |
#include <graphics/directgdidriver.h>
|
sl@0
|
20 |
#include <graphics/directgdidrawablesource.h>
|
sl@0
|
21 |
#include <graphics/sgresourceinternal.h>
|
sl@0
|
22 |
#include "mwsgraphicscontexttodirectgdimappings.h"
|
sl@0
|
23 |
#include "panic.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
CDirectGdiGcWrapper* CDirectGdiGcWrapper::NewL()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CDirectGdiGcWrapper* self = new(ELeave) CDirectGdiGcWrapper;
|
sl@0
|
28 |
CleanupStack::PushL(self);
|
sl@0
|
29 |
CDirectGdiDriver* driver = CDirectGdiDriver::Static();
|
sl@0
|
30 |
User::LeaveIfNull(driver);
|
sl@0
|
31 |
self->iContext = CDirectGdiContext::NewL(*driver);
|
sl@0
|
32 |
self->iErrorCode = KErrNone;
|
sl@0
|
33 |
self->iGcBuf = CBufSeg::NewL(512);
|
sl@0
|
34 |
//MWsFader
|
sl@0
|
35 |
//Default in BitGdi was 128 for the blackMap and 255 for the whiteMap
|
sl@0
|
36 |
//SetFadingParameters shows how the fade color is computed
|
sl@0
|
37 |
self->iFadeColor.SetInternal(0x80FFFFFF);
|
sl@0
|
38 |
|
sl@0
|
39 |
self->iLut = PtrTo16BitNormalisationTable();
|
sl@0
|
40 |
CleanupStack::Pop(self);
|
sl@0
|
41 |
return self;
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
CDirectGdiGcWrapper::~CDirectGdiGcWrapper()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
delete iContext;
|
sl@0
|
47 |
delete iGcBuf;
|
sl@0
|
48 |
for (TInt i = 0; i < iDrawableSources.Count(); ++i)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
iDrawableSources[i]->Close();
|
sl@0
|
51 |
}
|
sl@0
|
52 |
iDrawableSources.ResetAndDestroy();
|
sl@0
|
53 |
iClippingRegion.Close();
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
TAny* CDirectGdiGcWrapper::ResolveObjectInterface(TUint aTypeId)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
switch(aTypeId)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
case MWsGraphicsContext::EWsObjectInterfaceId:
|
sl@0
|
61 |
return static_cast<MWsGraphicsContext*>(this);
|
sl@0
|
62 |
case MWsFader::EWsObjectInterfaceId:
|
sl@0
|
63 |
return static_cast<MWsFader*>(this);
|
sl@0
|
64 |
case MWsDrawableSourceProvider::EWsObjectInterfaceId:
|
sl@0
|
65 |
return static_cast<MWsDrawableSourceProvider*>(this);
|
sl@0
|
66 |
case MWsTextCursor::EWsObjectInterfaceId:
|
sl@0
|
67 |
return static_cast<MWsTextCursor*>(this);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
return NULL;
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
iContext->BitBlt(aDestPos, aSourceBitmap);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
void CDirectGdiGcWrapper::BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
iContext->BitBlt(aDestPos, aSourceBitmap, aSourceRect);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
void CDirectGdiGcWrapper::BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
iContext->BitBltMasked(aDestPos, aSourceBitmap, aSourceRect, aMaskBitmap, aMaskPos);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
void CDirectGdiGcWrapper::ResetClippingRegion()
|
sl@0
|
93 |
{
|
sl@0
|
94 |
iContext->ResetClippingRegion();
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
void CDirectGdiGcWrapper::Clear()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
iContext->Clear();
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
void CDirectGdiGcWrapper::Clear(const TRect& aRect)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
iContext->Clear(aRect);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
void CDirectGdiGcWrapper::ResetBrushPattern()
|
sl@0
|
108 |
{
|
sl@0
|
109 |
iContext->ResetBrushPattern();
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
void CDirectGdiGcWrapper::ResetFont()
|
sl@0
|
113 |
{
|
sl@0
|
114 |
iContext->ResetFont();
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
void CDirectGdiGcWrapper::DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
iContext->DrawArc(aRect, aStart, aEnd);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
void CDirectGdiGcWrapper::DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
iContext->DrawPie(aRect, aStart, aEnd);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
iContext->DrawBitmap(aDestRect, aSourceBitmap);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
void CDirectGdiGcWrapper::DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
iContext->DrawBitmap(aDestRect, aSourceBitmap, aSourceRect);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
void CDirectGdiGcWrapper::DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
iContext->DrawBitmapMasked(aDestRect, aSourceBitmap, aSourceRect, aMaskBitmap, aInvertMask);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
void CDirectGdiGcWrapper::DrawRoundRect(const TRect& aRect, const TSize& aEllipse)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
iContext->DrawRoundRect(aRect, aEllipse);
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
void CDirectGdiGcWrapper::DrawPolyLine(const TArray<TPoint>& aPointList)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
iContext->DrawPolyLine(aPointList);
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
void CDirectGdiGcWrapper::DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
iContext->DrawPolyLineNoEndPoint(aPointList);
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
void CDirectGdiGcWrapper::DrawPolygon(const TArray<TPoint>& aPointList, TFillRule aFillRule)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
iContext->DrawPolygon(aPointList, MWsGraphicsContextToDirectGdiMappings::Convert(aFillRule));
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
void CDirectGdiGcWrapper::DrawEllipse(const TRect& aRect)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
iContext->DrawEllipse(aRect);
|
sl@0
|
165 |
}
|
sl@0
|
166 |
|
sl@0
|
167 |
void CDirectGdiGcWrapper::DrawLine(const TPoint& aStart, const TPoint& aEnd)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
iContext->DrawLine(aStart, aEnd);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
void CDirectGdiGcWrapper::DrawLineTo(const TPoint& aPoint)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
iContext->DrawLineTo(aPoint);
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
void CDirectGdiGcWrapper::DrawLineBy(const TPoint& aVector)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
iContext->DrawLineBy(aVector);
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
void CDirectGdiGcWrapper::DrawRect(const TRect& aRect)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
iContext->DrawRect(aRect);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
void CDirectGdiGcWrapper::DrawText(const TDesC& aText, const TTextParameters* aParam)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam));
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
void CDirectGdiGcWrapper::DrawText(const TDesC& aText, const TTextParameters* aParam, const TPoint& aPosition)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition);
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
void CDirectGdiGcWrapper::DrawText(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect);
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
void CDirectGdiGcWrapper::DrawText(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipFillRect, TInt aBaselineOffset, TTextAlign aHrz, TInt aMargin)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
iContext->DrawText(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipFillRect, aBaselineOffset, MWsGraphicsContextToDirectGdiMappings::Convert(aHrz), aMargin);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
|
sl@0
|
207 |
void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, TBool aUp)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp);
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TPoint& aPosition, TBool aUp)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aPosition, aUp);
|
sl@0
|
215 |
}
|
sl@0
|
216 |
|
sl@0
|
217 |
void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TBool aUp)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aUp);
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, TBool aUp, TTextAlign aVert, TInt aMargin)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin);
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
void CDirectGdiGcWrapper::DrawTextVertical(const TDesC& aText, const TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, TInt aTextWidth, TBool aUp, TTextAlign aVert, TInt aMargin)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
iContext->DrawTextVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aClipRect, aBaselineOffset, aTextWidth, aUp, MWsGraphicsContextToDirectGdiMappings::Convert(aVert), aMargin);
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
void CDirectGdiGcWrapper::MoveTo(const TPoint& aPoint)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
iContext->MoveTo(aPoint);
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
void CDirectGdiGcWrapper::MoveBy(const TPoint& aVector)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
iContext->MoveBy(aVector);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
void CDirectGdiGcWrapper::Plot(const TPoint& aPoint)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
iContext->Plot(aPoint);
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
void CDirectGdiGcWrapper::Reset()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
iContext->Reset();
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
void CDirectGdiGcWrapper::SetBrushColor(const TRgb& aColor)
|
sl@0
|
253 |
{
|
sl@0
|
254 |
iContext->SetBrushColor(aColor);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
void CDirectGdiGcWrapper::SetBrushOrigin(const TPoint& aOrigin)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
iContext->SetBrushOrigin(aOrigin);
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
void CDirectGdiGcWrapper::SetBrushStyle(TBrushStyle aBrushStyle)
|
sl@0
|
263 |
{
|
sl@0
|
264 |
iContext->SetBrushStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aBrushStyle));
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
void CDirectGdiGcWrapper::SetClippingRegion(const TRegion& aRegion)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
CDirectGdiDriver* driver = CDirectGdiDriver::Static();
|
sl@0
|
270 |
driver->GetError(); //make sure that an error has been received
|
sl@0
|
271 |
iContext->SetClippingRegion(aRegion);
|
sl@0
|
272 |
TInt err = driver->GetError();
|
sl@0
|
273 |
SetError(err);
|
sl@0
|
274 |
if(err == KErrNone)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
iClippingRegion.Copy(aRegion);
|
sl@0
|
277 |
}
|
sl@0
|
278 |
}
|
sl@0
|
279 |
|
sl@0
|
280 |
void CDirectGdiGcWrapper::SetDrawMode(TDrawMode aDrawMode)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
iContext->SetDrawMode(MWsGraphicsContextToDirectGdiMappings::LossyConvert(aDrawMode));
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
void CDirectGdiGcWrapper::SetOrigin(const TPoint& aPoint)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
iContext->SetOrigin(aPoint);
|
sl@0
|
288 |
iOrigin = aPoint;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
void CDirectGdiGcWrapper::SetPenColor(const TRgb& aColor)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
iContext->SetPenColor(aColor);
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
void CDirectGdiGcWrapper::SetPenStyle(TPenStyle aPenStyle)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
iContext->SetPenStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aPenStyle));
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
void CDirectGdiGcWrapper::SetPenSize(const TSize& aSize)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
iContext->SetPenSize(aSize);
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
void CDirectGdiGcWrapper::SetTextShadowColor(const TRgb& aColor)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
iContext->SetTextShadowColor(aColor);
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
void CDirectGdiGcWrapper::SetCharJustification(TInt aExcessWidth, TInt aNumChars)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
iContext->SetCharJustification(aExcessWidth, aNumChars);
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
void CDirectGdiGcWrapper::SetWordJustification(TInt aExcessWidth, TInt aNumGaps)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
iContext->SetWordJustification(aExcessWidth, aNumGaps);
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
void CDirectGdiGcWrapper::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
iContext->SetUnderlineStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aUnderlineStyle));
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
void CDirectGdiGcWrapper::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
iContext->SetStrikethroughStyle(MWsGraphicsContextToDirectGdiMappings::Convert(aStrikethroughStyle));
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
void CDirectGdiGcWrapper::SetBrushPattern(const CFbsBitmap& aBitmap)
|
sl@0
|
332 |
{
|
sl@0
|
333 |
iContext->SetBrushPattern(aBitmap);
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
void CDirectGdiGcWrapper::SetBrushPattern(TInt aFbsBitmapHandle)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
iContext->SetBrushPattern(aFbsBitmapHandle);
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
void CDirectGdiGcWrapper::SetFont(const CFont* aFont)
|
sl@0
|
342 |
{
|
sl@0
|
343 |
iContext->SetFont(aFont);
|
sl@0
|
344 |
}
|
sl@0
|
345 |
|
sl@0
|
346 |
void CDirectGdiGcWrapper::CopyRect(const TPoint& aOffset, const TRect& aRect)
|
sl@0
|
347 |
{
|
sl@0
|
348 |
iContext->CopyRect(aOffset, aRect);
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
void CDirectGdiGcWrapper::UpdateJustification(const TDesC& aText, const TTextParameters* aParam)
|
sl@0
|
352 |
{
|
sl@0
|
353 |
iContext->UpdateJustification(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam));
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
void CDirectGdiGcWrapper::UpdateJustificationVertical(const TDesC& aText, const TTextParameters* aParam, TBool aUp)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
iContext->UpdateJustificationVertical(aText, MWsGraphicsContextToDirectGdiMappings::Convert(aParam), aUp);
|
sl@0
|
359 |
}
|
sl@0
|
360 |
|
sl@0
|
361 |
void CDirectGdiGcWrapper::SetFontNoDuplicate(const CFont* aFont)
|
sl@0
|
362 |
{
|
sl@0
|
363 |
iContext->SetFontNoDuplicate(static_cast<const CDirectGdiFont*>(aFont));
|
sl@0
|
364 |
}
|
sl@0
|
365 |
|
sl@0
|
366 |
TBool CDirectGdiGcWrapper::HasBrushPattern() const
|
sl@0
|
367 |
{
|
sl@0
|
368 |
return iContext->HasBrushPattern();
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
TBool CDirectGdiGcWrapper::HasFont() const
|
sl@0
|
372 |
{
|
sl@0
|
373 |
return iContext->HasFont();
|
sl@0
|
374 |
}
|
sl@0
|
375 |
|
sl@0
|
376 |
TRgb CDirectGdiGcWrapper::BrushColor() const
|
sl@0
|
377 |
{
|
sl@0
|
378 |
return iContext->BrushColor();
|
sl@0
|
379 |
}
|
sl@0
|
380 |
|
sl@0
|
381 |
TRgb CDirectGdiGcWrapper::PenColor() const
|
sl@0
|
382 |
{
|
sl@0
|
383 |
return iContext->PenColor();
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
TRgb CDirectGdiGcWrapper::TextShadowColor() const
|
sl@0
|
387 |
{
|
sl@0
|
388 |
return iContext->TextShadowColor();
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
TInt CDirectGdiGcWrapper::CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource)
|
sl@0
|
392 |
{
|
sl@0
|
393 |
CDirectGdiDriver* driver = CDirectGdiDriver::Static();
|
sl@0
|
394 |
if (!driver)
|
sl@0
|
395 |
{
|
sl@0
|
396 |
return KErrNotReady;
|
sl@0
|
397 |
}
|
sl@0
|
398 |
RDirectGdiDrawableSource* drawableSource = new RDirectGdiDrawableSource(*driver);
|
sl@0
|
399 |
if (!drawableSource)
|
sl@0
|
400 |
{
|
sl@0
|
401 |
return KErrNoMemory;
|
sl@0
|
402 |
}
|
sl@0
|
403 |
|
sl@0
|
404 |
//check usage flags if the drawable is an RSgImage
|
sl@0
|
405 |
RSgImage image;
|
sl@0
|
406 |
TInt res = image.Open(aDrawableId);
|
sl@0
|
407 |
if (res == KErrNone)
|
sl@0
|
408 |
{
|
sl@0
|
409 |
TSgImageInfo info;
|
sl@0
|
410 |
res = image.GetInfo(info);
|
sl@0
|
411 |
image.Close();
|
sl@0
|
412 |
if (res == KErrNone && !(info.iUsage & ESgUsageWindowGcSource))
|
sl@0
|
413 |
{
|
sl@0
|
414 |
res = KErrNotSupported;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
if (res != KErrNone)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
delete drawableSource;
|
sl@0
|
420 |
return res;
|
sl@0
|
421 |
}
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
RSgDrawable drawable;
|
sl@0
|
425 |
res = drawable.Open(aDrawableId, ESgDoNotRestrictUsage);
|
sl@0
|
426 |
if (res != KErrNone)
|
sl@0
|
427 |
{
|
sl@0
|
428 |
delete drawableSource;
|
sl@0
|
429 |
return res;
|
sl@0
|
430 |
}
|
sl@0
|
431 |
res = drawableSource->Create(drawable);
|
sl@0
|
432 |
drawable.Close();
|
sl@0
|
433 |
if (res != KErrNone)
|
sl@0
|
434 |
{
|
sl@0
|
435 |
delete drawableSource;
|
sl@0
|
436 |
return res;
|
sl@0
|
437 |
}
|
sl@0
|
438 |
res = iDrawableSources.InsertInAddressOrder(drawableSource);
|
sl@0
|
439 |
if (res != KErrNone)
|
sl@0
|
440 |
{
|
sl@0
|
441 |
drawableSource->Close();
|
sl@0
|
442 |
delete drawableSource;
|
sl@0
|
443 |
return res;
|
sl@0
|
444 |
}
|
sl@0
|
445 |
aSource = drawableSource;
|
sl@0
|
446 |
return KErrNone;
|
sl@0
|
447 |
}
|
sl@0
|
448 |
|
sl@0
|
449 |
void CDirectGdiGcWrapper::CloseDrawableSource(TAny* aSource)
|
sl@0
|
450 |
{
|
sl@0
|
451 |
RDirectGdiDrawableSource* drawableSource = static_cast<RDirectGdiDrawableSource*>(aSource);
|
sl@0
|
452 |
TInt index = iDrawableSources.FindInAddressOrder(drawableSource);
|
sl@0
|
453 |
if (index != KErrNotFound)
|
sl@0
|
454 |
{
|
sl@0
|
455 |
drawableSource->Close();
|
sl@0
|
456 |
delete drawableSource;
|
sl@0
|
457 |
iDrawableSources.Remove(index);
|
sl@0
|
458 |
}
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
void CDirectGdiGcWrapper::DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation)
|
sl@0
|
462 |
{
|
sl@0
|
463 |
const RDirectGdiDrawableSource* drawableSource = static_cast<const RDirectGdiDrawableSource*>(aSource);
|
sl@0
|
464 |
TInt index = iDrawableSources.FindInAddressOrder(drawableSource);
|
sl@0
|
465 |
if (index == KErrNotFound)
|
sl@0
|
466 |
{
|
sl@0
|
467 |
STD_ASSERT_DEBUG(0, EPluginPanicInvalidDrawableSource);
|
sl@0
|
468 |
return;
|
sl@0
|
469 |
}
|
sl@0
|
470 |
iContext->DrawResource(aPos, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation);
|
sl@0
|
471 |
}
|
sl@0
|
472 |
|
sl@0
|
473 |
void CDirectGdiGcWrapper::DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
const RDirectGdiDrawableSource* drawableSource = static_cast<const RDirectGdiDrawableSource*>(aSource);
|
sl@0
|
476 |
TInt index = iDrawableSources.FindInAddressOrder(drawableSource);
|
sl@0
|
477 |
if (index == KErrNotFound)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
STD_ASSERT_DEBUG(0, EPluginPanicInvalidDrawableSource);
|
sl@0
|
480 |
return;
|
sl@0
|
481 |
}
|
sl@0
|
482 |
iContext->DrawResource(aRect, *drawableSource, (DirectGdi::TGraphicsRotation)aRotation);
|
sl@0
|
483 |
}
|
sl@0
|
484 |
|
sl@0
|
485 |
void CDirectGdiGcWrapper::DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation)
|
sl@0
|
486 |
{
|
sl@0
|
487 |
const RDirectGdiDrawableSource* drawableSource = static_cast<const RDirectGdiDrawableSource*>(aSource);
|
sl@0
|
488 |
TInt index = iDrawableSources.FindInAddressOrder(drawableSource);
|
sl@0
|
489 |
if (index == KErrNotFound)
|
sl@0
|
490 |
{
|
sl@0
|
491 |
STD_ASSERT_DEBUG(0, EPluginPanicInvalidDrawableSource);
|
sl@0
|
492 |
return;
|
sl@0
|
493 |
}
|
sl@0
|
494 |
iContext->DrawResource(aRectDest, *drawableSource, aRectSrc, (DirectGdi::TGraphicsRotation)aRotation);
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
void CDirectGdiGcWrapper::DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aDes)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
const RDirectGdiDrawableSource* drawableSource = static_cast<const RDirectGdiDrawableSource*>(aSource);
|
sl@0
|
500 |
TInt index = iDrawableSources.FindInAddressOrder(drawableSource);
|
sl@0
|
501 |
if (index == KErrNotFound)
|
sl@0
|
502 |
{
|
sl@0
|
503 |
STD_ASSERT_DEBUG(0, EPluginPanicInvalidDrawableSource);
|
sl@0
|
504 |
return;
|
sl@0
|
505 |
}
|
sl@0
|
506 |
iContext->DrawResource(aRect, *drawableSource, aDes);
|
sl@0
|
507 |
}
|
sl@0
|
508 |
|
sl@0
|
509 |
/**
|
sl@0
|
510 |
Sets the error code. If the error code is already set to a value other
|
sl@0
|
511 |
than KErrNone, the error code will not be modified.
|
sl@0
|
512 |
|
sl@0
|
513 |
@param aErr The error code to set.
|
sl@0
|
514 |
|
sl@0
|
515 |
@post The error code has been set.
|
sl@0
|
516 |
*/
|
sl@0
|
517 |
void CDirectGdiGcWrapper::SetError(TInt aError)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
if (aError != KErrNone && iErrorCode == KErrNone)
|
sl@0
|
520 |
{
|
sl@0
|
521 |
iErrorCode = aError;
|
sl@0
|
522 |
}
|
sl@0
|
523 |
}
|
sl@0
|
524 |
|
sl@0
|
525 |
/**
|
sl@0
|
526 |
Returns the first error code (set as the result of calling some CDirectGdiGcWrapper API), if any,
|
sl@0
|
527 |
since the last call to this function or, if it has not previously been called, since
|
sl@0
|
528 |
the CDirectGdiGcWrapper was constructed. Calling this function clears the error code.
|
sl@0
|
529 |
|
sl@0
|
530 |
@post The error code has been reset after being read.
|
sl@0
|
531 |
|
sl@0
|
532 |
@return The first error code, if any, since the last call to this function or,
|
sl@0
|
533 |
if it has not previously been called, since the CDirectGdiGcWrapper was constructed.
|
sl@0
|
534 |
KErrNone will indicate that no such error has occurred.
|
sl@0
|
535 |
*/
|
sl@0
|
536 |
TInt CDirectGdiGcWrapper::GetError()
|
sl@0
|
537 |
{
|
sl@0
|
538 |
TInt err = iErrorCode;
|
sl@0
|
539 |
iErrorCode = KErrNone;
|
sl@0
|
540 |
return err;
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
TPoint CDirectGdiGcWrapper::Origin() const
|
sl@0
|
544 |
{
|
sl@0
|
545 |
return iOrigin;
|
sl@0
|
546 |
}
|
sl@0
|
547 |
|
sl@0
|
548 |
const TRegion& CDirectGdiGcWrapper::ClippingRegion()
|
sl@0
|
549 |
{
|
sl@0
|
550 |
return iClippingRegion;
|
sl@0
|
551 |
}
|
sl@0
|
552 |
|
sl@0
|
553 |
TInt CDirectGdiGcWrapper::Push()
|
sl@0
|
554 |
{
|
sl@0
|
555 |
// the buf format is len+data where data is written by the GC's ExternalizeL()
|
sl@0
|
556 |
iGcBuf->Reset();
|
sl@0
|
557 |
CBufBase& buf = *iGcBuf;
|
sl@0
|
558 |
const TInt start = buf.Size();
|
sl@0
|
559 |
RBufWriteStream out(buf,start);
|
sl@0
|
560 |
TRAPD(err,out.WriteInt32L(0));
|
sl@0
|
561 |
if(!err)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
TRAP(err,iContext->ExternalizeL(out));
|
sl@0
|
564 |
}
|
sl@0
|
565 |
if(err) //rollback addition
|
sl@0
|
566 |
{
|
sl@0
|
567 |
buf.Delete(start,buf.Size()-start);
|
sl@0
|
568 |
}
|
sl@0
|
569 |
else //fixup len
|
sl@0
|
570 |
{
|
sl@0
|
571 |
TRAP_IGNORE(out.CommitL();) // can't see this failing
|
sl@0
|
572 |
TPckgBuf<TInt32> pckg(buf.Size()-sizeof(TInt32)-start);
|
sl@0
|
573 |
buf.Write(start,pckg);
|
sl@0
|
574 |
}
|
sl@0
|
575 |
return err;
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
void CDirectGdiGcWrapper::Pop()
|
sl@0
|
579 |
{
|
sl@0
|
580 |
CBufBase& buf = *iGcBuf;
|
sl@0
|
581 |
TInt ofs = 0;
|
sl@0
|
582 |
FOREVER
|
sl@0
|
583 |
{
|
sl@0
|
584 |
TInt chunk = 0;
|
sl@0
|
585 |
RBufReadStream in(buf,ofs);
|
sl@0
|
586 |
TRAPD(err,chunk = in.ReadInt32L());
|
sl@0
|
587 |
if(err)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
STD_ASSERT_DEBUG(err != 0, EPluginPanicPopGcSettings);
|
sl@0
|
590 |
return;
|
sl@0
|
591 |
}
|
sl@0
|
592 |
if(ofs+sizeof(TInt32)+chunk >= buf.Size()) // the last chunk?
|
sl@0
|
593 |
{
|
sl@0
|
594 |
TRAP_IGNORE(iContext->InternalizeL(in));
|
sl@0
|
595 |
buf.Delete(ofs,buf.Size()-ofs);
|
sl@0
|
596 |
return;
|
sl@0
|
597 |
}
|
sl@0
|
598 |
ofs += chunk + sizeof(TInt32);
|
sl@0
|
599 |
}
|
sl@0
|
600 |
}
|
sl@0
|
601 |
|
sl@0
|
602 |
//Default method of fading simply uses bitgdi to perform fading
|
sl@0
|
603 |
void CDirectGdiGcWrapper::FadeArea(const TRegion& aRegion)
|
sl@0
|
604 |
{
|
sl@0
|
605 |
if (!&aRegion || aRegion.CheckError())
|
sl@0
|
606 |
return;
|
sl@0
|
607 |
|
sl@0
|
608 |
iContext->Reset();
|
sl@0
|
609 |
iContext->SetClippingRegion(aRegion);
|
sl@0
|
610 |
iContext->SetPenStyle(DirectGdi::ENullPen);
|
sl@0
|
611 |
iContext->SetBrushStyle(DirectGdi::ESolidBrush);
|
sl@0
|
612 |
iContext->SetBrushColor(iFadeColor);
|
sl@0
|
613 |
iContext->DrawRect(aRegion.BoundingRect());
|
sl@0
|
614 |
}
|
sl@0
|
615 |
|
sl@0
|
616 |
//Default method of fading expects two TUint8's describing the black/white map
|
sl@0
|
617 |
//as possible fading parameters
|
sl@0
|
618 |
void CDirectGdiGcWrapper::SetFadingParameters(const TDesC8& aData)
|
sl@0
|
619 |
{
|
sl@0
|
620 |
TPckgBuf<TFadingParams> buf;
|
sl@0
|
621 |
buf.Copy(aData);
|
sl@0
|
622 |
TFadingParams parameters = buf();
|
sl@0
|
623 |
|
sl@0
|
624 |
//Situations where blackMap > whiteMap are NOT supported
|
sl@0
|
625 |
if (parameters.blackMap > parameters.whiteMap)
|
sl@0
|
626 |
{
|
sl@0
|
627 |
TUint8 oldMap = parameters.blackMap;
|
sl@0
|
628 |
parameters.blackMap = parameters.whiteMap;
|
sl@0
|
629 |
parameters.whiteMap = oldMap;
|
sl@0
|
630 |
}
|
sl@0
|
631 |
|
sl@0
|
632 |
//CFbsBitGc::FadeArea() does the following per color component:
|
sl@0
|
633 |
// dst = dst * (whiteMap - blackMap) + blackMap;
|
sl@0
|
634 |
|
sl@0
|
635 |
//To achieve the same effect using MWsGraphicsContext we draw a rectangle
|
sl@0
|
636 |
//with specific intensity and alpha values:
|
sl@0
|
637 |
// dst = dst * (1 - alpha) + intensity * alpha;
|
sl@0
|
638 |
//Thus:
|
sl@0
|
639 |
// alpha = 1 - whiteMap + blackMap;
|
sl@0
|
640 |
// intensity = blackMap / alpha;
|
sl@0
|
641 |
|
sl@0
|
642 |
// alpha = 1 - whiteMap + blackMap;
|
sl@0
|
643 |
TInt alpha = 255 - parameters.whiteMap + parameters.blackMap;
|
sl@0
|
644 |
// intensity = blackMap / alpha;
|
sl@0
|
645 |
TInt i = (parameters.blackMap * iLut[alpha]) >> 8;
|
sl@0
|
646 |
|
sl@0
|
647 |
iFadeColor.SetInternal(i << 16 | i << 8 | i | alpha << 24);
|
sl@0
|
648 |
}
|
sl@0
|
649 |
|
sl@0
|
650 |
void CDirectGdiGcWrapper::DrawTextCursor(const TTextCursorInfo& aTextCursorInfo)
|
sl@0
|
651 |
{
|
sl@0
|
652 |
/*
|
sl@0
|
653 |
* This function is written with the following assumption:
|
sl@0
|
654 |
* The UI Toolkit uses text entry windows with a white background
|
sl@0
|
655 |
* and black text, but always requests a white text cursor.
|
sl@0
|
656 |
*
|
sl@0
|
657 |
* We therefore ignore the KRgbWhite text cursor cursor supplied
|
sl@0
|
658 |
* and use a Black overprinting strategy instead.
|
sl@0
|
659 |
*/
|
sl@0
|
660 |
STD_ASSERT_ALWAYS(
|
sl@0
|
661 |
aTextCursorInfo.iTextCursorType == TTextCursor::ETypeRectangle ||
|
sl@0
|
662 |
aTextCursorInfo.iTextCursorType == TTextCursor::ETypeHollowRectangle,
|
sl@0
|
663 |
EPluginPanicInvalidCursorType
|
sl@0
|
664 |
);
|
sl@0
|
665 |
|
sl@0
|
666 |
TRegionFix<1> fullWindowRegion;
|
sl@0
|
667 |
const TRegion* clippingRegion = &aTextCursorInfo.iRegion;
|
sl@0
|
668 |
if (aTextCursorInfo.iRegion.CheckError())
|
sl@0
|
669 |
{
|
sl@0
|
670 |
fullWindowRegion.AddRect(aTextCursorInfo.iWindow->AbsRect());
|
sl@0
|
671 |
clippingRegion = &fullWindowRegion;
|
sl@0
|
672 |
}
|
sl@0
|
673 |
|
sl@0
|
674 |
if (clippingRegion->IsEmpty())
|
sl@0
|
675 |
{
|
sl@0
|
676 |
return;
|
sl@0
|
677 |
}
|
sl@0
|
678 |
|
sl@0
|
679 |
iContext->SetDrawMode(DirectGdi::EDrawModePEN);
|
sl@0
|
680 |
switch (aTextCursorInfo.iTextCursorType)
|
sl@0
|
681 |
{
|
sl@0
|
682 |
case TTextCursor::ETypeRectangle:
|
sl@0
|
683 |
{
|
sl@0
|
684 |
iContext->SetBrushStyle(DirectGdi::ESolidBrush);
|
sl@0
|
685 |
iContext->SetPenStyle(DirectGdi::ENullPen);
|
sl@0
|
686 |
iContext->SetBrushColor(KRgbBlack);
|
sl@0
|
687 |
}
|
sl@0
|
688 |
break;
|
sl@0
|
689 |
case TTextCursor::ETypeHollowRectangle:
|
sl@0
|
690 |
{
|
sl@0
|
691 |
iContext->SetBrushStyle(DirectGdi::ENullBrush);
|
sl@0
|
692 |
iContext->SetPenStyle(DirectGdi::ESolidPen);
|
sl@0
|
693 |
iContext->SetPenColor(KRgbBlack);
|
sl@0
|
694 |
}
|
sl@0
|
695 |
break;
|
sl@0
|
696 |
}
|
sl@0
|
697 |
iContext->SetClippingRegion(*clippingRegion);
|
sl@0
|
698 |
/*
|
sl@0
|
699 |
* During Sprite drawing, the GC gets reset. Possibly other code could
|
sl@0
|
700 |
* have done this also. So make sure we setup the origin so that window-relative
|
sl@0
|
701 |
* co-ordinates work as expected; iCursorRect is in window co-ordinates.
|
sl@0
|
702 |
*/
|
sl@0
|
703 |
iContext->SetOrigin(aTextCursorInfo.iWindow->Origin());
|
sl@0
|
704 |
iContext->DrawRect(aTextCursorInfo.iCursorRect);
|
sl@0
|
705 |
}
|