14
|
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 |
const TInt KColorMatrixSize = 20;
|
|
22 |
const TInt KLUTLength = 256;
|
|
23 |
|
|
24 |
|
|
25 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
26 |
// CVgImageInfo
|
|
27 |
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
28 |
|
|
29 |
CVgImageInfo::CVgImageInfo(VGImageFormat aFormat, VGint aWidth, VGint aHeight, CVgImageInfo* aParent, VGbitfield aAllowedQuality,
|
|
30 |
EGLImageKHR aEglImage, TUint64 aSgImageId) :
|
|
31 |
CVgImageBase(EVgHandleForImage, aWidth, aHeight), iFormat(aFormat), iParent(aParent),
|
|
32 |
iAllowedQuality(aAllowedQuality), iIsEglSibling( aSgImageId ? ETrue : EFalse),
|
|
33 |
iEglImage(aEglImage), iSgImageId(aSgImageId),
|
|
34 |
iChildCount(0)
|
|
35 |
{
|
|
36 |
if (aParent)
|
|
37 |
{
|
|
38 |
aParent->IncChildCount();
|
|
39 |
}
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
// eglChildImage
|
|
44 |
CVgImageInfo* CVgImageInfo::New(VGint aWidth, VGint aHeight, CVgImageInfo* aParent)
|
|
45 |
{
|
|
46 |
VGPANIC_ASSERT_DEBUG(aParent, EVgPanicImageParentIsInvalid);
|
|
47 |
RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
|
|
48 |
CVgImageInfo* self = new CVgImageInfo(aParent->iFormat, aWidth, aHeight, aParent, aParent->AllowedQuality(),
|
|
49 |
aParent->EglImage(), aParent->SgImageId());
|
|
50 |
CVghwUtils::SwitchFromVghwHeap(clientHeap);
|
|
51 |
return self;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
// vgCreateEGLImageTargetKHR
|
|
56 |
CVgImageInfo* CVgImageInfo::New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, EGLImageKHR aEglImage, TUint64& aSgImageId)
|
|
57 |
{
|
|
58 |
RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
|
|
59 |
CVgImageInfo* self = new CVgImageInfo(aFormat, aWidth, aHeight, VG_INVALID_HANDLE, 0, aEglImage, aSgImageId);
|
|
60 |
CVghwUtils::SwitchFromVghwHeap(clientHeap);
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
// eglCreateImage
|
|
66 |
CVgImageInfo* CVgImageInfo::New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality)
|
|
67 |
{
|
|
68 |
RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
|
|
69 |
CVgImageInfo* self = new CVgImageInfo(aFormat, aWidth, aHeight, VG_INVALID_HANDLE, aAllowedQuality, NULL, 0l);
|
|
70 |
CVghwUtils::SwitchFromVghwHeap(clientHeap);
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
CVgImageInfo::~CVgImageInfo()
|
|
76 |
{
|
|
77 |
VGPANIC_ASSERT(iChildCount == 0, EVgPanicDeleteInUseVgImageInfo);
|
|
78 |
if (iParent)
|
|
79 |
{
|
|
80 |
iParent->DecChildCount();
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
CVgImageInfo* CVgImageInfo::Parent() const
|
|
86 |
{
|
|
87 |
return iParent;
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
TInt CVgImageInfo::ChildCount() const
|
|
92 |
{
|
|
93 |
return iChildCount;
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CVgImageInfo::IncChildCount()
|
|
98 |
{
|
|
99 |
VGPANIC_ASSERT(!iIsDestroyed, EVgPanicParentImageAlreadyDestroyed);
|
|
100 |
User::LockedInc(iChildCount);
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
void CVgImageInfo::DecChildCount()
|
|
105 |
{
|
|
106 |
User::LockedDec(iChildCount);
|
|
107 |
if ((iChildCount == 0) && iIsDestroyed)
|
|
108 |
{
|
|
109 |
if (iParent == NULL)
|
|
110 |
{
|
|
111 |
if (IsEglSibling())
|
|
112 |
{ // close the root EglImage
|
|
113 |
OpenVgState.EglImageClose(iEglImage);
|
|
114 |
}
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
iParent->DecChildCount();
|
|
119 |
}
|
|
120 |
// delete this image & remove it from HandleMap
|
|
121 |
RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap();
|
|
122 |
OpenVgState.UnMapHandle(iClientHandle);
|
|
123 |
delete this;
|
|
124 |
CVghwUtils::SwitchFromVghwHeap(clientHeap);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
|
|
129 |
VGbitfield CVgImageInfo::AllowedQuality() const
|
|
130 |
{
|
|
131 |
return iAllowedQuality;
|
|
132 |
}
|
|
133 |
|
|
134 |
|
|
135 |
TBool CVgImageInfo::IsEglSibling() const
|
|
136 |
{
|
|
137 |
return iIsEglSibling;
|
|
138 |
}
|
|
139 |
|
|
140 |
|
|
141 |
EGLImageKHR CVgImageInfo::EglImage() const
|
|
142 |
{
|
|
143 |
return iEglImage;
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
TUint64 CVgImageInfo::SgImageId() const
|
|
148 |
{
|
|
149 |
return iSgImageId;
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
TBool CVgImageInfo::DestroyObject(MVgContext& aVgContext)
|
|
154 |
{
|
|
155 |
VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp);
|
|
156 |
OPENVG_TRACE(" CVgImageInfo::DestroyObject HostHandle=0x%x; ChildCount=%d, Parent=0x%x, IsEglSibling=%d, EglImage=0x%x",
|
|
157 |
iHostHandle, ChildCount(), Parent(), IsEglSibling(), EglImage());
|
|
158 |
|
|
159 |
if (iHostHandle)
|
|
160 |
{
|
|
161 |
// Destroy image, but not for eglImages/SgImages
|
|
162 |
if (!IsEglSibling())
|
|
163 |
{
|
|
164 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
165 |
vgApiData.Init(OpenVgRFC::EvgDestroyImage, RemoteFunctionCallData::EOpRequest);
|
|
166 |
vgApiData.AppendParam(iHostHandle);
|
|
167 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
168 |
}
|
|
169 |
iHostHandle = VG_INVALID_HANDLE;
|
|
170 |
}
|
|
171 |
|
|
172 |
if (iChildCount == 0)
|
|
173 |
{
|
|
174 |
if (iParent == NULL)
|
|
175 |
{
|
|
176 |
if (IsEglSibling())
|
|
177 |
{ // close the root EglImage
|
|
178 |
OpenVgState.EglImageClose(iEglImage);
|
|
179 |
}
|
|
180 |
}
|
|
181 |
else
|
|
182 |
{
|
|
183 |
iParent->DecChildCount();
|
|
184 |
}
|
|
185 |
return ETrue;
|
|
186 |
}
|
|
187 |
// don't delete this image until all children have been destroyed
|
|
188 |
return EFalse;
|
|
189 |
}
|
|
190 |
|
|
191 |
|
|
192 |
TInt CVgImageInfo::BitsPerPixelForVgImageFormat(VGImageFormat aFormat)
|
|
193 |
{
|
|
194 |
TInt result = -1;
|
|
195 |
if ((aFormat == VG_BW_1) || (aFormat == VG_A_1))
|
|
196 |
{
|
|
197 |
result = 1;
|
|
198 |
}
|
|
199 |
else if (aFormat == VG_A_4)
|
|
200 |
{
|
|
201 |
result = 4;
|
|
202 |
}
|
|
203 |
else if ((aFormat == VG_sL_8) || (aFormat == VG_lL_8) || (aFormat == VG_A_8))
|
|
204 |
{
|
|
205 |
result = 8;
|
|
206 |
}
|
|
207 |
else if ((aFormat >= 0) && (aFormat < 256))
|
|
208 |
{ // low bits of format number repeat in a pattern for 16/32 bit per pel
|
|
209 |
TInt format = aFormat & 0x3f;
|
|
210 |
if ((format >= VG_sRGB_565) && (format <= VG_sRGBA_4444))
|
|
211 |
{
|
|
212 |
result = 16;
|
|
213 |
}
|
|
214 |
else if (format <= VG_lRGBA_8888_PRE)
|
|
215 |
{
|
|
216 |
result = 32;
|
|
217 |
}
|
|
218 |
}
|
|
219 |
return result;
|
|
220 |
}
|
|
221 |
|
|
222 |
|
|
223 |
void CVgImageInfo::PixmapBlit(TUint8* aDest, const TUint8* aSource, TInt aDestStride, TInt aSourceStride, TInt aRowCount,
|
|
224 |
size_t aRowLength, TInt aLastBits)
|
|
225 |
{
|
|
226 |
VGPANIC_ASSERT_DEBUG(aDest, EVgPanicNullPointer);
|
|
227 |
VGPANIC_ASSERT_DEBUG(aSource, EVgPanicNullPointer);
|
|
228 |
VGPANIC_ASSERT_DEBUG(aDestStride >= aRowLength, EVgPanicStrideSmallerThanRowLength);
|
|
229 |
VGPANIC_ASSERT_DEBUG(aSourceStride >= aRowLength, EVgPanicStrideSmallerThanRowLength);
|
|
230 |
VGPANIC_ASSERT_DEBUG(aRowCount > 0, EVgPanicBadRowCountParam);
|
|
231 |
VGPANIC_ASSERT_DEBUG(aRowLength > 0, EVgPanicBadRowLengthParam);
|
|
232 |
VGPANIC_ASSERT_DEBUG( (aLastBits >= 0) && (aLastBits <= 7), EVgPanicBadLastBitsParam);
|
|
233 |
|
|
234 |
if (aLastBits)
|
|
235 |
{ // bits per pixel < 8, only copy lowest <aLastBits> from source to dest
|
|
236 |
TUint8 destMask = 0xFF << aLastBits; // high bits
|
|
237 |
TUint8 srcMask = 0xFF ^ destMask; // low bits
|
|
238 |
aRowLength -= 1;
|
|
239 |
for (VGint row = 0; row < aRowCount; ++row)
|
|
240 |
{
|
|
241 |
memcpy(aDest, aSource, aRowLength);
|
|
242 |
TUint8 byte = (aDest[aRowLength] & destMask) | (aSource[aRowLength] & srcMask);
|
|
243 |
aDest[aRowLength] = byte;
|
|
244 |
aSource += aSourceStride;
|
|
245 |
aDest += aDestStride;
|
|
246 |
}
|
|
247 |
}
|
|
248 |
else
|
|
249 |
{
|
|
250 |
for (VGint row = 0; row < aRowCount; ++row)
|
|
251 |
{
|
|
252 |
memcpy(aDest, aSource, aRowLength);
|
|
253 |
aSource += aSourceStride;
|
|
254 |
aDest += aDestStride;
|
|
255 |
}
|
|
256 |
}
|
|
257 |
}
|
|
258 |
|
|
259 |
|
|
260 |
VGint CVgImageInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType)
|
|
261 |
{
|
|
262 |
switch (aParamType)
|
|
263 |
{
|
|
264 |
case VG_IMAGE_FORMAT:
|
|
265 |
case VG_IMAGE_WIDTH:
|
|
266 |
case VG_IMAGE_HEIGHT:
|
|
267 |
return 1;
|
|
268 |
}
|
|
269 |
|
|
270 |
// invalid ParamType
|
|
271 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
272 |
return 0;
|
|
273 |
}
|
|
274 |
|
|
275 |
|
|
276 |
VGfloat CVgImageInfo::GetParameterf(MVgContext& aVgContext, VGint aParamType)
|
|
277 |
{
|
|
278 |
switch (aParamType)
|
|
279 |
{
|
|
280 |
case VG_IMAGE_FORMAT:
|
|
281 |
if (iFormat != VG_IMAGE_FORMAT_INVALID)
|
|
282 |
{
|
|
283 |
return (VGfloat)iFormat;
|
|
284 |
}
|
|
285 |
// for EglImage need to get format of underlying VgImage
|
|
286 |
return HostVgGetParameterf(aVgContext, aParamType);
|
|
287 |
|
|
288 |
case VG_IMAGE_WIDTH:
|
|
289 |
return (VGfloat)iWidth;
|
|
290 |
|
|
291 |
case VG_IMAGE_HEIGHT:
|
|
292 |
return (VGfloat)iHeight;
|
|
293 |
}
|
|
294 |
|
|
295 |
// invalid ParamType
|
|
296 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
297 |
return 0;
|
|
298 |
}
|
|
299 |
|
|
300 |
|
|
301 |
VGint CVgImageInfo::GetParameteri(MVgContext& aVgContext, VGint aParamType)
|
|
302 |
{
|
|
303 |
switch (aParamType)
|
|
304 |
{
|
|
305 |
case VG_IMAGE_FORMAT:
|
|
306 |
if (iFormat != VG_IMAGE_FORMAT_INVALID)
|
|
307 |
{
|
|
308 |
return iFormat;
|
|
309 |
}
|
|
310 |
// for EglImage need to get format of underlying VgImage
|
|
311 |
iFormat = (VGImageFormat) HostVgGetParameteri(aVgContext, aParamType);
|
|
312 |
return iFormat;
|
|
313 |
|
|
314 |
case VG_IMAGE_WIDTH:
|
|
315 |
return iWidth;
|
|
316 |
|
|
317 |
case VG_IMAGE_HEIGHT:
|
|
318 |
return iHeight;
|
|
319 |
}
|
|
320 |
|
|
321 |
// invalid ParamType
|
|
322 |
aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR);
|
|
323 |
return 0;
|
|
324 |
}
|
|
325 |
|
|
326 |
|
|
327 |
void CVgImageInfo::ClearImage(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight)
|
|
328 |
{
|
|
329 |
// **** Desirable: check aImage is not rendering target
|
|
330 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
331 |
vgApiData.Init(OpenVgRFC::EvgClearImage, RemoteFunctionCallData::EOpRequest);
|
|
332 |
vgApiData.AppendParam(iHostHandle);
|
|
333 |
vgApiData.AppendParam(aX);
|
|
334 |
vgApiData.AppendParam(aY);
|
|
335 |
vgApiData.AppendParam(aWidth);
|
|
336 |
vgApiData.AppendParam(aHeight);
|
|
337 |
TUint64 sgId(0L);
|
|
338 |
if (iIsEglSibling)
|
|
339 |
{
|
|
340 |
sgId = iSgImageId;
|
|
341 |
}
|
|
342 |
vgApiData.AppendTUint64(sgId);
|
|
343 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
344 |
}
|
|
345 |
|
|
346 |
|
|
347 |
void CVgImageInfo::ImageSubData(MVgContext& aVgContext, const void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY,
|
|
348 |
VGint aWidth, VGint aHeight)
|
|
349 |
{
|
|
350 |
// **** Desirable: check image is not a rendering target
|
|
351 |
|
|
352 |
// Limit aWidth & aHeight to the dimensions of aImage
|
|
353 |
if (iWidth < aWidth)
|
|
354 |
{
|
|
355 |
aWidth = iWidth;
|
|
356 |
}
|
|
357 |
if (iHeight < aHeight)
|
|
358 |
{
|
|
359 |
aHeight = iHeight;
|
|
360 |
}
|
|
361 |
OPENVG_TRACE("CVgImageInfo::ImageSubData.1a dest Image: width=%d, height=%d; clipped width=%d, clipped height=%d",
|
|
362 |
iWidth, iHeight, aWidth, aHeight);
|
|
363 |
TInt bitsPerPixel = BitsPerPixelForVgImageFormat(aDataFormat);
|
|
364 |
TUint32 lineLength = ((static_cast<TUint32>(aWidth) * static_cast<TUint32>(bitsPerPixel)) + 7) / 8;
|
|
365 |
OPENVG_TRACE("CVgImageInfo::ImageSubData.1b bitsPerPixel=%d, lineLength=%d", bitsPerPixel, lineLength);
|
|
366 |
|
|
367 |
if (bitsPerPixel <= 0)
|
|
368 |
{
|
|
369 |
aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR);
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
if (lineLength == aDataStride)
|
|
374 |
{ // use original parameters
|
|
375 |
OPENVG_TRACE("CVgImageInfo::ImageSubData.2a: lineLength == dataStride");
|
|
376 |
HostVgImageSubData(aVgContext, aData, aDataStride * aHeight, aDataStride,
|
|
377 |
aDataFormat, aX, aY, aWidth, aHeight);
|
|
378 |
}
|
|
379 |
else if (0 == aDataStride)
|
|
380 |
{ // Fill operation, pixmap size = lineLength
|
|
381 |
OPENVG_TRACE("CVgImageInfo::ImageSubData.2b: 0 == dataStride");
|
|
382 |
HostVgImageSubData(aVgContext, aData, lineLength, aDataStride,
|
|
383 |
aDataFormat, aX, aY, aWidth, aHeight);
|
|
384 |
}
|
|
385 |
else
|
|
386 |
{ // try to alloc a translation buffer - datastride maybe negative or simply > lineLength
|
|
387 |
size_t pixmapSize = lineLength * aHeight;
|
|
388 |
TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize);
|
|
389 |
OPENVG_TRACE("CVgImageInfo::ImageSubData.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer);
|
|
390 |
if (localBuffer != NULL)
|
|
391 |
{ // reformat data into temporary buffer
|
|
392 |
PixmapBlit(localBuffer, static_cast<const TUint8*>(aData), lineLength, aDataStride, aHeight, lineLength);
|
|
393 |
HostVgImageSubData(aVgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aX, aY, aWidth, aHeight);
|
|
394 |
CVghwUtils::Free(localBuffer);
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{ // alloc failed, so do VG operation row by row
|
|
398 |
const TUint8* source = static_cast<const TUint8*>(aData);
|
|
399 |
for (VGint row = 0; row < aHeight; ++row)
|
|
400 |
{
|
|
401 |
HostVgImageSubData(aVgContext, source, lineLength, lineLength, aDataFormat, aX + row, aY, aWidth, 1);
|
|
402 |
source += aDataStride;
|
|
403 |
}
|
|
404 |
}
|
|
405 |
}
|
|
406 |
}
|
|
407 |
}
|
|
408 |
|
|
409 |
|
|
410 |
void CVgImageInfo::HostVgImageSubData(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride,
|
|
411 |
VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight)
|
|
412 |
{
|
|
413 |
VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer);
|
|
414 |
VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError);
|
|
415 |
|
|
416 |
RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata);
|
|
417 |
vgApiData.Init(OpenVgRFC::EvgImageSubData, RemoteFunctionCallData::EOpRequest);
|
|
418 |
vgApiData.AppendParam(iHostHandle);
|
|
419 |
vgApiData.AppendVector(aPixmap, aPixmapSize);
|
|
420 |
vgApiData.AppendParam(aHostDataStride);
|
|
421 |
vgApiData.AppendParam(aDataFormat);
|
|
422 |
vgApiData.AppendParam(aX);
|
|
423 |
vgApiData.AppendParam(aY);
|
|
424 |
vgApiData.AppendParam(aWidth);
|
|
425 |
vgApiData.AppendParam(aHeight);
|
|
426 |
TUint64 sgId(0L);
|
|
427 |
if (iIsEglSibling)
|
|
428 |
{
|
|
429 |
sgId = iSgImageId;
|
|
430 |
}
|
|
431 |
OPENVG_TRACE("CVgImageInfo::HostVgImageSubData sgId 0x%lx", sgId);
|
|
432 |
vgApiData.AppendTUint64(sgId);
|
|
433 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
434 |
}
|
|
435 |
|
|
436 |
|
|
437 |
void CVgImageInfo::GetImageSubData(MVgContext& aVgContext, void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight)
|
|
438 |
{
|
|
439 |
// **** Desirable: check VGImage is not currently a rendering target
|
|
440 |
|
|
441 |
// Limit aWidth & aHeight to the dimensions of aImage
|
|
442 |
if (iWidth < aWidth)
|
|
443 |
{
|
|
444 |
aWidth = iWidth;
|
|
445 |
}
|
|
446 |
if (iHeight < aHeight)
|
|
447 |
{
|
|
448 |
aHeight = iHeight;
|
|
449 |
}
|
|
450 |
OPENVG_TRACE("CVgImageInfo::GetImageSubData.1a source Image: width=%d, height=%d; clipped width=%d, clipped height=%d",
|
|
451 |
iWidth, iHeight, aWidth, aHeight);
|
|
452 |
TInt bitsPerPixel = BitsPerPixelForVgImageFormat(aDataFormat);
|
|
453 |
TUint32 lineLength = static_cast<TUint32>(aWidth) * static_cast<TUint32>(bitsPerPixel);
|
|
454 |
TUint32 tailBits = lineLength & 7;
|
|
455 |
lineLength = (lineLength + 7) / 8;
|
|
456 |
OPENVG_TRACE("CVgImageInfo::GetImageSubData.1b bitsPerPixel=%d, lineLength=%d, tailBits=%d", bitsPerPixel, lineLength, tailBits);
|
|
457 |
|
|
458 |
if (bitsPerPixel <= 0)
|
|
459 |
{
|
|
460 |
aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR);
|
|
461 |
}
|
|
462 |
else
|
|
463 |
{
|
|
464 |
if (lineLength == aDataStride)
|
|
465 |
{ // use original params
|
|
466 |
OPENVG_TRACE("CVgImageInfo::GetImageSubData.2a: lineLength == dataStride");
|
|
467 |
HostVgGetImageSubData(aVgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aX, aY, aWidth, aHeight);
|
|
468 |
}
|
|
469 |
else if (0 == aDataStride)
|
|
470 |
{ // unlikely unless aHeight = 1, symmetric to fill function for vgGetImageSubData
|
|
471 |
OPENVG_TRACE("CVgImageInfo::GetImageSubData.2b: 0 == dataStride");
|
|
472 |
HostVgGetImageSubData(aVgContext, aData, lineLength, aDataStride, aDataFormat, aX, aY, aWidth, aHeight);
|
|
473 |
}
|
|
474 |
else
|
|
475 |
{ // datastride maybe negative or simply > lineLength
|
|
476 |
TInt pixmapSize = lineLength * aHeight;
|
|
477 |
TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize);
|
|
478 |
OPENVG_TRACE("CVgImageInfo::GetImageSubData.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer);
|
|
479 |
|
|
480 |
if (localBuffer != NULL)
|
|
481 |
{ // read pixels into temporary buffer
|
|
482 |
HostVgGetImageSubData(aVgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aX, aY, aWidth, aHeight);
|
|
483 |
// reformat into client memory
|
|
484 |
PixmapBlit(static_cast<TUint8*>(aData), localBuffer, aDataStride, lineLength, aHeight, lineLength, tailBits);
|
|
485 |
CVghwUtils::Free(localBuffer);
|
|
486 |
}
|
|
487 |
else
|
|
488 |
{ // alloc failed, so do VG operation row by row
|
|
489 |
TUint8* dest = static_cast<TUint8*>(aData);
|
|
490 |
for (VGint row = 0; row < aHeight; ++row)
|
|
491 |
{
|
|
492 |
HostVgGetImageSubData(aVgContext, dest, lineLength, lineLength, aDataFormat, aX + row, aY, aWidth, 1);
|
|
493 |
dest += aDataStride;
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
|
|
501 |
void CVgImageInfo::HostVgGetImageSubData(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride,
|
|
502 |
VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight)
|
|
503 |
{
|
|
504 |
VGPANIC_ASSERT_DEBUG(aPixmap != NULL, EVgPanicNullPixmapPointer);
|
|
505 |
VGPANIC_ASSERT_DEBUG(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError);
|
|
506 |
|
|
507 |
RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata);
|
|
508 |
vgApiData.Init(OpenVgRFC::EvgGetImageSubData);
|
|
509 |
vgApiData.AppendParam(iHostHandle);
|
|
510 |
vgApiData.AppendVector(aPixmap, aPixmapSize, RemoteFunctionCallData::EOut);
|
|
511 |
vgApiData.AppendParam(aHostDataStride);
|
|
512 |
vgApiData.AppendParam(aDataFormat);
|
|
513 |
vgApiData.AppendParam(aX);
|
|
514 |
vgApiData.AppendParam(aY);
|
|
515 |
vgApiData.AppendParam(aWidth);
|
|
516 |
vgApiData.AppendParam(aHeight);
|
|
517 |
vgApiData.AppendParam((VGint)aPixmapSize); // ToDo overload AppendParam for TUint32
|
|
518 |
TUint64 sgId(0L);
|
|
519 |
if (iIsEglSibling)
|
|
520 |
{
|
|
521 |
sgId = iSgImageId;
|
|
522 |
}
|
|
523 |
vgApiData.AppendTUint64(sgId);
|
|
524 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
525 |
}
|
|
526 |
|
|
527 |
|
|
528 |
void CVgImageInfo::CopyImage(MVgContext& aVgContext, VGint aDx, VGint aDy, CVgImageInfo& aSrcImageInfo, VGint aSx, VGint aSy, VGint aWidth,
|
|
529 |
VGint aHeight, VGboolean aDither)
|
|
530 |
{
|
|
531 |
// **** Desirable: verify src & dst are not a rendering target, ...
|
|
532 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
533 |
vgApiData.Init(OpenVgRFC::EvgCopyImage, RemoteFunctionCallData::EOpRequest);
|
|
534 |
vgApiData.AppendParam(iHostHandle);
|
|
535 |
vgApiData.AppendParam(aDx);
|
|
536 |
vgApiData.AppendParam(aDy);
|
|
537 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
538 |
vgApiData.AppendParam(aSx);
|
|
539 |
vgApiData.AppendParam(aSy);
|
|
540 |
vgApiData.AppendParam(aWidth);
|
|
541 |
vgApiData.AppendParam(aHeight);
|
|
542 |
vgApiData.AppendParam(aDither);
|
|
543 |
TUint64 dstSgId(0L);
|
|
544 |
TUint64 srcSgId(0L);
|
|
545 |
if (iIsEglSibling)
|
|
546 |
{
|
|
547 |
dstSgId = iSgImageId;
|
|
548 |
}
|
|
549 |
if (aSrcImageInfo.IsEglSibling())
|
|
550 |
{
|
|
551 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
552 |
}
|
|
553 |
vgApiData.AppendTUint64(dstSgId);
|
|
554 |
vgApiData.AppendTUint64(srcSgId);
|
|
555 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
556 |
}
|
|
557 |
|
|
558 |
|
|
559 |
void CVgImageInfo::DrawImage(MVgContext& aVgContext)
|
|
560 |
{
|
|
561 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
562 |
vgApiData.Init(OpenVgRFC::EvgDrawImage, RemoteFunctionCallData::EOpRequest);
|
|
563 |
vgApiData.AppendParam(iHostHandle);
|
|
564 |
TUint64 sgId(0L);
|
|
565 |
if (iIsEglSibling)
|
|
566 |
{
|
|
567 |
sgId = iSgImageId;
|
|
568 |
}
|
|
569 |
vgApiData.AppendTUint64(sgId);
|
|
570 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
571 |
}
|
|
572 |
|
|
573 |
|
|
574 |
void CVgImageInfo::SetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight)
|
|
575 |
{
|
|
576 |
// **** Desirable: verify aSrc image is not a rendering target
|
|
577 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
578 |
vgApiData.Init(OpenVgRFC::EvgSetPixels, RemoteFunctionCallData::EOpRequest);
|
|
579 |
vgApiData.AppendParam(aDx);
|
|
580 |
vgApiData.AppendParam(aDy);
|
|
581 |
vgApiData.AppendParam(iHostHandle);
|
|
582 |
vgApiData.AppendParam(aSx);
|
|
583 |
vgApiData.AppendParam(aSy);
|
|
584 |
vgApiData.AppendParam(aWidth);
|
|
585 |
vgApiData.AppendParam(aHeight);
|
|
586 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
587 |
}
|
|
588 |
|
|
589 |
|
|
590 |
void CVgImageInfo::GetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight)
|
|
591 |
{
|
|
592 |
// **** Desirable: verify aDst is not currently a rendering target
|
|
593 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
594 |
vgApiData.Init(OpenVgRFC::EvgGetPixels, RemoteFunctionCallData::EOpRequest);
|
|
595 |
vgApiData.AppendParam(iHostHandle);
|
|
596 |
vgApiData.AppendParam(aDx);
|
|
597 |
vgApiData.AppendParam(aDy);
|
|
598 |
vgApiData.AppendParam(aSx);
|
|
599 |
vgApiData.AppendParam(aSy);
|
|
600 |
vgApiData.AppendParam(aWidth);
|
|
601 |
vgApiData.AppendParam(aHeight);
|
|
602 |
TUint64 sgId(0L);
|
|
603 |
if (iIsEglSibling)
|
|
604 |
{
|
|
605 |
sgId = iSgImageId;
|
|
606 |
}
|
|
607 |
vgApiData.AppendTUint64(sgId);
|
|
608 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
609 |
}
|
|
610 |
|
|
611 |
|
|
612 |
void CVgImageInfo::ColorMatrix(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGfloat * aMatrix)
|
|
613 |
{
|
|
614 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
615 |
vgApiData.Init(OpenVgRFC::EvgColorMatrix, RemoteFunctionCallData::EOpRequest);
|
|
616 |
vgApiData.AppendParam(iHostHandle);
|
|
617 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
618 |
vgApiData.AppendVector(aMatrix, KColorMatrixSize);
|
|
619 |
TUint64 dstSgId(0L);
|
|
620 |
TUint64 srcSgId(0L);
|
|
621 |
if (IsEglSibling())
|
|
622 |
{
|
|
623 |
dstSgId = SgImageId();
|
|
624 |
}
|
|
625 |
if (aSrcImageInfo.IsEglSibling())
|
|
626 |
{
|
|
627 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
628 |
}
|
|
629 |
vgApiData.AppendTUint64(dstSgId);
|
|
630 |
vgApiData.AppendTUint64(srcSgId);
|
|
631 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
632 |
}
|
|
633 |
|
|
634 |
|
|
635 |
void CVgImageInfo::Convolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight,
|
|
636 |
VGint aShiftX, VGint aShiftY, const VGshort * aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode)
|
|
637 |
{
|
|
638 |
// **** Desirable: verify aDst & aSrc are valid and do not overlap
|
|
639 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
640 |
vgApiData.Init(OpenVgRFC::EvgConvolve, RemoteFunctionCallData::EOpRequest);
|
|
641 |
vgApiData.AppendParam(iHostHandle);
|
|
642 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
643 |
vgApiData.AppendParam(aKernelWidth);
|
|
644 |
vgApiData.AppendParam(aKernelHeight);
|
|
645 |
vgApiData.AppendParam(aShiftX);
|
|
646 |
vgApiData.AppendParam(aShiftY);
|
|
647 |
vgApiData.AppendVector(aKernel, aKernelWidth*aKernelHeight);
|
|
648 |
vgApiData.AppendParam(aScale);
|
|
649 |
vgApiData.AppendParam(aBias);
|
|
650 |
vgApiData.AppendParam(aTilingMode);
|
|
651 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
652 |
}
|
|
653 |
|
|
654 |
|
|
655 |
void CVgImageInfo::SeparableConvolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight,
|
|
656 |
VGint aShiftX, VGint aShiftY, const VGshort * aKernelX, const VGshort * aKernelY,
|
|
657 |
VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode)
|
|
658 |
{
|
|
659 |
// **** Desirable: verify aDst & aSrc are valid and do not overlap
|
|
660 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
661 |
vgApiData.Init(OpenVgRFC::EvgSeparableConvolve, RemoteFunctionCallData::EOpRequest);
|
|
662 |
vgApiData.AppendParam(iHostHandle);
|
|
663 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
664 |
vgApiData.AppendParam(aKernelWidth);
|
|
665 |
vgApiData.AppendParam(aKernelHeight);
|
|
666 |
vgApiData.AppendParam(aShiftX);
|
|
667 |
vgApiData.AppendParam(aShiftY);
|
|
668 |
vgApiData.AppendVector(aKernelX, aKernelWidth);
|
|
669 |
vgApiData.AppendVector(aKernelY, aKernelHeight);
|
|
670 |
vgApiData.AppendParam(aScale);
|
|
671 |
vgApiData.AppendParam(aBias);
|
|
672 |
vgApiData.AppendParam(aTilingMode);
|
|
673 |
TUint64 dstSgId(0L);
|
|
674 |
TUint64 srcSgId(0L);
|
|
675 |
if (IsEglSibling())
|
|
676 |
{
|
|
677 |
dstSgId = SgImageId();
|
|
678 |
}
|
|
679 |
if (aSrcImageInfo.IsEglSibling())
|
|
680 |
{
|
|
681 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
682 |
}
|
|
683 |
vgApiData.AppendTUint64(dstSgId);
|
|
684 |
vgApiData.AppendTUint64(srcSgId);
|
|
685 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
686 |
}
|
|
687 |
|
|
688 |
|
|
689 |
void CVgImageInfo::GaussianBlur(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode)
|
|
690 |
{
|
|
691 |
// **** Desirable: verify aDst & src are not currently a rendering target or overlap
|
|
692 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
693 |
vgApiData.Init(OpenVgRFC::EvgGaussianBlur, RemoteFunctionCallData::EOpRequest);
|
|
694 |
vgApiData.AppendParam(iHostHandle);
|
|
695 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
696 |
vgApiData.AppendParam(aStdDeviationX);
|
|
697 |
vgApiData.AppendParam(aStdDeviationY);
|
|
698 |
vgApiData.AppendParam(aTilingMode);
|
|
699 |
TUint64 dstSgId(0L);
|
|
700 |
TUint64 srcSgId(0L);
|
|
701 |
if (IsEglSibling())
|
|
702 |
{
|
|
703 |
dstSgId = SgImageId();
|
|
704 |
}
|
|
705 |
if (aSrcImageInfo.IsEglSibling())
|
|
706 |
{
|
|
707 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
708 |
}
|
|
709 |
vgApiData.AppendTUint64(dstSgId);
|
|
710 |
vgApiData.AppendTUint64(srcSgId);
|
|
711 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
712 |
}
|
|
713 |
|
|
714 |
|
|
715 |
void CVgImageInfo::Lookup(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGubyte * aRedLUT, const VGubyte * aGreenLUT, const VGubyte * aBlueLUT,
|
|
716 |
const VGubyte * aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied)
|
|
717 |
{
|
|
718 |
// **** Desirable: verify aDst & aSrc are not currently a rendering target or overlap
|
|
719 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
720 |
vgApiData.Init(OpenVgRFC::EvgLookup, RemoteFunctionCallData::EOpRequest);
|
|
721 |
vgApiData.AppendParam(iHostHandle);
|
|
722 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
723 |
vgApiData.AppendVector(aRedLUT, KLUTLength);
|
|
724 |
vgApiData.AppendVector(aGreenLUT, KLUTLength);
|
|
725 |
vgApiData.AppendVector(aBlueLUT, KLUTLength);
|
|
726 |
vgApiData.AppendVector(aAlphaLUT, KLUTLength);
|
|
727 |
vgApiData.AppendParam(aOutputLinear);
|
|
728 |
vgApiData.AppendParam(aOutputPremultiplied);
|
|
729 |
TUint64 dstSgId(0L);
|
|
730 |
TUint64 srcSgId(0L);
|
|
731 |
if (IsEglSibling())
|
|
732 |
{
|
|
733 |
dstSgId = SgImageId();
|
|
734 |
}
|
|
735 |
if (aSrcImageInfo.IsEglSibling())
|
|
736 |
{
|
|
737 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
738 |
}
|
|
739 |
vgApiData.AppendTUint64(dstSgId);
|
|
740 |
vgApiData.AppendTUint64(srcSgId);
|
|
741 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
742 |
}
|
|
743 |
|
|
744 |
|
|
745 |
void CVgImageInfo::LookupSingle(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGuint * aLookupTable, VGImageChannel aSourceChannel,
|
|
746 |
VGboolean aOutputLinear, VGboolean aOutputPremultiplied)
|
|
747 |
{
|
|
748 |
// **** Desirable: check aSrc is in an RGB pixel format, and that aSourceChannel is okay
|
|
749 |
RemoteFunctionCallData data; OpenVgRFC vgApiData(data);
|
|
750 |
vgApiData.Init(OpenVgRFC::EvgLookupSingle, RemoteFunctionCallData::EOpRequest);
|
|
751 |
vgApiData.AppendParam(iHostHandle);
|
|
752 |
vgApiData.AppendParam(aSrcImageInfo.HostHandle());
|
|
753 |
vgApiData.AppendVector(aLookupTable, KLUTLength);
|
|
754 |
vgApiData.AppendParam(aSourceChannel);
|
|
755 |
vgApiData.AppendParam(aOutputLinear);
|
|
756 |
vgApiData.AppendParam(aOutputPremultiplied);
|
|
757 |
TUint64 dstSgId(0L);
|
|
758 |
TUint64 srcSgId(0L);
|
|
759 |
if (IsEglSibling())
|
|
760 |
{
|
|
761 |
dstSgId = SgImageId();
|
|
762 |
}
|
|
763 |
if (aSrcImageInfo.IsEglSibling())
|
|
764 |
{
|
|
765 |
srcSgId = aSrcImageInfo.SgImageId();
|
|
766 |
}
|
|
767 |
vgApiData.AppendTUint64(dstSgId);
|
|
768 |
vgApiData.AppendTUint64(srcSgId);
|
|
769 |
aVgContext.ExecuteVgCommand(vgApiData);
|
|
770 |
}
|
|
771 |
|
|
772 |
|
|
773 |
// end of file vgimage.cpp
|