|
1 // Copyright (c) 1995-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "stdgraphicdrawer.h" |
|
17 #include "wsgraphicdrawercontext.h" |
|
18 #include <s32mem.h> |
|
19 #include <fbs.h> |
|
20 |
|
21 CWsGraphicDrawerBitmap* CWsGraphicDrawerBitmap::CreateL() |
|
22 { |
|
23 return new(ELeave) CWsGraphicDrawerBitmap; |
|
24 } |
|
25 |
|
26 void CWsGraphicDrawerBitmap::ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& aData) |
|
27 { |
|
28 TInt bitmapHandle = 0; |
|
29 TInt maskHandle = 0; |
|
30 RDesReadStream in(aData); |
|
31 in.PushL(); |
|
32 bitmapHandle = in.ReadInt32L(); |
|
33 maskHandle = in.ReadInt32L(); |
|
34 in.Pop(); |
|
35 BaseConstructL(aEnv,aId,aOwner); |
|
36 if(bitmapHandle) |
|
37 { |
|
38 iBitmap = new(ELeave) CFbsBitmap; |
|
39 User::LeaveIfError(iBitmap->Duplicate(bitmapHandle)); |
|
40 if(maskHandle) |
|
41 { |
|
42 iMask = new(ELeave) CFbsBitmap; |
|
43 User::LeaveIfError(iMask->Duplicate(maskHandle)); |
|
44 } |
|
45 } |
|
46 if (!(aEnv.Screen(0)->ResolveObjectInterface(KMWsCompositionContext) || aEnv.Screen(0)->ResolveObjectInterface(KMWsScene))) |
|
47 { |
|
48 iContext = CWsGraphicDrawerNonNgaContext::NewL(); |
|
49 } |
|
50 else |
|
51 { |
|
52 iContext = CWsGraphicDrawerNgaContext::NewL(); |
|
53 } |
|
54 } |
|
55 |
|
56 CWsGraphicDrawerBitmap::CWsGraphicDrawerBitmap() |
|
57 { |
|
58 } |
|
59 |
|
60 CWsGraphicDrawerBitmap::~CWsGraphicDrawerBitmap() |
|
61 { |
|
62 if (iContext) |
|
63 { |
|
64 iContext->Destroy(); |
|
65 iContext = NULL; |
|
66 } |
|
67 delete iBitmap; |
|
68 delete iMask; |
|
69 } |
|
70 |
|
71 void CWsGraphicDrawerBitmap::DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& /*aData*/) const |
|
72 { |
|
73 if (iBitmap) |
|
74 { |
|
75 if (KErrNone != iContext->Push(aGc)) |
|
76 { |
|
77 return; |
|
78 } |
|
79 TRect bmpRect(aRect.iTl,iBitmap->SizeInPixels()); |
|
80 bmpRect.Intersection(aRect); |
|
81 iContext->DrawBitmap(aGc, aRect.iTl, iBitmap, bmpRect.Size(), iMask); |
|
82 iContext->Pop(aGc); |
|
83 } |
|
84 } |
|
85 |
|
86 void CWsGraphicDrawerBitmap::HandleMessage(const TDesC8& /*aData*/) |
|
87 { |
|
88 } |
|
89 |