46
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: NVG Decoder source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "NVGTLVIcon.h"
|
|
21 |
#include "NVGIconData.h"
|
|
22 |
#include "NVGUtil.h"
|
|
23 |
#include "TLVRenderer.h"
|
|
24 |
#include "TLVIconCreator.h"
|
|
25 |
#include "TLVIconRenderer.h"
|
|
26 |
#include "OpenVGHandleStore.h"
|
|
27 |
|
|
28 |
CNVGTLVIcon::CNVGTLVIcon()
|
|
29 |
: iNVGIconData(0),
|
|
30 |
iVGImageBinder(0)
|
|
31 |
{
|
|
32 |
}
|
|
33 |
|
|
34 |
CNVGTLVIcon::~CNVGTLVIcon()
|
|
35 |
{
|
|
36 |
delete iNVGIconData;
|
|
37 |
delete iOpenVGHandles;
|
|
38 |
}
|
|
39 |
|
|
40 |
CNVGTLVIcon * CNVGTLVIcon::NewL()
|
|
41 |
{
|
|
42 |
CNVGTLVIcon* self = CNVGTLVIcon::NewLC();
|
|
43 |
CleanupStack::Pop(self);
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
CNVGTLVIcon * CNVGTLVIcon::NewLC()
|
|
48 |
{
|
|
49 |
CNVGTLVIcon* self = new (ELeave) CNVGTLVIcon;
|
|
50 |
CleanupStack::PushL(self);
|
|
51 |
|
|
52 |
self->ConstructL();
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
void CNVGTLVIcon::ConstructL()
|
|
57 |
{
|
|
58 |
iNVGIconData = CNVGIconData::NewL();
|
|
59 |
iOpenVGHandles = COpenVGHandleStore::NewL();
|
|
60 |
}
|
|
61 |
|
|
62 |
TInt CNVGTLVIcon::SetPreserveAspectRatio(TInt aPreserveAspectSetting,
|
|
63 |
TInt aSmilFitSetting)
|
|
64 |
{
|
|
65 |
(void)aPreserveAspectSetting;
|
|
66 |
(void)aSmilFitSetting;
|
|
67 |
|
|
68 |
return KErrNotSupported;
|
|
69 |
}
|
|
70 |
|
|
71 |
TInt CNVGTLVIcon::Rotate(TReal32 aAngle, TReal32 aX, TReal32 aY) __SOFTFP
|
|
72 |
{
|
|
73 |
(void)aAngle;
|
|
74 |
(void)aX;
|
|
75 |
(void)aY;
|
|
76 |
|
|
77 |
return KErrNotSupported;
|
|
78 |
}
|
|
79 |
|
|
80 |
TInt CNVGTLVIcon::DirectDrawL(const TDesC8& aBuf, const TSize& aTargetSize)
|
|
81 |
{
|
|
82 |
TInt error = KErrNone;
|
|
83 |
|
|
84 |
CTLVRenderer * iconRenderer = CTLVRenderer::NewLC(aBuf, aTargetSize.iWidth, aTargetSize.iHeight);
|
|
85 |
|
|
86 |
iconRenderer->SetVGImageBinder(iVGImageBinder);
|
|
87 |
|
|
88 |
iconRenderer->ExecuteL();
|
|
89 |
|
|
90 |
CleanupStack::PopAndDestroy(iconRenderer);
|
|
91 |
|
|
92 |
return error;
|
|
93 |
}
|
|
94 |
|
|
95 |
TInt CNVGTLVIcon::CreateL(const TDesC8& aBuf, const TSize& aTargetSize)
|
|
96 |
{
|
|
97 |
TInt error = KErrNone;
|
|
98 |
|
|
99 |
CTLVIconCreator * iconCreater = CTLVIconCreator::NewLC(aBuf, aTargetSize.iWidth, aTargetSize.iHeight, this);
|
|
100 |
|
|
101 |
iconCreater->ExecuteL();
|
|
102 |
|
|
103 |
CleanupStack::PopAndDestroy(iconCreater);
|
|
104 |
return error;
|
|
105 |
}
|
|
106 |
|
|
107 |
TInt CNVGTLVIcon::Draw(const TSize aSize, CNvgEngine * aNVGEngine)
|
|
108 |
{
|
|
109 |
TInt error = KErrNone;
|
|
110 |
iNVGEngine = aNVGEngine;
|
|
111 |
UpdateClientMatrices();
|
|
112 |
|
|
113 |
TRAP(error, DoDrawL(aSize));
|
|
114 |
RestoreClientMatrices();
|
|
115 |
return error;
|
|
116 |
}
|
|
117 |
TInt CNVGTLVIcon::DoDrawL(const TSize aSize)
|
|
118 |
{
|
|
119 |
TPtr8 bufPtr = ((HBufC8 *)(iNVGIconData->GetNVGData()))->Des();
|
|
120 |
|
|
121 |
CTLVRenderer * iconRenderer = CTLVIconRenderer::NewLC(bufPtr, aSize.iWidth, aSize.iHeight);
|
|
122 |
|
|
123 |
iconRenderer->SetVGImageBinder(iVGImageBinder);
|
|
124 |
|
|
125 |
#ifndef __MIRROR_
|
|
126 |
vgScale(1.0f, -1.0f);
|
|
127 |
vgTranslate(0, (VGfloat)(-aSize.iHeight));
|
|
128 |
#endif
|
|
129 |
iconRenderer->ExecuteL();
|
|
130 |
|
|
131 |
CleanupStack::PopAndDestroy(iconRenderer);
|
|
132 |
return KErrNone;
|
|
133 |
}
|
|
134 |
|
|
135 |
void CNVGTLVIcon::AddDrawPathCommandL(VGPath aPath, VGPaintMode aPaintMode)
|
|
136 |
{
|
|
137 |
iOpenVGHandles->AddPathDHL(aPath);
|
|
138 |
iNVGIconData->EncodeInt8L(EPath);
|
|
139 |
iNVGIconData->EncodeInt32L(aPath);
|
|
140 |
iNVGIconData->EncodeInt32L(aPaintMode);
|
|
141 |
}
|
|
142 |
|
|
143 |
void CNVGTLVIcon::AddCommandL(const TUint8 * aCommandBuffer, TInt aCommandBufferLength)
|
|
144 |
{
|
|
145 |
iNVGIconData->EncodeDataL(aCommandBuffer, aCommandBufferLength);
|
|
146 |
}
|
|
147 |
|
|
148 |
void CNVGTLVIcon::AddCommandL(TInt8 aCommandType, const TUint8 * aCommandBuffer, TInt aCommandBufferLength)
|
|
149 |
{
|
|
150 |
iNVGIconData->EncodeInt8L(aCommandType);
|
|
151 |
iNVGIconData->EncodeDataL(aCommandBuffer, aCommandBufferLength);
|
|
152 |
}
|
|
153 |
void CNVGTLVIcon::UpdateClientMatrices()
|
|
154 |
{
|
|
155 |
iMatrixMode = vgGeti(VG_MATRIX_MODE);
|
|
156 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
157 |
vgGetMatrix(iPathMatrix);
|
|
158 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
|
159 |
vgGetMatrix(iImageMatrix);
|
|
160 |
vgSeti(VG_MATRIX_MODE, iMatrixMode);
|
|
161 |
}
|
|
162 |
|
|
163 |
void CNVGTLVIcon::RestoreClientMatrices()
|
|
164 |
{
|
|
165 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
166 |
vgLoadMatrix(iPathMatrix);
|
|
167 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
|
168 |
vgLoadMatrix(iImageMatrix);
|
|
169 |
vgSeti(VG_MATRIX_MODE, iMatrixMode);
|
|
170 |
}
|