56
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
|
|
20 |
#include "HgVgSkinRenderer.h"
|
|
21 |
#include "HgVgHelper.h"
|
|
22 |
#include "HgVgDrawBuffer.h"
|
|
23 |
|
|
24 |
#include <ganes.mbg>
|
|
25 |
#include <AknIconUtils.h>
|
|
26 |
#include <avkon.mbg>
|
|
27 |
#include <AknsDrawUtils.h>
|
|
28 |
#include <touchfeedback.h>
|
|
29 |
#include <gulicon.h>
|
|
30 |
#include <AknUtils.h>
|
|
31 |
#include <layoutmetadata.cdl.h>
|
|
32 |
#include <AknLayout2ScalableDef.h>
|
|
33 |
#include <e32math.h>
|
|
34 |
#include <gulcolor.h>
|
|
35 |
|
|
36 |
#include <AknsDrawUtils.h>
|
|
37 |
|
|
38 |
|
|
39 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// CHgVgSkinRenderer::NewL()
|
|
42 |
// Two-phased constructor.
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CHgVgSkinRenderer* CHgVgSkinRenderer::NewL(const TRect& aRect)
|
|
46 |
{
|
|
47 |
CHgVgSkinRenderer* self = new ( ELeave ) CHgVgSkinRenderer(aRect);
|
|
48 |
CleanupStack::PushL (self );
|
|
49 |
self->ConstructL();
|
|
50 |
CleanupStack::Pop ( self );
|
|
51 |
return self;
|
|
52 |
}
|
|
53 |
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
// CHgVgSkinRenderer::ConstructL()
|
|
56 |
// Symbian 2nd phase constructor can leave.
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
void CHgVgSkinRenderer::ConstructL ()
|
|
60 |
{
|
|
61 |
|
|
62 |
iDrawBuffer = CHgVgDrawBuffer::NewL( TSize(iRect.Width(), iRect.Height()), EColor16MA );
|
|
63 |
|
|
64 |
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CHgVgSkinRenderer::CHgVgSkinRenderer()
|
|
69 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CHgVgSkinRenderer::CHgVgSkinRenderer(const TRect& aRect) : iRect(aRect)
|
|
73 |
{
|
|
74 |
|
|
75 |
}
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// CHgVgSkinRenderer::~CHgVgSkinRenderer()
|
|
79 |
// Destructor.
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
CHgVgSkinRenderer::~CHgVgSkinRenderer ( )
|
|
83 |
{
|
|
84 |
|
|
85 |
delete iDrawBuffer;
|
|
86 |
|
|
87 |
vgDestroyImage(iSkinImage);
|
|
88 |
|
|
89 |
}
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// CHgVgSkinRenderer::UpdateSkin()
|
|
93 |
// Updates skin image.
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CHgVgSkinRenderer::UpdateSkinL(const MObjectProvider* aProvider,
|
|
97 |
const CCoeControl* aControl)
|
|
98 |
{
|
|
99 |
// destroy old vg image
|
|
100 |
if (iSkinImage != VG_INVALID_HANDLE)
|
|
101 |
{
|
|
102 |
vgDestroyImage(iSkinImage);
|
|
103 |
iSkinImage = VG_INVALID_HANDLE;
|
|
104 |
}
|
|
105 |
|
|
106 |
// render skin to draw buffer
|
|
107 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
108 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( aProvider );
|
|
109 |
if( AknsDrawUtils::DrawBackground( skin, cc, aControl, iDrawBuffer->Gc(), TPoint(0,0),
|
|
110 |
aControl->Rect(), KAknsDrawParamDefault ) )
|
|
111 |
{
|
|
112 |
// create new image for the skin
|
|
113 |
iSkinImage = vgCreateImage(VG_sRGBA_8888,
|
|
114 |
iRect.Width(), iRect.Height(),
|
|
115 |
VG_IMAGE_QUALITY_NONANTIALIASED);
|
|
116 |
|
|
117 |
// handle out of memory
|
|
118 |
if( iSkinImage == VG_INVALID_HANDLE )
|
|
119 |
{
|
|
120 |
User::Leave(KErrNoMemory);
|
|
121 |
}
|
|
122 |
|
|
123 |
// Copy to draw buffer to vg image
|
|
124 |
iDrawBuffer->GetDrawBufferToVgImage(TRect(TPoint(0,0), TPoint(iRect.Width(), iRect.Height())),
|
|
125 |
TPoint(0,0), iSkinImage, VG_sARGB_8888);
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
void CHgVgSkinRenderer::SetRect( const TRect& aRect )
|
|
130 |
{
|
|
131 |
iRect = aRect;
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CHgVgSkinRenderer::Draw
|
|
136 |
// Draws skin.
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CHgVgSkinRenderer::Draw() const
|
|
140 |
{
|
|
141 |
|
|
142 |
VGfloat color[] = {255,255,255,0};
|
|
143 |
vgSetfv(VG_CLEAR_COLOR, 4, color);
|
|
144 |
if(iLandscape)
|
|
145 |
vgClear(0, 0, iRect.Height(), iRect.Width());
|
|
146 |
else
|
|
147 |
vgClear(0, 0, iRect.Width(), iRect.Height());
|
|
148 |
|
|
149 |
if( iSkinImage != VG_INVALID_HANDLE )
|
|
150 |
HgVgHelper::DrawImage(iSkinImage, TPoint(0, 0), iRect, EFalse, iLandscape);
|
|
151 |
}
|
|
152 |
|
|
153 |
void CHgVgSkinRenderer::EnableLanscapeRendering(TBool aLandscape)
|
|
154 |
{
|
|
155 |
iLandscape = aLandscape;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
// End of File
|