24
|
1 |
// Copyright (c) 2010 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 |
// Client-side state information for Open VG handle based objects.
|
|
15 |
|
|
16 |
#include "vgstate.h"
|
|
17 |
#include "remotefunctioncall.h"
|
|
18 |
#include "openvgrfc.h"
|
|
19 |
|
|
20 |
|
|
21 |
// defintions for all static member data for CVgHandleBase family of classes
|
|
22 |
THandleGen CVgHandleBase::iHandleGen; // for creating local UIDs for clients to use as VG Handles
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
27 |
// THandleGen
|
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
29 |
|
|
30 |
void THandleGen::Init(TUint aInit)
|
|
31 |
{
|
|
32 |
OPENVG_TRACE("THandleGen::Init aInit=0x%x", aInit);
|
|
33 |
VGPANIC_ASSERT_DEBUG(aInit != 0, EVgPanicUidGeneratorZeroSeed);
|
|
34 |
iValue = aInit;
|
|
35 |
}
|
|
36 |
|
|
37 |
|
|
38 |
TUint THandleGen::NextUid()
|
|
39 |
{
|
|
40 |
VGPANIC_ASSERT_DEBUG(iValue != 0, EVgPanicUidGeneratorZeroSeed);
|
|
41 |
TUint result = iValue;
|
|
42 |
++iValue;
|
|
43 |
if (iValue == 0)
|
|
44 |
iValue = 1;
|
|
45 |
return result;
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
50 |
// CVgHandleBase = base class for CVgImageInfo etc...
|
|
51 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
52 |
|
|
53 |
// Client Handle generates local UIDs for each VG Handle based object created
|
|
54 |
void CVgHandleBase::InitStatics()
|
|
55 |
{
|
|
56 |
// valued of first Client side VG Handle
|
|
57 |
TUint seed = 0x00010000;
|
|
58 |
iHandleGen.Init(seed);
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
void CVgHandleBase::Destroy(MVgContext& aVgContext)
|
|
63 |
{
|
|
64 |
VGPANIC_ASSERT_DEBUG(!IsDestroyed(), EVgPanicHandleAlreadyMarkedDestroyed);
|
|
65 |
iIsDestroyed = ETrue;
|
|
66 |
if (DestroyObject(aVgContext))
|
|
67 |
{
|
|
68 |
RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
|
|
69 |
OpenVgState.UnMapHandle(iClientHandle);
|
|
70 |
delete this;
|
|
71 |
CVghwUtils::SwitchFromVghwHeap(clientHeap);
|
|
72 |
}
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
VGint CVgHandleBase::HostVgGetParameterVectorSize(MVgContext& aVgContext, VGint aParamType)
|
|
77 |
{
|
|
78 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
79 |
vgApiData.Init(OpenVgRFC::EvgGetParameterVectorSize);
|
|
80 |
vgApiData.AppendParam(HostHandle());
|
|
81 |
vgApiData.AppendParam(aParamType);
|
|
82 |
VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode);
|
|
83 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
84 |
return static_cast<VGint>(vgApiData.ReturnValue());
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
VGint CVgHandleBase::HostVgGetParameteri(MVgContext& aVgContext, VGint aParamType)
|
|
89 |
{
|
|
90 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
91 |
vgApiData.Init(OpenVgRFC::EvgGetParameteri);
|
|
92 |
vgApiData.AppendParam(HostHandle());
|
|
93 |
vgApiData.AppendParam(aParamType);
|
|
94 |
VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode);
|
|
95 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
96 |
return static_cast<VGint>(vgApiData.ReturnValue());
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
VGfloat CVgHandleBase::HostVgGetParameterf(MVgContext& aVgContext, VGint aParamType)
|
|
101 |
{
|
|
102 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
103 |
vgApiData.Init(OpenVgRFC::EvgGetParameterf);
|
|
104 |
vgApiData.AppendParam(HostHandle());
|
|
105 |
vgApiData.AppendParam(aParamType);
|
|
106 |
VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode);
|
|
107 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
108 |
return static_cast<VGfloat>(vgApiData.ReturnValue());
|
|
109 |
}
|
|
110 |
|
|
111 |
|
|
112 |
void CVgHandleBase::HostVgGetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues)
|
|
113 |
{
|
|
114 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
115 |
vgApiData.Init(OpenVgRFC::EvgGetParameterfv);
|
|
116 |
vgApiData.AppendParam(iHostHandle);
|
|
117 |
vgApiData.AppendParam(aParamType);
|
|
118 |
vgApiData.AppendParam(aCount);
|
|
119 |
vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut);
|
|
120 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
void CVgHandleBase::HostVgGetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues)
|
|
125 |
{
|
|
126 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
127 |
vgApiData.Init(OpenVgRFC::EvgGetParameteriv);
|
|
128 |
vgApiData.AppendParam(iHostHandle);
|
|
129 |
vgApiData.AppendParam(aParamType);
|
|
130 |
vgApiData.AppendParam(aCount);
|
|
131 |
vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut);
|
|
132 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
void CVgHandleBase::HostVgSetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue)
|
|
137 |
{
|
|
138 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
139 |
vgApiData.Init(OpenVgRFC::EvgSetParameterf, RemoteFunctionCallData::EOpRequest);
|
|
140 |
vgApiData.AppendParam(iHostHandle);
|
|
141 |
vgApiData.AppendParam(aParamType);
|
|
142 |
vgApiData.AppendParam(aValue);
|
|
143 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
void CVgHandleBase::HostVgSetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue)
|
|
148 |
{
|
|
149 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
150 |
vgApiData.Init(OpenVgRFC::EvgSetParameteri, RemoteFunctionCallData::EOpRequest);
|
|
151 |
vgApiData.AppendParam(iHostHandle);
|
|
152 |
vgApiData.AppendParam(aParamType);
|
|
153 |
vgApiData.AppendParam(aValue);
|
|
154 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
void CVgHandleBase::HostVgSetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues)
|
|
159 |
{
|
|
160 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
161 |
vgApiData.Init(OpenVgRFC::EvgSetParameterfv, RemoteFunctionCallData::EOpRequest);
|
|
162 |
vgApiData.AppendParam(iHostHandle);
|
|
163 |
vgApiData.AppendParam(aParamType);
|
|
164 |
vgApiData.AppendParam(aCount);
|
|
165 |
vgApiData.AppendVector(aValues, aCount);
|
|
166 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
void CVgHandleBase::HostVgSetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues)
|
|
171 |
{
|
|
172 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
173 |
vgApiData.Init(OpenVgRFC::EvgSetParameteriv, RemoteFunctionCallData::EOpRequest);
|
|
174 |
vgApiData.AppendParam(iHostHandle);
|
|
175 |
vgApiData.AppendParam(aParamType);
|
|
176 |
vgApiData.AppendParam(aCount);
|
|
177 |
vgApiData.AppendVector(aValues, aCount);
|
|
178 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
179 |
}
|
|
180 |
|
|
181 |
|
|
182 |
// Base version of GetParameter* use GetParameterVectorSize to validate aParamType then cal Host VG
|
|
183 |
VGfloat CVgHandleBase::GetParameterf(MVgContext& aVgContext, VGint aParamType)
|
|
184 |
{
|
|
185 |
VGint vSize = GetParameterVectorSize(aVgContext, aParamType);
|
|
186 |
if (vSize > 0)
|
|
187 |
{
|
|
188 |
return HostVgGetParameterf(aVgContext, aParamType);
|
|
189 |
}
|
|
190 |
return KFloatMinusOne;
|
|
191 |
}
|
|
192 |
|
|
193 |
|
|
194 |
VGint CVgHandleBase::GetParameteri(MVgContext& aVgContext, VGint aParamType)
|
|
195 |
{
|
|
196 |
VGint vSize = GetParameterVectorSize(aVgContext, aParamType);
|
|
197 |
if (vSize > 0)
|
|
198 |
{
|
|
199 |
return HostVgGetParameteri(aVgContext, aParamType);
|
|
200 |
}
|
|
201 |
return 0;
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
/* Base versions of GetParameter*v call:
|
|
206 |
* GetParameterVectorSize to validate aParamtType,
|
|
207 |
* if aCount is 1 they call GetParameterf/i for the object
|
|
208 |
* otherwise if aCount is valid they call HostVgGetParameter*v
|
|
209 |
* */
|
|
210 |
void CVgHandleBase::GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues)
|
|
211 |
{
|
|
212 |
VGint vSize = GetParameterVectorSize(aVgContext, aParamType);
|
|
213 |
if (vSize > 0)
|
|
214 |
{
|
|
215 |
if (aCount == 1)
|
|
216 |
{
|
|
217 |
*aValues = GetParameterf(aVgContext, aParamType);
|
|
218 |
return;
|
|
219 |
}
|
|
220 |
else if ( (aCount > 0) && (aCount <= vSize) )
|
|
221 |
{
|
|
222 |
return HostVgGetParameterfv(aVgContext, aParamType, aCount, aValues);
|
|
223 |
}
|
|
224 |
|
|
225 |
// invalid aCount
|
|
226 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
227 |
}
|
|
228 |
return;
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
void CVgHandleBase::GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues)
|
|
233 |
{
|
|
234 |
VGint vSize = GetParameterVectorSize(aVgContext, aParamType);
|
|
235 |
if (vSize > 0)
|
|
236 |
{
|
|
237 |
if (aCount == 1)
|
|
238 |
{
|
|
239 |
*aValues = GetParameteri(aVgContext, aParamType);
|
|
240 |
return;
|
|
241 |
}
|
|
242 |
else if ( (aCount > 0) && (aCount <= vSize) )
|
|
243 |
{
|
|
244 |
return HostVgGetParameteriv(aVgContext, aParamType, aCount, aValues);
|
|
245 |
}
|
|
246 |
|
|
247 |
// invalid aCount
|
|
248 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
249 |
}
|
|
250 |
return;
|
|
251 |
}
|
|
252 |
|
|
253 |
|
|
254 |
// Base versions of SetParameter* assume any parameters are read-only, and give an error return
|
|
255 |
void CVgHandleBase::SetParameterf(MVgContext& aVgContext, VGint, VGfloat)
|
|
256 |
{
|
|
257 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
258 |
}
|
|
259 |
|
|
260 |
|
|
261 |
void CVgHandleBase::SetParameteri(MVgContext& aVgContext, VGint, VGint)
|
|
262 |
{
|
|
263 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
264 |
}
|
|
265 |
|
|
266 |
|
|
267 |
void CVgHandleBase::SetParameterfv(MVgContext& aVgContext, VGint, VGint, const VGfloat *)
|
|
268 |
{
|
|
269 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
270 |
}
|
|
271 |
|
|
272 |
|
|
273 |
void CVgHandleBase::SetParameteriv(MVgContext& aVgContext, VGint, VGint, const VGint *)
|
|
274 |
{
|
|
275 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
276 |
}
|
|
277 |
|
|
278 |
|
|
279 |
// end of file vghandle.cpp
|