# HG changeset patch # User Faisal Memon # Date 1283961754 -3600 # Node ID acbd4400e82b598baff59fb0234a251bfba0e46f # Parent 220791dae4c42b8a3e96b05dcd1079ce327dadc5 Add Guest OpenVG diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/group/bld.inf --- a/guestrendering/guestopenvg/group/bld.inf Wed Sep 08 15:45:18 2010 +0100 +++ b/guestrendering/guestopenvg/group/bld.inf Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,23 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Project build file for Guest OpenVG implementation + +PRJ_PLATFORMS +DEFAULT -WINSCW + +PRJ_EXPORTS +../rom/guestopenvg.iby /epoc32/rom/include/guestopenvg.iby + +PRJ_MMPFILES +guestopenvg.mmp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/group/guestopenvg.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/group/guestopenvg.mmp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,55 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Project specification file for Guest OpenVG + +#include +#include // For uids + +TARGET guestopenvg.dll +TARGETTYPE dll +LINKAS libopenvg.dll +UID KUidSharedDllUidValue KUidOpenVGDllUidValue +CAPABILITY CAP_GENERAL_DLL +VENDORID VID_DEFAULT + +OS_LAYER_SYSTEMINCLUDE +OS_LAYER_ESTLIB_SYSTEMINCLUDE +USERINCLUDE ../inc +USERINCLUDE ../../vghwutils/inc +USERINCLUDE ../../vghwserialiser/inc + +SOURCEPATH ../../vghwserialiser/src +SOURCE openvgrfc.cpp + +SOURCEPATH ../src +SOURCE openvg.cpp // exported C api for Open VG +SOURCE vgapi.cpp // C++ version of Open VG api +SOURCE vgstate.cpp +SOURCE vghandle.cpp // base behaviour for VGHandle objects +SOURCE vgfont.cpp // VGFont specific code +SOURCE vgimage.cpp // VGImage specific code +SOURCE vgmask.cpp // VGMaskLayer specific code +SOURCE vgpaint.cpp // VGPaint specific code +SOURCE vgpath.cpp // VGPath specific code + +LIBRARY euser.lib // Mandatory +LIBRARY vghwutils.lib +LIBRARY guestvideohwapi.lib +LIBRARY vghwserialiser.lib +LIBRARY libc.lib // for strcmp + +// standard ARM def file baseline for all implementions +DEFFILE /epoc32/include/def/eabi/libopenvg11.def + +EPOCALLOWDLLDATA diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/inc/openvg.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/inc/openvg.inl Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,522 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Inline functions for Open VG client-side state classes. + +#ifndef OPENVG_INL +#define OPENVG_INL + +#include "vgstate.h" + + +///////////////////////////////////////////////////////////////////////////////////////////// +// XOpenVgState +///////////////////////////////////////////////////////////////////////////////////////////// + +RMutex& XOpenVgState::MutexWait() + { + iStateLock.Wait(); + return iStateLock; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgHandleBase +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgHandleBase::CVgHandleBase(TVgHandleType aHandleType) : + iClientHandle(iHandleGen.NextUid()), iHandleType(aHandleType), iHostHandle(VG_INVALID_HANDLE), iIsDestroyed(EFalse) + { + } + + +CVgHandleBase::~CVgHandleBase() + { + VGPANIC_ASSERT_DEBUG( iIsDestroyed || (iHostHandle == VG_INVALID_HANDLE), EVgPanicTemp); + } + + +TUint CVgHandleBase::ClientHandle() const + { + return iClientHandle; + } + + +VGHandle CVgHandleBase::HostHandle() const + { + VGPANIC_ASSERT(iHostHandle, EVgPanicHostHandleIsInvalid); + return iHostHandle; + } + + +TVgHandleType CVgHandleBase::HandleType() const + { + return iHandleType; + } + + +TBool CVgHandleBase::IsDestroyed() const + { + return iIsDestroyed; + } + + +void CVgHandleBase::SetHostHandle(VGHandle aHostHandle) + { // should be set exactly once (For EglImages it should be the underlying VG Image) + VGPANIC_ASSERT(iHostHandle == 0, EVgPanicHostHandleAlreadySet); + VGPANIC_ASSERT(aHostHandle, EVgPanicHostHandleIsInvalid); + iHostHandle = aHostHandle; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgImageBase +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgImageBase::CVgImageBase(TVgHandleType aHandleType, VGint aWidth, VGint aHeight) : + CVgHandleBase(aHandleType), iWidth(aWidth), iHeight(aHeight) + { + } + + +VGint CVgImageBase::Width() const + { + return iWidth; + } + + +VGint CVgImageBase::Height() const + { + return iHeight; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// TCleanupVgLocks +///////////////////////////////////////////////////////////////////////////////////////////// + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPath is not a valid VGPath handle + */ +TBool TCleanupVgLocks::CheckVGPath(VGPath aPath, CVgPathInfo** aPathInfo, VGbitfield aReqdCapabilities) + { // VGPath is an opaque data handle + TBool valid = OpenVgState.CheckVGHandle(iVgContext, aPath, (CVgHandleBase**)aPathInfo, EVgHandleForPath); + if (valid && aReqdCapabilities) + { // Check for VG_PATH_CAPABILITY_ERROR + return (*aPathInfo)->CheckHasPathCapabilities(iVgContext, aReqdCapabilities); + } + return valid; + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPath is neither VG_INVALID_HANDLE or a valid VGPath handle + */ +TBool TCleanupVgLocks::CheckOptionalVGPath(VGPath aPath, CVgPathInfo** aPathInfo) + { // VGPath is an opaque data handle + if (aPath == VG_INVALID_HANDLE) + { + return ETrue; + } + return OpenVgState.CheckVGHandle(iVgContext, aPath, (CVgHandleBase**)aPathInfo, EVgHandleForPath); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPaint is not a valid VGPaint handle + */ +TBool TCleanupVgLocks::CheckVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo) + { // VGPaint is an opaque data handle + return OpenVgState.CheckVGHandle(iVgContext, aPaint, (CVgHandleBase**)aPaintInfo, EVgHandleForPaint); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aPaint is neither VG_INVALID_HANDLE or a valid VGPaint handle + */ +TBool TCleanupVgLocks::CheckOptionalVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo) + { // VGPaint is an opaque data handle + if (aPaint == VG_INVALID_HANDLE) + { + return ETrue; + } + return OpenVgState.CheckVGHandle(iVgContext, aPaint, (CVgHandleBase**)aPaintInfo, EVgHandleForPaint); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is not a valid VGImage handle + */ +TBool TCleanupVgLocks::CheckVGImage(VGImage aImage, CVgImageInfo** aImageInfo) + { // VGImage is an opaque data handle + return OpenVgState.CheckVGHandle(iVgContext, aImage, (CVgHandleBase**)aImageInfo, EVgHandleForImage); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is neither VG_INVALID_HANDLE or a valid VGImage handle + */ +TBool TCleanupVgLocks::CheckOptionalVGImage(VGImage aImage, CVgImageInfo** aImageInfo) + { // VGImage is an opaque data handle + if (aImage == VG_INVALID_HANDLE) + { + return ETrue; + } + return OpenVgState.CheckVGHandle(iVgContext, aImage, (CVgHandleBase**)aImageInfo, EVgHandleForImage); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aImage is not a valid VGImage handle, + or if the 2 Images are the same. + */ +TBool TCleanupVgLocks::Check2VGImages(VGImage aImage1, CVgImageInfo** aImageInfo1, VGImage aImage2, CVgImageInfo** aImageInfo2) + { // VGImage is an opaque data handle + // ToDo some (all?) callers need the 2 images to not be overlapping + if (aImage1 != aImage2) + { + return OpenVgState.CheckVGHandle(iVgContext, aImage1, (CVgHandleBase**)aImageInfo1, EVgHandleForImage) && + OpenVgState.CheckVGHandle(iVgContext, aImage2, (CVgHandleBase**)aImageInfo2, EVgHandleForImage); + } + iVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aFont is not a valid VGFont handle + */ +TBool TCleanupVgLocks::CheckVGFont(VGFont aFont, CVgFontInfo** aFontInfo) + { // VGFont is an opaque data handle + return OpenVgState.CheckVGHandle(iVgContext, aFont, (CVgHandleBase**)aFontInfo, EVgHandleForFont); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aMaskLayer is not a valid VGMaskLayer handle + */ +TBool TCleanupVgLocks::CheckVGMaskLayer(VGMaskLayer aMaskLayer, CVgMaskLayerInfo** aMaskLayerInfo) + { // VGMaskLayer is an opaque data handle + return OpenVgState.CheckVGHandle(iVgContext, aMaskLayer, (CVgHandleBase**)aMaskLayerInfo, EVgHandleForMaskLayer); + } + + +/* + Returns false & sets VG error to VG_BAD_HANDLE_ERROR if aHandle is not a valid Open VG handle + */ +TBool TCleanupVgLocks::CheckVGAnyHandle(VGHandle aHandle, CVgHandleBase** aHandleInfo) + { + return OpenVgState.CheckVGHandle(iVgContext, aHandle, aHandleInfo, EVgHandleAny); + } + + +TBool TCleanupVgLocks::CheckKernelWidthAndHeight(VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType) + { + return OpenVgState.CheckKernelWidthAndHeight(iVgContext, aKernelWidth, aKernelHeight, aLimitType); + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// TCheck - parameter checking utility functions +///////////////////////////////////////////////////////////////////////////////////////////// + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtr is NULL or not 32-bit aligned + */ +TBool TCheck::Chk32bitPtr(MVgContext& aVgContext, const void* aDataPtr) + { + TBool result = (aDataPtr != NULL) && !(3ul & (unsigned)aDataPtr); + if (!result) + { + OPENVG_TRACE("TCheck::Chk32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is NULL or not 32-bit aligned + */ +TBool TCheck::Chk2x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2) + { + TBool result = (aDataPtr1 != NULL) && !(3ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(3ul & (unsigned)aDataPtr2); + if (!result) + { + OPENVG_TRACE("TCheck::Chk2x32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is NULL or not 32-bit aligned + */ +TBool TCheck::Chk4x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2, const void* aDataPtr3, const void* aDataPtr4) + { + TBool result = (aDataPtr1 != NULL) && !(3ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(3ul & (unsigned)aDataPtr2) && + (aDataPtr3 != NULL) && !(3ul & (unsigned)aDataPtr3) && (aDataPtr4 != NULL) && !(3ul & (unsigned)aDataPtr4); + if (!result) + { + OPENVG_TRACE("TCheck::Chk4x32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtrN is not-NULL and not 32-bit aligned + */ +TBool TCheck::Chk2xOptional32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2) + { + TBool result = !(3ul & (unsigned)aDataPtr1) && !(3ul & (unsigned)aDataPtr2); + if (!result) + { + OPENVG_TRACE("TCheck::Chk2xOptional32bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aDataPtr is NULL or not 16-bit aligned + */ +TBool TCheck::Chk16bitPtr(MVgContext& aVgContext, const void* aDataPtr) + { + TBool result = (aDataPtr != NULL) && !(1ul & (unsigned)aDataPtr); + if (!result) + { + OPENVG_TRACE("TCheck::Chk16bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if either aDataPtr1 or aDataPtr2 is NULL or not 16-bit aligned + */ +TBool TCheck::Chk2x16bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2) + { + TBool result = (aDataPtr1 != NULL) && !(1ul & (unsigned)aDataPtr1) && (aDataPtr2 != NULL) && !(1ul & (unsigned)aDataPtr2); + if (!result) + { + OPENVG_TRACE("TCheck::Chk2x16bitPtr setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_UNSUPPORTED_PATH_FORMAT_ERROR if pathFormat is not a supported format + */ +TBool TCheck::ChkVGPathFormat(MVgContext& aVgContext, VGint aPathFormat) + { + switch (aPathFormat) + { + case VG_PATH_FORMAT_STANDARD: + return ETrue; + default: + OPENVG_TRACE("TCheck::ChkVGPathFormat setting VG_UNSUPPORTED_PATH_FORMAT_ERROR"); + aVgContext.SetVgError(VG_UNSUPPORTED_PATH_FORMAT_ERROR); + return EFalse; + } + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if datatype is not a valid value from the VGPathDatatype enumeration + */ +TBool TCheck::ChkVGPathDataType(MVgContext& aVgContext, VGPathDatatype aDatatype) + { + switch (aDatatype) + { + case VG_PATH_DATATYPE_S_8: + case VG_PATH_DATATYPE_S_16: + case VG_PATH_DATATYPE_S_32: + case VG_PATH_DATATYPE_F: + return ETrue; + default: + OPENVG_TRACE("TCheck::ChkVGPathDataType setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + } + + +/* + aWidth & aHeight parameters must be >0, otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged. + */ +TBool TCheck::ChkPositiveImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight) + { + if ( (aWidth > 0) && (aHeight > 0) ) + { + return ETrue; + } + OPENVG_TRACE("TCheck::ChkPositiveImageSize setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + + +/* + aWidth & aHeight parameters must be >0, otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged. + */ +TBool TCheck::ChkNewImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight) + { + // ToDo compare with max limits fetched from Host Open VG:VG_MAX_IMAGE_WIDTH, VG_MAX_IMAGE_HEIGHT & VG_MAX_IMAGE_PIXELS + if ( (aWidth > 0) && (aHeight > 0) ) + { + return ETrue; + } + OPENVG_TRACE("TCheck::ChkNewImageSize setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aPaintMode is not a valid VGPaintMode + */ +TBool TCheck::ChkVGPaintMode(MVgContext& aVgContext, VGPaintMode aPaintMode) + { + switch(aPaintMode) + { + case VG_STROKE_PATH: + case VG_FILL_PATH: + return ETrue; + default: + OPENVG_TRACE("TCheck::ChkVGPaintMode setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aPaintModes has invalid VGPaintMode bits set + */ +TBool TCheck::ChkVGPaintModesCombination(MVgContext& aVgContext, VGbitfield aPaintModes) + { + if (aPaintModes & ~(VG_STROKE_PATH | VG_FILL_PATH)) + { + OPENVG_TRACE("TCheck::ChkVGPaintModesCombination setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + return ETrue; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if VGMaskOperation is not a supported operation + */ +TBool TCheck::ChkVGMaskOperation(MVgContext& aVgContext, VGMaskOperation aOperation) + { + switch (aOperation) + { + case VG_CLEAR_MASK: + case VG_FILL_MASK: + case VG_SET_MASK: + case VG_UNION_MASK: + case VG_INTERSECT_MASK: + case VG_SUBTRACT_MASK: + return ETrue; + default: + OPENVG_TRACE("TCheck::ChkVGMaskOperation setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + } + + +TBool TCheck::ChkVgImageFormat(MVgContext& aVgContext, VGImageFormat aFormat) + { + if ( ImageFormatByteDepth(aFormat) ) + { + return ETrue; + } + OPENVG_TRACE("TCheck::ChkVgImageFormat setting VG_UNSUPPORTED_IMAGE_FORMAT_ERROR"); + aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + return EFalse; + } + + +/* + Checks aData is aligned according to the specified VGImageFormet. + + On failure sets these VgErrors: + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if aImageFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + + */ +TBool TCheck::ChkImageAlignment(MVgContext& aVgContext, VGImageFormat aImageFormat, const void* aData) + { + TBool result = EFalse; + if (aData != NULL) + { + switch( ImageFormatByteDepth(aImageFormat) ) + { + case 1: + result = ETrue; + break; + case 2: + result = !( 1ul & (unsigned)aData ); + break; + case 4: + result = !( 3ul & (unsigned)aData ); + break; + default: + OPENVG_TRACE("TCheck::ImageAlignment setting VG_UNSUPPORTED_IMAGE_FORMAT_ERROR"); + aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + return EFalse; + } + } + if (!result) + { + OPENVG_TRACE("TCheck::ImageAlignment setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if aTilingMode is not a valid value from the + VGTilingMode enumeration + */ +TBool TCheck::ChkVGTilingMode(MVgContext& aVgContext, VGTilingMode aTilingMode) + { + switch (aTilingMode) + { + case VG_TILE_FILL: + case VG_TILE_PAD: + case VG_TILE_REPEAT: + case VG_TILE_REFLECT: + return ETrue; + default: + OPENVG_TRACE("TCheck::ChkVGTilingMode setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + } + + +#endif // OPENVG_INL diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/inc/vgstate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/inc/vgstate.h Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,639 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Header file defining Open VG client-side state classes. + +#ifndef VGSTATE_H +#define VGSTATE_H + +#include +#include +#include +#include "vghwutils.h" + + + +// tracing +#include +#ifdef _DEBUG + #define OPENVG_TRACE(fmt, args...) RDebug::Printf(fmt, ##args) + #define VGPANIC_ASSERT(condition, panic) if (!(condition)) { VgPanic(panic, #panic, #condition, __FILE__, __LINE__); } + #define VGPANIC_ASSERT_DEBUG(condition, panic) if (!(condition)) { VgPanic(panic, #panic, #condition, __FILE__, __LINE__); } + #define VGPANIC_ALWAYS(panic) { VgPanic(panic, #panic, NULL, __FILE__, __LINE__); } +#else + #define OPENVG_TRACE(fmt, args...) + #define VGPANIC_ASSERT(condition, panic) if (!(condition)) { VgPanic(panic, NULL, NULL, NULL, __LINE__); } + #define VGPANIC_ASSERT_DEBUG(condition, panic) + #define VGPANIC_ALWAYS(panic) { VgPanic(panic, NULL, NULL, NULL, __LINE__); } +#endif + + +// Guest Open VG panic codes +typedef enum + { + EVgPanicTemp = 1, // note: for development, references should be replaced with a more specific panic + EVgPanicNullPixmapPointer, + EVgPanicPixmapSizeError, + EVgPanicSingletonAlreadyInitialised, + EVgPanicSingletonNotInitialised, + EVgPanicNullPointer, + EVgPanicBadLastBitsParam, + EVgPanicBadRowLengthParam, + EVgPanicBadRowCountParam, + EVgPanicStrideSmallerThanRowLength, // 10 + EVgPanicNotReplyOpcode, + EVgPanicDeleteInUseVgImageInfo, + EVgPanicUidGeneratorZeroSeed, + EVgPanicMissingEglInterface, + EVgPanicNullCVgHandlePointer, + EVgPanicWrongVgHandleType, + EVgPanicHandleAlreadyMarkedDestroyed, + EVgPanicUnknownVgHandleType, + EVgPanicHostHandleIsInvalid, + EVgPanicImageParentIsInvalid, // 20 + EVgPanicFunctionParameterIsNull, + EVgPanicValueFromHostVgIsInvalid, + EVgPanicHostHandleAlreadySet, + EVgPanicParentImageAlreadyDestroyed, + EVgPanicStateLockMutexNotHeld, + } TVgPanic; + +void VgPanic(TVgPanic aPanicCode, char* aPanicName, char* aCondition, char* aFile, TInt aLine); + + +// state singleton, in Writeable Static Data memory +class XOpenVgState; +extern XOpenVgState OpenVgState; + +// classes declared in this header +class CVgHandleBase; +class CVgImageBase; +class CVgMaskLayerInfo; +class CVgFontInfo; +class CVgImageInfo; +class CVgPaintInfo; +class CVgPathInfo; +class THandleGen; +class TVgLockHolder; + +extern const float KFloatMinusOne; + + +class THandleGen + { +public: + inline void Init(TUint aInit); + TUint NextUid(); +private: + TUint iValue; + }; + +typedef enum + { + EVgHandleAny = -1, // match any valid handle type, e.g. for vgSetParameteri + EVgHandleForFont = 0, // specific types ... + EVgHandleForImage, + EVgHandleForPaint, + EVgHandleForPath, + EVgHandleForMaskLayer, + } TVgHandleType; + + +// state structures for VG objects (i.e. anything that is a VGHandle): VGImage, VGPath, VGMaskLayer, VGPaint, VGFont +// ToDo review how to handle thread locking these objects whilst they are in use +NONSHARABLE_CLASS(CVgHandleBase) : public CBase // Base Class + { +public: + static void InitStatics(); + + // public inline methods + inline VGHandle HostHandle() const; + inline TVgHandleType HandleType() const; + inline TBool IsDestroyed() const; + inline void SetHostHandle(VGHandle aHostHandle); + inline TUint ClientHandle() const; + + // general & specific portions of derived object destruction + void Destroy(MVgContext& aVgContext); + virtual TBool DestroyObject(MVgContext& aVgContext) = 0; + + // Each VGHandle object type must implement GetParameterVectorSize + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) = 0; + // Base version of GetParameter* uses GetParameterVectorSize to validate aParamType then calls Host VG + virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); + virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); + // For details of Base versions of GetParameter*v see vghandle.cpp + virtual void GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues); + virtual void GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues); + // Base versions of SetParameter* assume parameters are read-only, and give an error return + virtual void SetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); + virtual void SetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); + virtual void SetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); + virtual void SetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); + +protected: + inline CVgHandleBase(TVgHandleType aHandleType); + inline ~CVgHandleBase(); + + VGint HostVgGetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + VGint HostVgGetParameteri(MVgContext& aVgContext, VGint aParamType); + VGfloat HostVgGetParameterf(MVgContext& aVgContext, VGint aParamType); + void HostVgGetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); + void HostVgGetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); + void HostVgSetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); + void HostVgSetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); + void HostVgSetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); + void HostVgSetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); + +protected: + TUint iClientHandle; + TVgHandleType iHandleType; + VGHandle iHostHandle; + TBool iIsDestroyed; + +private: + static THandleGen iHandleGen; // generator for unique client side handles + }; + + +NONSHARABLE_CLASS(CVgImageBase) : public CVgHandleBase + { +public: + inline VGint Width() const; + inline VGint Height() const; + + TBool DestroyObject(MVgContext& aVgContext) = 0; + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) = 0; + +protected: + inline CVgImageBase(TVgHandleType aHandleType, VGint aWidth, VGint aHeight); + +protected: + VGint const iWidth; + VGint const iHeight; + }; + + +NONSHARABLE_CLASS(CVgMaskLayerInfo) : public CVgImageBase + { +public: + static CVgMaskLayerInfo* New(VGint aWidth, VGint aHeight); + virtual TBool DestroyObject(MVgContext& aVgContext); + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + + // Mask specific operations + void FillMaskLayer(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue); + void CopyMask(MVgContext& aVgContext, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); + +private: + inline CVgMaskLayerInfo(VGint aWidth, VGint aHeight); + inline ~CVgMaskLayerInfo(); + }; + + +NONSHARABLE_CLASS(CVgImageInfo) : public CVgImageBase + { +public: + static CVgImageInfo* New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); + static CVgImageInfo* New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, EGLImageKHR aEglImage, TUint64& aSgImageId); + static CVgImageInfo* New(VGint aWidth, VGint aHeight, CVgImageInfo* aParent); + virtual TBool DestroyObject(MVgContext& aVgContext); + + TInt ChildCount() const; + CVgImageInfo* Parent() const; + VGbitfield AllowedQuality() const; + TBool IsEglSibling() const; + TUint64 SgImageId() const; + EGLImageKHR EglImage() const; + + static TInt BitsPerPixelForVgImageFormat(VGImageFormat aFormat); + static void PixmapBlit(TUint8* aDest, const TUint8* aSource, TInt aDestStride, TInt aSourceStride, TInt aRowCount, + size_t aRowLength, TInt aLastBits=0); + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); + virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); + + void ClearImage(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + void ImageSubData(MVgContext& aVgContext, const void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, + VGint aWidth, VGint aHeight); + void GetImageSubData(MVgContext& aVgContext, void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, + VGint aWidth, VGint aHeight); + void CopyImage(MVgContext& aVgContext, VGint aDx, VGint aDy, CVgImageInfo& aSrcImageInfo, VGint aSx, VGint aSy, VGint aWidth, + VGint aHeight, VGboolean aDither); + void DrawImage(MVgContext& aVgContext); + void SetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + void GetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + void ColorMatrix(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGfloat * aMatrix); + void Convolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort * aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); + void SeparableConvolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort * aKernelX, const VGshort * aKernelY, + VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); + void GaussianBlur(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode); + void Lookup(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGubyte * aRedLUT, const VGubyte * aGreenLUT, const VGubyte * aBlueLUT, + const VGubyte * aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied); + void LookupSingle(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGuint * aLookupTable, VGImageChannel aSourceChannel, + VGboolean aOutputLinear, VGboolean aOutputPremultiplied); + +private: + inline CVgImageInfo(VGImageFormat aFormat, VGint aWidth, VGint aHeight, CVgImageInfo* aParent, VGbitfield aAllowedQuality, + EGLImageKHR aEglImage, TUint64 aSgImageId); + inline ~CVgImageInfo(); + inline void IncChildCount(); + inline void DecChildCount(); + void HostVgGetImageSubData(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + void HostVgImageSubData(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + + + /* **** desireable: expand CVgImageInfo to include and use for validating for various appropriate: + (TBool iIsRenderTarget; - VgImage is a surface currently being rendered, blocks some operations) + (TUint iUsedAsPaintPattern; - non-zero stops use as a render target) + (TUint iUsedAsGlyph; - count of how many places the VgImage is being used as a font glyph) + */ +private: + VGImageFormat iFormat; // not const because this is not currently initialised at creation for EglImages + CVgImageInfo* const iParent; // immediate parent VgImage, NULL if not a child + VGbitfield const iAllowedQuality; + // EglImage / SgImage info ... + TBool const iIsEglSibling; + EGLImageKHR const iEglImage; + TUint64 const iSgImageId; // Set or copied from parent for Egl Sibling - used to prompt Cmd Scheduler to sync pbuffer & vgimage + // non-const state + TInt iChildCount; // count of direct child images + }; + + +NONSHARABLE_CLASS(CVgFontInfo) : public CVgHandleBase + { +public: + static CVgFontInfo* New(); + virtual TBool DestroyObject(MVgContext& aVgContext); + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + + void SetGlyphToPath(MVgContext& aVgContext, VGuint aGlyphIndex, CVgPathInfo* aPathInfo, VGboolean aIsHinted, + const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]); + void SetGlyphToImage(MVgContext& aVgContext, VGuint aGlyphIndex, CVgImageInfo* aImageInfo, const VGfloat aGlyphOrigin [2], + const VGfloat aEscapement[2]); + void ClearGlyph(MVgContext& aVgContext, VGuint aGlyphIndex); + void DrawGlyph(MVgContext& aVgContext, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); + void DrawGlyphs(MVgContext& aVgContext, VGint aGlyphCount, const VGuint * aGlyphIndices, const VGfloat * aAdjustmentsX, + const VGfloat * aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); + +private: + inline CVgFontInfo(); + inline ~CVgFontInfo(); + }; + + +NONSHARABLE_CLASS(CVgPaintInfo) : public CVgHandleBase + { +public: + static CVgPaintInfo* New(); + virtual TBool DestroyObject(MVgContext& aVgContext); + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); + virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); + virtual void GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues); + virtual void GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues); + + virtual void SetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue); + virtual void SetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue); + virtual void SetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues); + virtual void SetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues); + + static void ResetPaint(MVgContext& aVgContext); + void SetPaint(MVgContext& aVgContext, VGbitfield aPaintModes); + void SetColor(MVgContext& aVgContext, VGuint aRgba); + VGuint GetColor(MVgContext& aVgContext); + void PaintPattern(MVgContext& aVgContext, CVgImageInfo* aPatternInfo); + +private: + inline CVgPaintInfo(); + inline ~CVgPaintInfo(); + +private: + // cached parameters + VGPaintType iPaintType; + VGColorRampSpreadMode iColorRampSpreadMode; + VGboolean iColorRampPremultiplied; + VGTilingMode iPatternTilingMode; + // VGfloat vector parameters are not currently cached in client + }; + + +NONSHARABLE_CLASS(CVgPathInfo) : public CVgHandleBase + { +public: + static CVgPathInfo* CVgPathInfo::New(VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities); + virtual TBool DestroyObject(MVgContext& aVgContext); + + void ClearPath(MVgContext& aVgContext, VGbitfield aCapabilities); + void RemovePathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities); + VGbitfield GetPathCapabilities(MVgContext& aVgContext); + + void AppendPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo); + void AppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte * aPathSegments, const void* aPathData); + void ModifyPathCoords(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments, const void* aPathData); + void TransformPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo); + VGboolean InterpolatePath(MVgContext& aVgContext, CVgPathInfo& aStartPathInfo, CVgPathInfo& aEndPathInfo, VGfloat aAmount); + VGfloat PathLength(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments); + void PointAlongPath(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, + VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY); + void PathBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); + void PathTransformedBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); + void DrawPath(MVgContext& aVgContext, VGbitfield aPaintModes); + void RenderToMask(MVgContext& aVgContext, VGbitfield aPaintModes, VGMaskOperation aOperation); + + inline VGPathDatatype PathDatatype() const; + + TBool CheckHasPathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities); + + virtual VGint GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType); + virtual VGfloat GetParameterf(MVgContext& aVgContext, VGint aParamType); + virtual VGint GetParameteri(MVgContext& aVgContext, VGint aParamType); + +private: + inline CVgPathInfo(VGPathDatatype aPathDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities); + inline ~CVgPathInfo(); + TBool CheckAppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData, + VGint* aPathDataSize); + TBool CheckPathDataAlignment(MVgContext& aVgContext, const void* aPathData); + TBool CheckPathDataSize(MVgContext& aVgContext, const VGubyte* aPathSegments, VGint aNumSegments, VGint* aPathDataSize); + VGint HostVgeGetPathCoordsSizeInBytes(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments); + +private: + VGPathDatatype const iDatatype; + VGfloat const iScale; + VGfloat const iBias; + VGbitfield iCapabilities; + }; + + +// Collection of static parameter checking functions - all "Chk" functions set the appropriate last VG Error on failure +class TCheck + { +public: + inline static TBool Chk16bitPtr(MVgContext& aVgContext, const void* aDataPtr); + inline static TBool Chk2x16bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); + inline static TBool Chk32bitPtr(MVgContext& aVgContext, const void* aDataPtr); + inline static TBool Chk2x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); + inline static TBool Chk4x32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2, const void* aDataPtr3, const void* aDataPtr4); + inline static TBool Chk2xOptional32bitPtr(MVgContext& aVgContext, const void* aDataPtr1, const void* aDataPtr2); + inline static TBool ChkVGMaskOperation(MVgContext& aVgContext, VGMaskOperation aOperation); + inline static TBool ChkVGPaintMode(MVgContext& aVgContext, VGPaintMode aPaintMode); + inline static TBool ChkVGPathDataType(MVgContext& aVgContext, VGPathDatatype aDatatype); + inline static TBool ChkVGTilingMode(MVgContext& aVgContext, VGTilingMode aTilingMode); + inline static TBool ChkVgImageFormat(MVgContext& aVgContext, VGImageFormat aFormat); + inline static TBool ChkImageAlignment(MVgContext& aVgContext, VGImageFormat aImageFormat, const void* aData); + inline static TBool ChkPositiveImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight); + inline static TBool ChkNewImageSize(MVgContext& aVgContext, VGint aWidth, VGint aHeight); + inline static TBool ChkVGPaintModesCombination(MVgContext& aVgContext, VGbitfield aPaintModes); + inline static TBool ChkVGPathFormat(MVgContext& aVgContext, VGint aPathFormat); + static TBool ChkAreaIsWithinImage(MVgContext& aVgContext, CVgImageBase* aImageInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static TBool ChkParamCountAndValuesPtr(MVgContext& aVgContext, VGint aCount, const void* aValues); + static VGint ImageFormatByteDepth(VGImageFormat aImageFormat); + }; + + +/* + Class holds mutex for Open VG client side state on construction, & releases it on destruction. + + Placing methods here ensures the procedural requirement that the Mutex is held before these methods are called. + */ +class TCleanupVgLocks + { +public: + // having functions here forces the caller to hold the Open VG Mutex before they are called (when the lock object is constructed) + TCleanupVgLocks(MVgContext& aVgContext); + ~TCleanupVgLocks(); + void WaitForMutex(RMutex& aMutex); + void SignalMutex(); + + inline TBool CheckVGFont(VGFont aFont, CVgFontInfo** aFontInfo); + inline TBool CheckVGImage(VGImage aImage, CVgImageInfo** aImageInfo); + inline TBool CheckOptionalVGImage(VGImage aImage, CVgImageInfo** aImageInfo); + inline TBool Check2VGImages(VGImage aImage1, CVgImageInfo** aImageInfo1, VGImage aImage2, CVgImageInfo** aImageInfo2); + inline TBool CheckVGMaskLayer(VGMaskLayer aMaskLayer, CVgMaskLayerInfo** aHandleInfo); + inline TBool CheckVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo); + inline TBool CheckOptionalVGPaint(VGPaint aPaint, CVgPaintInfo** aPaintInfo); + // ToDo maybe add a version that checks Start Segment & Segment Count + inline TBool CheckVGPath(VGPath aPath, CVgPathInfo** aPathInfo, VGbitfield aReqdCapabilities=0); + inline TBool CheckOptionalVGPath(VGPath aPath, CVgPathInfo** aPathInfo); + inline TBool CheckVGAnyHandle(VGHandle aHandle, CVgHandleBase** aHandleInfo); + TBool CheckVGMaskOperationAndHandle(VGMaskOperation aOperation, VGHandle aMask, CVgImageBase** aImageInfo); + inline TBool CheckKernelWidthAndHeight(VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType); + + VGFont CreateFont(VGint aGlyphCapacityHint); + VGImage ChildImage(CVgImageInfo& aParentInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + VGImage CreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); + VGMaskLayer CreateMaskLayer(VGint aWidth, VGint aHeight); + VGPaint CreatePaint(); + VGPaint GetPaint(VGPaintMode aPaintMode); + VGPath CreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, + VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities); + VGImage CreateEGLImageTargetKHR(VGeglImageKHR aImage); + +private: + MVgContext& const iVgContext; + RMutex& iMutex; + TBool iIsHeld; + }; + + + +// per VG client state +NONSHARABLE_CLASS(XOpenVgState) : public MEglManagementApi, public MVgApiForEgl + { + friend class TCleanupVgLocks; +public: + XOpenVgState(); + ~XOpenVgState(); + + // functions using/maintaining Open Vg Handle Map + TBool AddToHashMap(MVgContext& aVgContext, CVgHandleBase* aHandleInfo, VGHandle aHostHandle); + void UnMapHandle(TUint32 aClientHandle); + + // MEglManagementApi - redirects via CVghwUtils to the EGL implementation + virtual TBool EglImageOpenForVgImage(EGLImageKHR aImage, TSize& aSize, VGHandle& aVgHandle, TUint64& aSgImageId); + virtual void EglImageClose(EGLImageKHR aImage); + + // MVgApiForEgl - exported via CvghwUtils to the Guest EGL implementation + virtual ExtensionProcPointer guestGetVgProcAddress (const char *aProcName); + +protected: // fns only visible to TVgLockHolder class + inline RMutex& MutexWait(); + TBool CheckVGHandle(MVgContext& aVgContext, VGHandle aHandle, CVgHandleBase** aHandleInfo, TVgHandleType aMatchType); + // functions using cached values from Host Open VG implementation + TBool CheckKernelWidthAndHeight(MVgContext& aVgContext, VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType); + +private: + RMutex iStateLock; + + // Map holds info about VG Handle based objects + RMutex iMapLock; + RHashMap iHandleHashMap; + MEglManagementApi* iEglManagementApi; + + // 'constants' initialised from x86 VG implementation the first time they are required + VGint iKVgMaxKernelSize; + VGint iKVgMaxSeparableKernelSize; + // ToDo: more values to cache: VG_MAX_IMAGE_WIDTH, VG_MAX_IMAGE_HEIGHT, VG_MAX_IMAGE_PIXELS + + // ToDo Record when VG fonts use glyphs based on SgImages, required for Ref counting + }; + + + + +// class of static methods to implement Open VG APIs +class TGuestOpenVg + { +public: + // VG APIs + static VGPaint vgGetPaint(VGPaintMode aPaintMode); + static VGPaint vgCreatePaint(); + static VGboolean vgInterpolatePath(VGPath aDstPath, VGPath aStartPath, VGPath aEndPath, VGfloat aAmount); + static VGfloat vgPathLength(VGPath aPath, VGint aStartSegment, VGint aNumSegments); + static VGbitfield vgGetPathCapabilities(VGPath aPath); + static VGPath vgCreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, + VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities); + static VGfloat vgGetf(VGParamType aType); + static VGint vgGeti(VGParamType aType); + static VGfloat vgGetParameterf(VGHandle aObject, VGint aParamType); + static VGint vgGetParameteri(VGHandle aObject, VGint aParamType); + static VGint vgGetParameterVectorSize(VGHandle aObject, VGint aParamType); + static VGMaskLayer vgCreateMaskLayer(VGint aWidth, VGint aHeight); + static VGuint vgGetColor(VGPaint aPaint); + static VGImage vgCreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality); + static VGImage vgChildImage(VGImage aParent, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static VGImage vgGetParent(VGImage aImage); + static VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR aImage); + static VGFont vgCreateFont(VGint aGlyphCapacityHint); + static VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key, VGint setting); + static void vgGetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, VGfloat * aValues); + static void vgGetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, VGint * aValues); + static VGint vgGetVectorSize(VGParamType type); + static void vgGetfv(VGParamType aType, VGint aCount, const VGfloat * aValues); + static void vgGetiv(VGParamType aType, VGint aCount, const VGint * aValues); + static void vgGetMatrix(VGfloat* aM); + static void vgGetImageSubData(VGImage aImage, void* aData, VGint aDataStride, VGImageFormat aDataFormat, + VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static void vgReadPixels(void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aSx, VGint aSy, + VGint aWidth, VGint aHeight); + static void vgPathBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); + static void vgPathTransformedBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight); + static void vgSetf(VGParamType aType, VGfloat aValue); + static void vgSeti(VGParamType aType, VGint aVvalue); + static void vgSetfv(VGParamType aType, VGint aCount, const VGfloat * aValues); + static void vgSetiv(VGParamType aType, VGint aCount, const VGint * aValues); + static void vgSetParameterf(VGHandle aObject, VGint aParamType, VGfloat aValue); + static void vgSetParameteri(VGHandle aObject, VGint aParamType, VGint aValue); + static void vgSetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, const VGfloat * aValues); + static void vgSetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, const VGint * aValues); + static void vgLoadIdentity(); + static void vgLoadMatrix(const VGfloat* aM); + static void vgMultMatrix(const VGfloat* aM); + static void vgTranslate(VGfloat aTx, VGfloat aTy); + static void vgScale(VGfloat aSx, VGfloat aSy); + static void vgShear(VGfloat aShx, VGfloat aShy); + static void vgRotate(VGfloat aAngle); + static void vgMask(VGHandle aMask, VGMaskOperation aOperation, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static void vgRenderToMask(VGPath aPath, VGbitfield aPaintModes, VGMaskOperation aOperation); + static void vgDestroyMaskLayer(VGMaskLayer maskLayer); + static void vgFillMaskLayer(VGMaskLayer aMaskLayer, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue); + static void vgCopyMask(VGMaskLayer aMaskLayer, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); + static void vgClear(VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static void vgClearPath(VGPath aPath, VGbitfield aCapabilities); + static void vgDestroyPath(VGPath aPath); + static void vgRemovePathCapabilities(VGPath aPath, VGbitfield aCapabilities); + static void vgAppendPath(VGPath aDstPath, VGPath aSrcPath); + static void vgAppendPathData(VGPath aDstPath, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData); + static void vgModifyPathCoords(VGPath aDstPath, VGint aStartIndex, VGint aNumSegments, const void* aPathData); + static void vgTransformPath(VGPath aDstPath, VGPath aSrcPath); + static void vgPointAlongPath(VGPath aPath, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, + VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY); + static void vgDrawPath(VGPath aPath, VGbitfield aPaintModes); + static void vgDestroyPaint(VGPaint aPaint); + static void vgSetPaint(VGPaint aPaint, VGbitfield aPaintModes); + static void vgSetColor(VGPaint aPaint, VGuint aRgba); + static void vgPaintPattern(VGPaint aPaint, VGImage aPattern); + static void vgDestroyImage(VGImage aImage); + static void vgClearImage(VGImage aImage, VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static void vgImageSubData(VGImage aImage, const void* aData, VGint aDataStride, VGImageFormat aDataFormat, + VGint aX, VGint aY, VGint aWidth, VGint aHeight); + static void vgCopyImage(VGImage aDst, VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight, + VGboolean aDither); + static void vgDrawImage(VGImage aImage); + static void vgSetPixels(VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + static void vgWritePixels(const void* data, VGint aDataStride, VGImageFormat aDataFormat, VGint aDx, VGint aDy, + VGint aWidth, VGint aHeight); + static void vgGetPixels(VGImage aDst, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + static void vgCopyPixels(VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + static void vgDestroyFont(VGFont aFont); + static void vgSetGlyphToPath(VGFont aFont, VGuint aGlyphIndex, VGPath aPath, VGboolean aIsHinted, const VGfloat aGlyphOrigin [2], + const VGfloat aEscapement[2]); + static void vgSetGlyphToImage(VGFont aFont, VGuint aGlyphIndex, VGImage aImage, const VGfloat aGlyphOrigin [2], + const VGfloat aEscapement[2]); + static void vgClearGlyph(VGFont aFont, VGuint aGlyphIndex); + static void vgDrawGlyph(VGFont aFont, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); + static void vgDrawGlyphs(VGFont aFont, VGint aGlyphCount, const VGuint* aGlyphIndices, const VGfloat* aAdjustmentsX, + const VGfloat* aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting); + static void vgColorMatrix(VGImage aDst, VGImage aSrc, const VGfloat* aMatrix); + static void vgConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, VGint aShiftX, VGint aShiftY, + const VGshort* aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); + static void vgSeparableConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, VGint aShiftX, VGint aShiftY, + const VGshort* aKernelX, const VGshort* aKernelY, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode); + static void vgGaussianBlur(VGImage aDst, VGImage aSrc, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode); + static void vgLookup(VGImage aDst, VGImage aSrc, const VGubyte* aRedLUT, const VGubyte* aGreenLUT, const VGubyte* aBlueLUT, + const VGubyte* aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied); + static void vgLookupSingle(VGImage aDst, VGImage aSrc, const VGuint* aLookupTable, VGImageChannel aSourceChannel, + VGboolean aOutputLinear, VGboolean aOutputPremultiplied); + +private: + // fns that directly talk to Host Open VG (no parameter checking) + static void HostVgReadPixels(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight); + static void HostVgWritePixels(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight); + + static VGint HostGetVectorSize(MVgContext& aVgContext, VGParamType aType); + +public: // ToDo find a more elegant way of calling this from XOpenVgState + static VGint HostGeti(MVgContext& aVgContext, VGParamType type); +private: + static inline VGfloat HostGetf(MVgContext& aVgContext, VGParamType type); + }; + + +// C api extensions +#ifdef __cplusplus +extern "C" { +#endif + +VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR image); + +#ifdef __cplusplus +} +#endif + + +#include "openvg.inl" + +#endif // VGSTATE_H diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/rom/guestopenvg.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/rom/guestopenvg.iby Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,23 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Guest OpenVG IBY File + +#ifndef __GUEST_OPENVG_IBY__ +#define __GUEST_OPENVG_IBY__ + +file=ABI_DIR\BUILD_DIR\guestopenvg.dll sys\bin\libopenvg.dll +file=ABI_DIR\BUILD_DIR\guestopenvgu.dll sys\bin\libopenvgu.dll +file=ABI_DIR\BUILD_DIR\vghwutils.dll sys\bin\vghwutils.dll +file=ABI_DIR\BUILD_DIR\vghwserialiser.dll sys\bin\vghwserialiser.dll +#endif diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/openvg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/openvg.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,2260 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// OpenVG C API for Symbian DLL + + +#include "vgstate.h" + + + +extern "C" { + +/* + Note: Comments at the start of each Open VG api are adapted from the Open VG 1.1 specification. + The text has been chosen/adapted to give a helpful overview of the function, and the errors + (other than VG_NO_CONTEXT_ERROR) that it may generate. For more details and diagrams see the + full Open VG specification. + */ + +/* + The vgGetParameter functions return the value of a parameter on a given VGHandlebased + object. + + The original value passed to vgSetParameter (provided the call to + vgSetParameter completed without error) should be returned by + vgGetParameter (except where specifically noted), even if the implementation + makes use of a truncated or quantized value internally. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a vector parameter in vgGetParameterf or + vgGetParameteri + */ +EXPORT_C VGint + vgGetParameteri(VGHandle object, + VGint paramType) + { + OPENVG_TRACE("vgGetParameteri object=0x%x, paramType=0x%x -->", object, paramType); + + VGint value = TGuestOpenVg::vgGetParameteri(object, paramType); + OPENVG_TRACE("vgGetParameteri value=0x%x <--", value); + return value; + } + + +//////////////////////////////////////////////////////////////////////////////////////////// +//Functions returning value +//////////////////////////////////////////////////////////////////////////////////////////// +/* + Returns the oldest error code provided by an API call on the current context since the + previous call to vgGetError on that context (or since the creation of the context). No + error is indicated by a return value of 0 (VG_NO_ERROR). After the call, the error code is + cleared to 0. The possible errors that may be generated by each OpenVG function (apart from + VG_OUT_OF_MEMORY_ERROR) are shown below the definition of the function. + If no context is current at the time vgGetError is called, the error code + VG_NO_CONTEXT_ERROR is returned. Pending error codes on existing contexts are not affected + by the call. + */ +EXPORT_C VGErrorCode + vgGetError(void) + { + OPENVG_TRACE("vgGetError"); + + MVgContext* vgContext = CVghwUtils::VgContext(); + VGErrorCode error = VG_NO_CONTEXT_ERROR; + if (vgContext) + { // thread state already exists - get client or Host VG error + error = vgContext->VgError(); + } + return error; + } + +/* + Returns the paint object currently set for the given paintMode, or VG_INVALID_HANDLE + if an error occurs or if no paint object is set (i.e., the default paint is present) on + the given context with the given paintMode. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paintMode is not a valid value from the VGPaintMode enumeration + */ +EXPORT_C VGPaint + vgGetPaint(VGPaintMode paintMode) + { + OPENVG_TRACE("vgGetPaint paintMode=0x%x -->", paintMode); + + VGPaint paintHandle = TGuestOpenVg::vgGetPaint(paintMode); + OPENVG_TRACE("vgGetPaint handle=0x%x <--", paintHandle); + return paintHandle; + } + +/* + Creates a new paint object that is initialized to a set of default values and returns + a VGPaint handle to it. If insufficient memory is available to allocate a new object, + VG_INVALID_HANDLE is returned. + */ +EXPORT_C VGPaint + vgCreatePaint(void) + { + OPENVG_TRACE("vgCreatePaint -->"); + + VGPaint paintHandle = TGuestOpenVg::vgCreatePaint(); + OPENVG_TRACE("vgCreatePaint handle=0x%x <--", paintHandle); + return paintHandle; + } + +/* + Appends a path, defined by interpolation (or extrapolation) between the paths + startPath and endPath by the given amount, to the path dstPath. It returns + VG_TRUE if interpolation was successful (i.e., the paths had compatible segment + types after normalization), and VG_FALSE otherwise. If interpolation is + unsuccessful, dstPath is left unchanged. It is legal for dstPath to be a handle + to the same path object as either startPath or endPath or both, in which case + the contents of the source path or paths referenced by dstPath will have the + interpolated path appended. If dstPath is not the a handle to the same path + object as either startPath or endPath, the contents of startPath and endPath + will not be affected by the call. + + ERRORS + VG_BAD_HANDLE_ERROR + – if any of dstPath, startPath, or endPath is not a valid path handle, or is + not shared with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_INTERPOLATE_TO is not enabled for dstPath + – if VG_PATH_CAPABILITY_INTERPOLATE_FROM is not enabled for startPath or endPath + */ +EXPORT_C VGboolean + vgInterpolatePath(VGPath dstPath, + VGPath startPath, + VGPath endPath, + VGfloat amount) + { + OPENVG_TRACE("vgInterpolatePath dstPath=0x%x, startPath=0x%x, endPath=0x%x, amount=%f", + dstPath, startPath, endPath, amount); + + return TGuestOpenVg::vgInterpolatePath(dstPath, startPath, endPath, amount); + } + +/* + Returns the length of a given portion of a path in the user coordinate system + (that is, in the path’s own coordinate system, disregarding any matrix + settings). Only the subpath consisting of the numSegments path segments beginning + with startSegment (where the initial path segment has index 0) is used. If an + error occurs, -1.0f is returned. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_LENGTH is not enabled for path + VG_ILLEGAL_ARGUMENT_ERROR + – if startSegment is less than 0 or greater than the index of the final path + segment + – if numSegments is less than or equal to 0 + – if (startSegment + numSegments – 1) is greater than the index of the final + path segment + */ +EXPORT_C VGfloat + vgPathLength(VGPath path, + VGint startSegment, + VGint numSegments) + { + OPENVG_TRACE("vgPathLength path=0x%x, startSegment=%d, numSegments=%d", path, startSegment, numSegments); + + return TGuestOpenVg::vgPathLength(path, startSegment, numSegments); + } + +/* + Returns the current capabilities of the path, as a bitwise OR of + VGPathCapabilities constants. If an error occurs, 0 is returned. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +EXPORT_C VGbitfield + vgGetPathCapabilities(VGPath path) + { + OPENVG_TRACE("vgGetPathCapabilities path=0x%x", path); + + return TGuestOpenVg::vgGetPathCapabilities(path); + } + +/* + Create a new path that is ready to accept segment data and return a VGPath handle + to it. The path data will be formatted in the format given by pathFormat, typically + VG_PATH_FORMAT_STANDARD. The datatype parameter contains a value from the + VGPathDatatype enumeration indicating the datatype that will be used for coordinate + data. The capabilities argument is a bitwise OR of the desired VGPathCapabilities + values. Bits of capabilities that do not correspond to values from VGPathCapabilities + have no effect. + + If an error occurs, VG_INVALID_HANDLE is returned. + + ERRORS + VG_UNSUPPORTED_PATH_FORMAT_ERROR + – if pathFormat is not a supported format + VG_ILLEGAL_ARGUMENT_ERROR + – if datatype is not a valid value from the VGPathDatatype enumeration + – if scale is equal to 0 + */ +EXPORT_C VGPath + vgCreatePath(VGint pathFormat, + VGPathDatatype datatype, + VGfloat scale, VGfloat bias, + VGint segmentCapacityHint, + VGint coordCapacityHint, + VGbitfield capabilities) + { + OPENVG_TRACE("vgCreatePath pathFormat=%d, datatype=0x%x, scale=%f, bias=%f, segCapHint=%d, coordCapHint=%d, caps=0x%x -->", + pathFormat, datatype, scale, bias, segmentCapacityHint, coordCapacityHint, capabilities); + + VGPath pathHandle = TGuestOpenVg::vgCreatePath(pathFormat, datatype, scale, bias, segmentCapacityHint, coordCapacityHint, capabilities); + OPENVG_TRACE("vgCreatePath handle=0x%x <--", pathHandle); + return pathHandle; + } + +/* + The vgGet functions return the value of a parameter on the current context. + The original value passed to vgSet (except as specifically noted, and provided the call to + vgSet completed without error) is returned by vgGet, even if the implementation makes + use of a truncated or quantized value internally. This rule ensures that OpenVG state may + be saved and restored without degradation. + + If an error occurs during a call to vgGetf, vgGeti, or vgGetVectorSize, the return value + is undefined. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a vector parameter in vgGetf or vgGeti + */ +EXPORT_C VGfloat + vgGetf(VGParamType type) + { + OPENVG_TRACE("vgGetf type=0x%x", type); + + return TGuestOpenVg::vgGetf(type); + } + +/* + The vgGet functions return the value of a parameter on the current context. + The original value passed to vgSet (except as specifically noted, and provided the call to + vgSet completed without error) is returned by vgGet, even if the implementation makes + use of a truncated or quantized value internally. This rule ensures that OpenVG state may + be saved and restored without degradation. + + If an error occurs during a call to vgGetf, vgGeti, or vgGetVectorSize, the return value + is undefined. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a vector parameter in vgGetf or vgGeti + */ +EXPORT_C VGint + vgGeti(VGParamType type) + { + OPENVG_TRACE("vgGeti type=0x%x", type); + + return TGuestOpenVg::vgGeti(type); + } + +/* + The vgGetVectorSize function returns the maximum number of elements in the vector + that will be retrieved by the vgGetiv or vgGetfv functions if called with the given + paramType argument. For scalar values, 1 is returned. If vgGetiv or vgGetfv is + called with a smaller value for count than that returned by vgGetVectorSize, + only the first count elements of the vector are retrieved. Use of a greater value + for count will result in an error. + The original value passed to vgSet (except as specifically noted, and provided the call to + vgSet completed without error) is returned by vgGet, even if the implementation makes + use of a truncated or quantized value internally. This rule ensures that OpenVG state may + be saved and restored without degradation. + If an error occurs during a call to vgGetf, vgGeti, or vgGetVectorSize, the return value + is undefined. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + */ +EXPORT_C VGint + vgGetVectorSize(VGParamType type) + { + OPENVG_TRACE("vgGetVectorSize type=0x%x", type); + + return TGuestOpenVg::vgGetVectorSize(type); + } + +/* + The vgGetParameter functions return the value of a parameter on a given VGHandlebased + object. + + The original value passed to vgSetParameter (provided the call to + vgSetParameter completed without error) should be returned by + vgGetParameter (except where specifically noted), even if the implementation + makes use of a truncated or quantized value internally. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a vector parameter in vgGetParameterf or + vgGetParameteri + */ +EXPORT_C VGfloat + vgGetParameterf(VGHandle object, + VGint paramType) + { + OPENVG_TRACE("vgGetParameterf object=0x%x, paramType=0x%x -->", object, paramType); + + VGfloat value = TGuestOpenVg::vgGetParameterf(object, paramType); + OPENVG_TRACE("vgGetParameterf value=%f <--", value); + return value; + } + +/* + The vgGetParameterVectorSize function returns the number of elements in the vector + that will be returned by the vgGetParameteriv or vgGetParameterfv functions if called + with the given paramType argument. For scalar values, 1 is returned. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + */ +EXPORT_C VGint + vgGetParameterVectorSize(VGHandle object, + VGint paramType) + { + OPENVG_TRACE("vgGetParameterVectorSize object=0x%x, paramType=0x%x -->", object, paramType); + + VGint size = TGuestOpenVg::vgGetParameterVectorSize(object, paramType); + OPENVG_TRACE("vgGetParameterVectorSize size=%i <--", size); + return size; + } + +/* + Creates an object capable of storing a mask layer with the given width and + height and returns a VGMaskLayer handle to it. The mask layer is defined to + be compatible with the format and multisampling properties of the current + drawing surface. If there is no current drawing surface, no mask is + configured for the current drawing surface, or an error occurs, + VG_INVALID_HANDLE is returned. All mask layer values are initially set to one. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if width is greater than VG_MAX_IMAGE_WIDTH + – if height is greater than VG_MAX_IMAGE_HEIGHT + – if width*height is greater than VG_MAX_IMAGE_PIXELS + */ +EXPORT_C VGMaskLayer + vgCreateMaskLayer(VGint width, VGint height) + { + OPENVG_TRACE("vgCreateMaskLayer width=%d, height=%d -->", width, height); + + VGMaskLayer maskHandle = TGuestOpenVg::vgCreateMaskLayer(width, height); + OPENVG_TRACE("vgCreateMaskLayer handle=0x%x <--", maskHandle); + return maskHandle; + } + +/* + The current setting of the VG_PAINT_COLOR parameter on a given paint object may + be queried as a 32-bit non-premultiplied sRGBA_8888 value. Each color channel or + alpha value is clamped to the range [0, 1] , multiplied by 255, and rounded to obtain an + 8-bit integer; the resulting values are packed into a 32-bit value in the same format as for + vgSetColor. + + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +EXPORT_C VGuint + vgGetColor(VGPaint paint) + { + OPENVG_TRACE("vgGetColor paint=0x%x", paint); + + return TGuestOpenVg::vgGetColor(paint); + } + +/* + Creates an image with the given width, height, and pixel format and returns a + VGImage handle to it. If an error occurs, VG_INVALID_HANDLE is returned. All + color and alpha channel values are initially set to zero. The format parameter + must contain a value from the VGImageFormat enumeration. + The allowedQuality parameter is a bitwise OR of values from the + VGImageQuality enumeration, indicating which levels of resampling quality may be + used to draw the image. It is always possible to draw an image using the + VG_IMAGE_QUALITY_NONANTIALIASED quality setting even if it is not explicitly + specified. + + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if format is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if width is greater than VG_MAX_IMAGE_WIDTH + – if height is greater than VG_MAX_IMAGE_HEIGHT + – if width*height is greater than VG_MAX_IMAGE_PIXELS + – if width*height*(pixel size of format) is greater than + VG_MAX_IMAGE_BYTES + – if allowedQuality is not a bitwise OR of values from the + VGImageQuality enumeration + */ +EXPORT_C VGImage + vgCreateImage(VGImageFormat format, + VGint width, VGint height, + VGbitfield allowedQuality) + { + OPENVG_TRACE("vgCreateImage format=0x%x, width=%d, height=%d, allowedQuality=0x%x -->", + format, width, height, allowedQuality); + + VGImage imageHandle = TGuestOpenVg::vgCreateImage(format, width, height, allowedQuality); + OPENVG_TRACE("vgCreateImage handle=0x%x <--", imageHandle); + return imageHandle; + } + +/* + Returns a new VGImage handle that refers to a portion of the parent image. The + region is given by the intersection of the bounds of the parent image with the + rectangle beginning at pixel (x, y) with dimensions width and height, which + must define a positive region contained entirely within parent. + + ERRORS + VG_BAD_HANDLE_ERROR + – if parent is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if parent is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if x is less than 0 or greater than or equal to the parent width + – if y is less than 0 or greater than or equal to the parent height + – if width or height is less than or equal to 0 + – if x + width is greater than the parent width + – if y + height is greater than the parent height + */ +EXPORT_C VGImage + vgChildImage(VGImage parent, + VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgChildImage parent=oc%x, x=%d, y=%d, width=%d, height=%d -->", + parent, x, y, width, height); + + VGImage imageHandle = TGuestOpenVg::vgChildImage(parent, x, y, width, height); + OPENVG_TRACE("vgChildImage handle=0x%x <--", imageHandle); + return imageHandle; + } + +/* + Returns the closest valid ancestor (i.e., one that has not been the target of + a vgDestroyImage call) of the given image. If image has no ancestors, image is + returned. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +EXPORT_C VGImage vgGetParent(VGImage image) + { + OPENVG_TRACE("vgGetParent image=0x%x", image); + + return TGuestOpenVg::vgGetParent(image); + } + +/* + Creates a new font object and returns a VGFont handle to it. The glyphCapacityHint + argument provides a hint as to the capacity of a VGFont, i.e., the total number of + glyphs that this VGFont object will be required to accept. A value of 0 indicates that + the value is unknown. If an error occurs during execution, VG_INVALID_HANDLE is returned. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphCapacityHint is negative + */ +EXPORT_C VGFont vgCreateFont(VGint glyphCapacityHint) + { + OPENVG_TRACE("vgCreateFont glyphCapacityHint=%d -->", glyphCapacityHint); + + VGFont fontHandle = TGuestOpenVg::vgCreateFont(glyphCapacityHint); + OPENVG_TRACE("vgCreateFont handle=0x%x <--", fontHandle); + return fontHandle; + } + +/* Hardware Queries */ + +/* + Returns a value indicating whether a given setting of a property of a type given + by key is generally accelerated in hardware on the currently running OpenVG + implementation. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if key is not one of the values from the VGHardwareQueryType enumeration + – if setting is not one of the values from the enumeration associated with + key + */ +EXPORT_C VGHardwareQueryResult + vgHardwareQuery + (VGHardwareQueryType key, + VGint setting) + { + OPENVG_TRACE("vgHardwareQuery key=0x%x, setting=%d", key, setting); + + return TGuestOpenVg::vgHardwareQuery(key, setting); + } + +/* + The vgGetString function returns information about the OpenVG implementation, + including extension information. The values returned may vary according to + the display (e.g., the EGLDisplay when using EGL) associated with the current + context. + + Returns NULL if no context is current. + */ +EXPORT_C const VGubyte * + vgGetString(VGStringID name) + { + OPENVG_TRACE("vgGetString name=0x%x", name); + + switch (name) + { + case VG_VENDOR: + return (const VGubyte *)"Nokia"; + case VG_RENDERER: + return (const VGubyte *)"Guest 1.0"; + case VG_VERSION: + return (const VGubyte *)"1.1"; + case VG_EXTENSIONS: // supported VG extensions, (associated function addresses are fetched with eglGetProcAddress) + return (const VGubyte *)"VG_KHR_EGL_image"; + } + return (const VGubyte *)NULL; + } + +/* + The vgGetParameter functions return the value of a parameter on a given VGHandlebased + object. + + If vgGetParameteriv or vgGetParameterfv is called with a smaller value for + count than that returned by vgGetParameterVectorSize, only the first count + elements of the vector are retrieved. Use of a greater value for count will result + in an error. + + The original value passed to vgSetParameter (provided the call to + vgSetParameter completed without error) should be returned by + vgGetParameter (except where specifically noted), even if the implementation + makes use of a truncated or quantized value internally. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if values is NULL in vgGetParameterfv or vgGetParameteriv + – if values is not properly aligned in vgGetParameterfv or vgGetParameteriv + – if count is less than or equal to 0 in vgGetParameterfv or vgGetParameteriv + – if count is greater than the value returned by vgGetParameterVectorSize for + the given parameter in vgGetParameterfv or vgGetParameteriv + */ +EXPORT_C void + vgGetParameterfv(VGHandle object, + VGint paramType, + VGint count, + VGfloat * values) + { + OPENVG_TRACE("vgGetParameterfv object=0x%x, paramType=0x%x, count=%d, values=0x%x", + object, paramType, count, values); + + TGuestOpenVg::vgGetParameterfv(object, paramType, count, values); + } + +EXPORT_C void + vgGetParameteriv(VGHandle object, + VGint paramType, + VGint count, + VGint * values) + { + OPENVG_TRACE("vgGetParameteriv object=0x%x, paramType=0x%x, count=%d, values=0x%x", + object, paramType, count, values); + + TGuestOpenVg::vgGetParameteriv(object, paramType, count, values); + } + +/* Renderer and Extension Information */ + +/* +The vgGetVectorSize function returns the maximum number of elements in the vector +that will be retrieved by the vgGetiv or vgGetfv functions if called with the given +paramType argument. For scalar values, 1 is returned. If vgGetiv or vgGetfv is +called with a smaller value for count than that returned by vgGetVectorSize, +only the first count elements of the vector are retrieved. Use of a greater value +for count will result in an error. +The original value passed to vgSet (except as specifically noted, and provided the call to +vgSet completed without error) is returned by vgGet, even if the implementation makes +use of a truncated or quantized value internally. This rule ensures that OpenVG state may +be saved and restored without degradation. +If an error occurs during a call to vgGetfv or vgGetiv, nothing is +written to values. + +ERRORS +VG_ILLEGAL_ARGUMENT_ERROR +– if paramType is not a valid value from the VGParamType enumeration +– if values is NULL in vgGetfv or vgGetiv +– if values is not properly aligned in vgGetfv or vgGetiv +– if count is less than or equal to 0 in vgGetfv or vgGetiv +– if count is greater than the value returned by vgGetVectorSize for the +given parameter in vgGetfv or vgGetiv + */ +EXPORT_C void + vgGetfv(VGParamType type, VGint count, + VGfloat * values) + { + OPENVG_TRACE("vgGetfv type=0x%x, count=%d, values=0x%x", type, count, values); + + TGuestOpenVg::vgGetfv(type, count, values); + } + +EXPORT_C void + vgGetiv(VGParamType type, VGint count, + VGint * values) + { + OPENVG_TRACE("vgGetiv type=0x%x, count=%d, values=0x%x", type, count, values); + + TGuestOpenVg::vgGetiv(type, count, values); + } + +/* + Retrieve the value of the current transformation. + Nine values are written to m in the order: + { sx, shy, w0, shx, sy, w1, tx, ty, w2 } + For an affine matrix, w0 and w1 will always be 0 and w2 will always be 1. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +EXPORT_C void + vgGetMatrix(VGfloat * m) + { + OPENVG_TRACE("vgGetMatrix m=0x%x", m); + + TGuestOpenVg::vgGetMatrix(m); + } + +/* + Read pixel values from a rectangular portion of an image, performs format conversion + if necessary, and stores the resulting pixels into memory. + + Pixel values are written starting at the address given by the pointer data; adjacent + scanlines are separated by dataStride bytes. Negative or zero values of + dataStride are allowed. The region to be read is given by x, y, width, and + height, which must define a positive region. Pixels that fall outside the bounds + of the image are ignored. + Pixel values in memory are formatted according to the dataFormat parameter, which + must contain a value from the VGImageFormat enumeration. If dataFormat + specifies a premultiplied format (VG_sRGBA_8888_PRE or VG_lRGBA_8888_PRE), + color channel values of a pixel that are greater than their corresponding alpha value are + clamped to the range [0, alpha]. The data pointer alignment and the pixel layout in + memory are as described in the vgImageSubData section. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +EXPORT_C void + vgGetImageSubData(VGImage image, + void * data, + VGint dataStride, + VGImageFormat dataFormat, + VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgGetImageSubData image=0x%x, data=0x%x, dataStride=%d, dataFormat=0x%x, x=%d, y=%d, width=%d, height=%d", + image, data, dataStride, dataFormat, x, y, width, height); + + TGuestOpenVg::vgGetImageSubData(image, data, dataStride, dataFormat, x, y, width, height); + } + +/* + Copy pixel data from the drawing surface without the creation of a VGImage object. + Pixel values are written starting at the address given by the pointer data; adjacent + scanlines are separated by dataStride bytes. Negative or zero values of + dataStride are allowed. The region to be read is given by x, y, width, and + height, which must define a positive region. + + Pixel values in memory are formatted according to the dataFormat parameter, which + must contain a value from the VGImageFormat enumeration. The data pointer + alignment and the pixel layout in memory is as described for vgImageSubData. + + Pixels whose source lies outside of the bounds of the drawing surface are + ignored. Pixel format conversion is applied as needed. The scissoring region + does not affect the reading of pixels. + + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +EXPORT_C void + vgReadPixels(void * data, VGint dataStride, + VGImageFormat dataFormat, + VGint sx, VGint sy, + VGint width, VGint height) + { + OPENVG_TRACE("vgReadPixels data=0x%x, dataStride=%d, dataFormat=0x%x, sx=%d, sy=%d, width=%d, height=%d", + data, dataStride, dataFormat, sx, sy, width, height); + + TGuestOpenVg::vgReadPixels(data, dataStride, dataFormat, sx, sy, width, height); + } + +/* + Returns an axis-aligned bounding box that tightly bounds the interior of the given + path. Stroking parameters are ignored. If path is empty, minX and minY are set to 0 + and width and height are set to -1. If path contains a single point, minX and minY + are set to the coordinates of the point and width and height are set to 0. + + The VG_PATH_CAPABILITY_PATH_BOUNDS capability must be enabled for path. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if minX, minY, width, or height is NULL + – if minX, minY, width, or height is not properly aligned + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_BOUNDS is not enabled for path + */ +EXPORT_C void + vgPathBounds(VGPath path, + VGfloat * minX, + VGfloat * minY, + VGfloat * width, + VGfloat * height) + { + OPENVG_TRACE("vgPathBounds path=0x%x, minX=0x%x, minY=0x%x, width=0x%x, height=0x%x", + path, minX, minY, width, height); + + TGuestOpenVg::vgPathBounds(path, minX, minY, width, height); + } + +/* + The vgPathTransformedBounds function returns an axis-aligned bounding box + that is guaranteed to enclose the geometry of the given path following + transformation by the current path-user-to-surface transform. The returned + bounding box is not guaranteed to fit tightly around the path geometry. If path + is empty, minX and minY are set to 0 and width and height are set to -1. If + path contains a single point, minX and minY are set to the transformed + coordinates of the point and width and height are set to 0. + The VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS capability must be + enabled for path. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if minX, minY, width, or height is NULL + – if minX, minY, width, or height is not properly aligned + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS is not enabled + for path + */ +EXPORT_C void + vgPathTransformedBounds(VGPath path, + VGfloat * minX, + VGfloat * minY, + VGfloat * width, + VGfloat * height) + { + OPENVG_TRACE("vgPathTransformedBounds path=0x%x, minX=0x%x, minY=0x%x, width=0x%x, height=0x%x", + path, minX, minY, width, height); + + TGuestOpenVg::vgPathTransformedBounds(path, minX, minY, width, height); + } + +//////////////////////////////////////////////////////////////////////////////////////////// +//Syncing methods +//////////////////////////////////////////////////////////////////////////////////////////// + +/* + Ensures that all outstanding requests on the current context will complete in finite time. + vgFlush may return prior to the actual completion of all requests. + */ +EXPORT_C void + vgFlush(void) + { + // ToDo comment + OPENVG_TRACE("vgFlush"); + + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + vgContext->ExecuteVgFlushCommand(); + } + } + +/* + The vgFinish function forces all outstanding requests on the current context to + complete, returning only when the last request has completed. + */ +EXPORT_C void + vgFinish(void) + { + // ToDo comment + OPENVG_TRACE("vgFinish"); + + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + vgContext->ExecuteVgFinishCommand(); + } + } + +//////////////////////////////////////////////////////////////////////////////////////////// +//Functions not returning value (possible to buffer) +//////////////////////////////////////////////////////////////////////////////////////////// +/* Getters and Setters */ + +/* + The vgSet functions set the value of a parameter on the current context. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a vector parameter in vgSetf or vgSeti + – if value is not a legal enumerated value for the given parameter in vgSetf or + vgSeti + */ +EXPORT_C void + vgSetf (VGParamType type, VGfloat value) + { + OPENVG_TRACE("vgSetf type=0x%x, value=%f", type, value); + + TGuestOpenVg::vgSetf(type, value); + } + +EXPORT_C void + vgSeti (VGParamType type, VGint value) + { + OPENVG_TRACE("vgSeti type=0x%x, value=%d", type, value); + + TGuestOpenVg::vgSeti(type, value); + } + +/* + The vgSet functions set the value of a parameter on the current context. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a scalar parameter in vgSetfv or vgSetiv and count is + not equal to 1 + – if values[i] is not a legal enumerated value for the given parameter in vgSetfv + or vgSetiv for 0 <= i < count + – if values is NULL in vgSetfv or vgSetiv and count is greater than 0 + – if values is not properly aligned in vgSetfv or vgSetiv + – if count is less than 0 in vgSetfv or vgSetiv + – if count is not a valid value for the given parameter + */ +EXPORT_C void + vgSetfv(VGParamType type, VGint count, + const VGfloat * values) + { + OPENVG_TRACE("vgSetfv type=0x%x, count=%d, values=0x%x", type, count, values); + + TGuestOpenVg::vgSetfv(type, count, values); + } + +EXPORT_C void + vgSetiv(VGParamType type, VGint count, + const VGint * values) + { + OPENVG_TRACE("vgSetiv type=0x%x, count=%d, values=0x%x", type, count, values); + + TGuestOpenVg::vgSetiv(type, count, values); + } + +/* + For vgSetParameterf and vgSetParameteri. + + The vgSetParameter functions set the value of a parameter on a given VGHandlebased + object. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a vector parameter in vgSetParameterf or + vgSetParameteri + – if value is not a legal enumerated value for the given parameter in + vgSetParameterf or vgSetParameteri + */ +EXPORT_C void + vgSetParameterf(VGHandle object, + VGint paramType, + VGfloat value) + { + OPENVG_TRACE("vgSetParameterf object=0x%x, paramType=0x%x, value=%f -->", object, paramType, value); + + TGuestOpenVg::vgSetParameterf(object, paramType, value); + } + +EXPORT_C void + vgSetParameteri(VGHandle object, + VGint paramType, + VGint value) + { + OPENVG_TRACE("vgSetParameteri object=0x%x, paramType=0x%x, value=0x%x", object, paramType, value); + + TGuestOpenVg::vgSetParameteri(object, paramType, value); + } + +/* + For vgSetParameterfv and vgSetParameteriv. + + The vgSetParameter functions set the value of a parameter on a given VGHandlebased + object. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a scalar parameter in vgSetParameterfv or + vgSetParameteriv and count is not equal to 1 + – if values[i] is not a legal enumerated value for the given parameter + in vgSetParameterfv or vgSetParameteriv for 0 <= i < count + – if values is NULL in vgSetParameterfv or vgSetParameteriv and count is + greater than 0 + – if values is not properly aligned in vgSetParameterfv or vgSetParameteriv + – if count is less than 0 in vgSetParameterfv or vgSetParameteriv + – if count is not a valid value for the given parameter + */ +EXPORT_C void + vgSetParameterfv(VGHandle object, + VGint paramType, + VGint count, + const VGfloat * values) + { + OPENVG_TRACE("vgSetParameterfv object=0x%x, paramType=%d, count=%d, values=0x%x", object, paramType, count, values); + + TGuestOpenVg::vgSetParameterfv(object, paramType, count, values); + } + +EXPORT_C void + vgSetParameteriv(VGHandle object, + VGint paramType, + VGint count, + const VGint * values) + { + OPENVG_TRACE("vgSetParameteriv object=0x%x, paramType=%d, count=%d, values=0x%x", object, paramType, count, values); + + TGuestOpenVg::vgSetParameteriv(object, paramType, count, values); + } + +/* Matrix Manipulation */ + +/* + Sets the current matrix M to the identity matrix: + */ +EXPORT_C void + vgLoadIdentity(void) + { + OPENVG_TRACE("vgLoadIdentity"); + + TGuestOpenVg::vgLoadIdentity(); + } + +/* + Loads an arbitrary set of matrix values into the current + matrix. Nine matrix values are read from m, in the order: + { sx, shy, w0, shx, sy, w1, tx, ty, w2 } + However, if the targeted matrix is affine (i.e., the matrix mode is not + VG_MATRIX_IMAGE_USER_TO_SURFACE), the values { w0, w1, w2 } are ignored and + replaced by the values { 0, 0, 1 }. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +EXPORT_C void + vgLoadMatrix(const VGfloat * m) + { + OPENVG_TRACE("vgLoadMatrix m=0x%x", m); + + TGuestOpenVg::vgLoadMatrix(m); + } + +/* + Right-multiplies the current matrix M by a given matrix: + Nine matrix values are read from m in the order: + { sx, shy, w0, shx, sy, w1, tx, ty, w2 } + and the current matrix is multiplied by the resulting matrix. However, if the + targeted matrix is affine (i.e., the matrix mode is not + VG_MATRIX_IMAGE_USER_TO_SURFACE), the values { w0, w1, w2 } are ignored + and replaced by the values { 0, 0, 1 } prior to multiplication. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +EXPORT_C void + vgMultMatrix(const VGfloat * m) + { + OPENVG_TRACE("vgMultMatrix m=0x%x", m); + + TGuestOpenVg::vgMultMatrix(m); + } + +/* + Modifies the current transformation by appending a translation. This is equivalent + to right-multiplying the current matrix M by a translation matrix: + [ 1 0 tx ] + [ 0 1 ty ] + [ 0 0 1 ] + */ +EXPORT_C void + vgTranslate(VGfloat tx, VGfloat ty) + { + OPENVG_TRACE("vgTranslate tx=%f, ty=%f", tx, ty); + + TGuestOpenVg::vgTranslate(tx, ty); + } + +/* + Modifies the current transformation by appending a scale. This is equivalent to + right-multiplying the current matrix M by a scale matrix: + [ sx 0 0 ] + [ 0 sy 0 ] + [ 0 0 1 ] + */ +EXPORT_C void + vgScale(VGfloat sx, VGfloat sy) + { + OPENVG_TRACE("vgScale sx=%f, sy=%f", sx, sy); + + TGuestOpenVg::vgScale(sx, sy); + } + +/* + Modifies the current transformation by appending a shear. This is equivalent to + right-multiplying the current matrix M by a shear matrix: + [ 1 shx 0 ] + [ shy 1 0 ] + [ 0 0 1 ] + */ +EXPORT_C void + vgShear(VGfloat shx, VGfloat shy) + { + OPENVG_TRACE("vgShear shx=%f, shy=%f", shx, shy); + + TGuestOpenVg::vgShear(shx, shy); + } + +/* + Modifies the current transformation by appending a counterclockwise rotation by a given + angle (expressed in degrees) about the origin. This is equivalent to right-multiplying + the current matrix M by the following matrix (using the symbol a to represent the value + of the angle parameter): + [ cos(a) -sin(a) 0 ] + [ sin(a) cos(a) 0 ] + [ 0 0 1 ] + */ +EXPORT_C void + vgRotate(VGfloat angle) + { + OPENVG_TRACE("vgRotate angle=%f"); + + TGuestOpenVg::vgRotate(angle); + } + +/* + Modifies the drawing surface mask values according to a given operation, possibly + using coverage values taken from a mask layer or bitmap image given by the mask + parameter. If no mask is configured for the current drawing surface, vgMask has + no effect. + + ERRORS + VG_BAD_HANDLE_ERROR + – if operation is not VG_CLEAR_MASK or VG_FILL_MASK, and mask is not a + valid mask layer or image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if mask is a VGImage that is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if operation is not a valid value from the VGMaskOperation + enumeration + – if width or height is less than or equal to 0 + – if mask is a VGMaskLayer and is not compatible with the current surface + mask + */ +EXPORT_C void + vgMask(VGHandle mask, VGMaskOperation operation, + VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgMask mask=0x%x, operation=0x%x, x=%d, y=%d, width=%d, height=%d", + mask, operation, x, y, width, height); + + TGuestOpenVg::vgMask(mask, operation, x, y, width, height); + } + +/* + Modifies the current surface mask by applying the given operation to the set of + coverage values associated with the rendering of the given path. If paintModes + contains VG_FILL_PATH, the path is filled; if it contains VG_STROKE_PATH, the path + is stroked. If both are present, the mask operation is performed in two passes, + first on the filled path geometry, then on the stroked path geometry. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + – if operation is not a valid value from the VGMaskOperation enumeration + */ +EXPORT_C void + vgRenderToMask(VGPath path, + VGbitfield paintModes, + VGMaskOperation operation) + { + OPENVG_TRACE("vgRenderToMask path=0x%x, paintModes=0x%x, operation=0x%x", path, paintModes, operation); + + TGuestOpenVg::vgRenderToMask(path, paintModes, operation); + } + +/* + Deallocate the resources associated with a mask layer. Following the call, + the maskLayer handle is no longer valid in the current context. + + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask handle + */ +EXPORT_C void vgDestroyMaskLayer(VGMaskLayer maskLayer) + { + OPENVG_TRACE("vgDestroyMaskLayer maskLayer=0x%x", maskLayer); + + TGuestOpenVg::vgDestroyMaskLayer(maskLayer); + } + +/* + Set the values of a given maskLayer within a given rectangular region to a given + value. The floating-point value value must be between 0 and 1. The value is rounded + to the closest available value supported by the mask layer. If two values are equally + close, the larger value is used. + + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask layer handle, or is not shared with the + current context + VG_ILLEGAL_ARGUMENT_ERROR + – if value is less than 0 or greater than 1 + – if width or height is less than or equal to 0 + – if x or y is less than 0 + – if x + width is greater than the width of the mask + – if y + height is greater than the height of the mask + */ +EXPORT_C void + vgFillMaskLayer(VGMaskLayer maskLayer, + VGint x, VGint y, + VGint width, VGint height, + VGfloat value) + { + OPENVG_TRACE("vgFillMaskLayer maskLayer=0x%x, x=%d, y=%d, width=%d, height=%d, value=%f", + maskLayer, x, y, width, height, value); + + TGuestOpenVg::vgFillMaskLayer(maskLayer, x, y, width, height, value); + } + +/* + Copies a portion of the current surface mask into a VGMaskLayer object. The source + region starts at (sx, sy) in the surface mask, and the destination region starts + at (dx, dy) in the destination maskLayer. The copied region is clipped to the given + width and height and the bounds of the source and destination. If the current context + does not contain a surface mask, vgCopyMask does nothing. + + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask layer handle + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if maskLayer is not compatible with the current surface mask + */ +EXPORT_C void + vgCopyMask(VGMaskLayer maskLayer, + VGint sx, VGint sy, + VGint dx, VGint dy, + VGint width, VGint height) + { + OPENVG_TRACE("vgCopyMask maskLayer=0x%x, sx=%d, sy=%d, dx=%d, dy=%d, width=%d, height=%d", + maskLayer, sx, sy, dx, dy, width, height); + + TGuestOpenVg::vgCopyMask(maskLayer, sx, sy, dx, dy, width, height); + } + +/* + Fills the portion of the drawing surface intersecting the rectangle extending from + pixel (x, y) and having the given width and height with a constant color value, taken + from the VG_CLEAR_COLOR parameter. The color value is expressed in non-premultiplied + sRGBA (sRGB color plus alpha)format. Values outside the [0, 1] range are interpreted + as the nearest endpoint of the range. The color is converted to the destination color + space in the same manner as if a rectangular path were being filled. Clipping and + scissoring take place in the usual fashion, but antialiasing, masking, and blending + do not occur. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgClear(VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgClear x=%d, y=%d, width=%d, height=%d", x, y, width, height); + + TGuestOpenVg::vgClear(x, y, width, height); + } + + +/* Paths */ + +/* + Remove all segment command and coordinate data associated with a path. The handle + continues to be valid for use in the future, and the path format and datatype retain + their existing values. The capabilities argument is a bitwise OR of the desired + VGPathCapabilities values. Bits of capabilities that do not correspond to values from + VGPathCapabilities have no effect. Using vgClearPath may be more efficient than + destroying and re-creating a path for short-lived paths. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +EXPORT_C void + vgClearPath(VGPath path, VGbitfield capabilities) + { + OPENVG_TRACE("vgClearPath path=0x%x, capabilities=0x%x", path, capabilities); + + TGuestOpenVg::vgClearPath(path, capabilities); + } + +/* + Release any resources associated with path, and makes the handle invalid in all + contexts that shared it. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +EXPORT_C void vgDestroyPath(VGPath path) + { + OPENVG_TRACE("vgDestroyPath path=0x%x", path); + + TGuestOpenVg::vgDestroyPath(path); + } + +/* + Requests the set of capabilities specified in the capabilities argument to + be disabled for the given path. The capabilities argument is a bitwise OR of + the VGPathCapabilities values whose removal is requested. Attempting to + remove a capability that is already disabled has no effect. Bits of + capabilities that do not correspond to values from VGPathCapabilities have + no effect. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +EXPORT_C void + vgRemovePathCapabilities(VGPath path, + VGbitfield capabilities) + { + OPENVG_TRACE("vgRemovePathCapabilities path=0x%x, capabilities=0x%x", path, capabilities); + + TGuestOpenVg::vgRemovePathCapabilities(path, capabilities); + } + +/* + Appends a copy of all path segments from srcPath onto the end of the existing + data in dstPath. It is legal for srcPath and dstPath to be handles to the same + path object, in which case the contents of the path are duplicated. If srcPath + and dstPath are handles to distinct path objects, the contents of srcPath will + not be affected by the call. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dstPath or srcPath is not a valid path handle, or is not shared + with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_APPEND_FROM is not enabled for srcPath + – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath + */ +EXPORT_C void + vgAppendPath(VGPath dstPath, VGPath srcPath) + { + OPENVG_TRACE("vgAppendPath dstPath=0x%x, srcPath=0x%x", dstPath, srcPath); + + TGuestOpenVg::vgAppendPath(dstPath, srcPath); + } + +/* + Appends data taken from pathData to the given path dstPath. The data are formatted + using the path format of dstPath (as returned by querying the path’s VG_PATH_FORMAT + parameter using vgGetParameteri). The numSegments parameter gives the total number + of entries in the pathSegments array, and must be greater than 0. Legal values for + the pathSegments array are the values from the VGPathCommand enumeration as well as + VG_CLOSE_PATH and (VG_CLOSE_PATH | VG_RELATIVE) (which are synonymous). + + The pathData pointer must be aligned on a 1-, 2-, or 4-byte boundary (as defined in + the “Bytes” column of Open VG spec Table 7) depending on the size of the coordinate + datatype (as returned by querying the path’s VG_PATH_DATATYPE parameter using + vgGetParameteri). The VG_PATH_CAPABILITY_APPEND_TO capability must be enabled for + path. + + ERRORS + VG_BAD_HANDLE_ERROR + – if dstPath is not a valid path handle, or is not shared with the current + context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath + VG_ILLEGAL_ARGUMENT_ERROR + – if pathSegments or pathData is NULL + – if pathData is not properly aligned + – if numSegments is less than or equal to 0 + – if pathSegments contains an illegal command + */ +EXPORT_C void + vgAppendPathData(VGPath dstPath, + VGint numSegments, + const VGubyte * pathSegments, + const void * pathData) + { + OPENVG_TRACE("vgAppendPathData dstPath=0x%x, numSegments=%d, pathSegments=0x%x, pathData=0x%x", + dstPath, numSegments, pathSegments, pathData); + + TGuestOpenVg::vgAppendPathData(dstPath, numSegments, pathSegments, pathData); + } + +/* + Modifies the coordinate data for a contiguous range of segments of dstPath, starting + at startIndex (where 0 is the index of the first path segment) and having length + numSegments. The data in pathData must be formatted in exactly the same manner as the + original coordinate data for the given segment range, unless the path has been + transformed using vgTransformPath or interpolated using vgInterpolatePath. In these + cases, the path will have been subject to the segment promotion rules specified in + those functions. + + The pathData pointer must be aligned on a 1-, 2-, or 4-byte boundary + depending on the size of the coordinate datatype (as returned by querying the + path’s VG_PATH_DATATYPE parameter using vgGetParameteri). The + VG_PATH_CAPABILITY_MODIFY capability must be enabled for path. + + ERRORS + VG_BAD_HANDLE_ERROR + – if dstPath is not a valid path handle, or is not shared with the current + context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_MODIFY is not enabled for dstPath + VG_ILLEGAL_ARGUMENT_ERROR + – if pathData is NULL + – if pathData is not properly aligned + – if startIndex is less than 0 + – if numSegments is less than or equal to 0 + – if startIndex + numSegments is greater than the number of segments in the path + */ +EXPORT_C void + vgModifyPathCoords(VGPath dstPath, + VGint startIndex, + VGint numSegments, + const void * pathData) + { + OPENVG_TRACE("vgModifyPathCoords dstPath=0x%x, startIndex=%d, numSegments=%d, pathData=0x%x", + dstPath, startIndex, numSegments, pathData); + + TGuestOpenVg::vgModifyPathCoords(dstPath, startIndex, numSegments, pathData); + } + +/* + Appends a transformed copy of srcPath to the current contents of dstPath. + The appended path is equivalent to the results of applying the current + pathuser-to-surface transformation (VG_MATRIX_PATH_USER_TO_SURFACE) to srcPath. + + It is legal for srcPath and dstPath to be handles to the same path object, in + which case the transformed path will be appended to the existing path. If + srcPath and dstPath are handles to distinct path objects, the contents of + srcPath will not be affected by the call. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dstPath or srcPath is not a valid path handle, or is not shared with + the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_TRANSFORM_FROM is not enabled for srcPath + – if VG_PATH_CAPABILITY_TRANSFORM_TO is not enabled for dstPath + */ +EXPORT_C void + vgTransformPath(VGPath dstPath, VGPath srcPath) + { + OPENVG_TRACE("vgTransformPath dstPath=0x%x, srcPath=0x%x", dstPath, srcPath); + + TGuestOpenVg::vgTransformPath(dstPath, srcPath); + } + +/* + Returns the point lying a given distance along a given portion of a path and + the unit-length tangent vector at that point. Only the subpath consisting of the + numSegments path segments beginning with startSegment (where the initial path + segment has index 0) is used. For the remainder of this section we refer only to + this subpath when discussing paths. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_PATH_CAPABILITY_ERROR + – If x and y are both non-NULL, and the VG_PATH_CAPABILITY_POINT_ALONG_PATH is + not enabled for path + – If tangentX and tangentY are both non-NULL, and the + VG_PATH_CAPABILITY_TANGENT_ALONG_PATH capability is not enabled for path + VG_ILLEGAL_ARGUMENT_ERROR + – if startSegment is less than 0 or greater than the index of the final path + segment + – if numSegments is less than or equal to 0 + – if (startSegment + numSegments – 1) is less than 0 or greater than the index + of the final path segment + – if x, y, tangentX or tangentY is not properly aligned + */ +EXPORT_C void + vgPointAlongPath(VGPath path, + VGint startSegment, + VGint numSegments, + VGfloat distance, + VGfloat * x, VGfloat * y, + VGfloat * tangentX, + VGfloat * tangentY) + { + OPENVG_TRACE("vgPointAlongPath path=0x%x, startSeg=%d, numSegs=%d, distance=%f, x=0x%x, y=0x%x, tangentX=0x%x, tangentY=0x%x", + path, startSegment, numSegments, distance, x, y, tangentX, tangentY); + + TGuestOpenVg::vgPointAlongPath(path, startSegment, numSegments, distance, x, y, tangentX, tangentY); + } + +/* + Performs filling and stroking. The paintModes argument is a bitwise OR of + values from the VGPaintMode enumeration, determining whether the path is to be + filled (VG_FILL_PATH), stroked (VG_STROKE_PATH), or both (VG_FILL_PATH | + VG_STROKE_PATH). If both filling and stroking are to be performed, the path is + first filled, then stroked. + + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + */ +EXPORT_C void + vgDrawPath(VGPath path, VGbitfield paintModes) + { + OPENVG_TRACE("vgDrawPath path=0x%x paintModes=0x%x", path, paintModes); + + TGuestOpenVg::vgDrawPath(path, paintModes); + } + +/* Paint */ + +/* + Deallocates the resources associated with a paint object. Following the call, the + paint handle is no longer valid in any of the contexts that shared it. If the paint + object is currently active in a drawing context, the context continues to access it + until it is replaced or the context is destroyed. + + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +EXPORT_C void vgDestroyPaint(VGPaint paint) + { + OPENVG_TRACE("vgDestroyPaint paint=0x%x", paint); + + TGuestOpenVg::vgDestroyPaint(paint); + } + +/* + Set paint definitions on the current context. The paintModes argument is a + bitwise OR of values from the VGPaintMode enumeration, determining whether + the paint object is to be used for filling (VG_FILL_PATH), stroking + (VG_STROKE_PATH), or both (VG_FILL_PATH | VG_STROKE_PATH). The current paint + replaces the previously set paint object, if any, for the given paint mode + or modes. If paint is equal to VG_INVALID_HANDLE, the previously set paint + object for the given mode (if present) is removed and the paint settings are + restored to their default values. + + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is neither a valid paint handle nor equal to VG_INVALID_HANDLE, + or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + */ +EXPORT_C void + vgSetPaint(VGPaint paint, VGbitfield paintModes) + { + OPENVG_TRACE("vgSetPaint paint=0x%x, paintModes=0x%x", paint, paintModes); + + TGuestOpenVg::vgSetPaint(paint, paintModes); + } + +/* + As a shorthand, the vgSetColor function allows the VG_PAINT_COLOR parameter of a + given paint object to be set using a 32-bit non-premultiplied sRGBA_8888 + representation. The rgba parameter is a VGuint with 8 bits of red starting at the + most significant bit, followed by 8 bits each of green, blue, and alpha. Each color + or alpha channel value is conceptually divided by 255. So as to obtain a value + between 0 and 1. + + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +EXPORT_C void + vgSetColor(VGPaint paint, VGuint rgba) + { + OPENVG_TRACE("vgSetColor paint=0x%x, rgba=0x%x", paint, rgba); + + TGuestOpenVg::vgSetColor(paint, rgba); + } + +/* + Replaces any previous pattern image defined on the given paint object for the given + set of paint modes with a new pattern image. A value of VG_INVALID_HANDLE for the + pattern parameter removes the current pattern image from the paint object. + If the current paint object has its VG_PAINT_TYPE parameter set to VG_PAINT_TYPE_PATTERN, + but no pattern image is set, the paint object behaves as if VG_PAINT_TYPE were set to + VG_PAINT_TYPE_COLOR. While an image is set as the paint pattern for any paint object, it + may not be used as a rendering target. Conversely, an image that is currently a rendering + target may not be set as a paint pattern. + + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + – if pattern is neither a valid image handle nor equal to VG_INVALID_HANDLE, or is not + shared with the current context + VG_IMAGE_IN_USE_ERROR + – if pattern is currently a rendering target + */ +EXPORT_C void + vgPaintPattern(VGPaint paint, VGImage pattern) + { + OPENVG_TRACE("vgPaintPattern paint=0x%x, pattern=0x%x", paint, pattern); + + TGuestOpenVg::vgPaintPattern(paint, pattern); + } + +/* Images */ + +/* + Deallocates the resources associated with an image. Following the call, the image + handle is no longer valid in any context that shared it. If the image is currently + in use as a rendering target, is the ancestor of another image (see vgChildImage), + is set as a paint pattern image on a VGPaint object, or is set as a glyph an a + VGFont object, its definition remains available to those consumers as long as they + remain valid, but the handle may no longer be used. When those uses cease, the + image’s resources will automatically be deallocated. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + */ +EXPORT_C void vgDestroyImage(VGImage image) + { + OPENVG_TRACE("vgDestroyImage image=0x%x -->", image); + + TGuestOpenVg::vgDestroyImage(image); + OPENVG_TRACE("vgDestroyImage <--"); + } + +/* + Fills a given rectangle of an image with the color specified by the VG_CLEAR_COLOR parameter. + The rectangle to be cleared is given by x, y, width, and height, which must define a positive + region. The rectangle is clipped to the bounds of the image. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgClearImage(VGImage image, + VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgClearImage image=0x%x, x=%d, y=%d, width=%d, height=%d", + image, x, y, width, height); + + TGuestOpenVg::vgClearImage(image, x, y, width, height); + } + +/* + Read pixel values from memory, perform format conversion if necessary, and store + the resulting pixels into a rectangular portion of an image. + + Pixel values are read starting at the address given by the pointer data; adjacent + scanlines are separated by dataStride bytes. Negative or zero values of + dataStride are allowed. The region to be written is given by x, y, width, and + height, which must define a positive region. Pixels that fall outside the bounds + of the image are ignored. + + Pixel values in memory are formatted according to the dataFormat parameter, which + must contain a value from the VGImageFormat enumeration. The data pointer must + be aligned according to the number of bytes of the pixel format specified by + dataFormat, unless dataFormat is equal to VG_BW_1, VG_A_1, or VG_A_4, in + which case 1 byte alignment is sufficient. Each pixel is converted into the format of + the destination image as it is written. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +EXPORT_C void + vgImageSubData(VGImage image, + const void * data, + VGint dataStride, + VGImageFormat dataFormat, + VGint x, VGint y, + VGint width, VGint height) + { + OPENVG_TRACE("vgImageSubData image=0x%x, data=0x%x, dataStride=%d, dataFormat=0x%x, x=%d, y=%d, width=%d, height=%d", + image, data, dataStride, dataFormat, x, y, width, height); + + TGuestOpenVg::vgImageSubData(image, data, dataStride, dataFormat, x, y, width, height); + } + +/* + Copies pixels between images. The source image pixel (sx + i, sy + j) is copied + to the destination image pixel (dx + i, dy + j), for 0 <= i < width and + 0 <= j < height. Pixels whose source or destination lie outside of the bounds + of the respective image are ignored. Pixel format conversion is applied as needed. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgCopyImage(VGImage dst, VGint dx, VGint dy, + VGImage src, VGint sx, VGint sy, + VGint width, VGint height, + VGboolean dither) + { + OPENVG_TRACE("vgCopyImage dst=0x%x, dx=%d, dy=%d, src=0x%x, sx=%d, sy=%d, width=%d, height=%d, dither=%d", + dst, dx, dy, src, sx, sy, width, height, dither); + + TGuestOpenVg::vgCopyImage(dst, dx, dy, src, sx, sy, width, height, dither); + } + +/* + Draw an image to the current drawing surface. The current image-user-to-surface + transformation Ti is applied to the image, so that the image pixel centered at + (px + 0.5, py + 0.5) is mapped to the point (Ti)(px + 0.5, py + 0.5). In practice, + backwards mapping may be used. That is, a sample located at (x, y) in the surface + coordinate system is colored according to an interpolated image pixel value at the + point (Ti)-1(x, y) in the image coordinate system. If Ti is non-invertible (or nearly + so, within the limits of numerical accuracy), no drawing occurs. + + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +EXPORT_C void + vgDrawImage(VGImage image) + { + OPENVG_TRACE("vgDrawImage image=0x%x", image); + + TGuestOpenVg::vgDrawImage(image); + } + +/* + Copies pixel data from the image src onto the drawing surface. The image pixel + (sx + i, sy + j) is copied to the drawing surface pixel (dx + i, dy + j), for + 0 <= i < width and 0 <= j < height. Pixels whose source lies outside of the + bounds of src or whose destination lies outside the bounds of the drawing surface + are ignored. Pixel format conversion is applied as needed. Scissoring takes place + normally. Transformations, masking, and blending are not applied. + + ERRORS + VG_BAD_HANDLE_ERROR + – if src is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgSetPixels(VGint dx, VGint dy, + VGImage src, VGint sx, VGint sy, + VGint width, VGint height) + { + OPENVG_TRACE("vgSetPixels dx=%d, dy=%d, src==0x%x, sx=%d, sy=%d, width=%d, height=%d", + dx, dy, src, sx, sy, width, height); + + TGuestOpenVg::vgSetPixels(dx, dy, src, sx, sy, width, height); + } + +/* + Copy pixel data to the drawing surface without the creation of a VGImage object. The pixel + values to be drawn are taken from the data pointer at the time of the vgWritePixels call, + so future changes to the data have no effect. The effects of changes to the data by another + thread at the time of the call to vgWritePixels are undefined. + + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +EXPORT_C void + vgWritePixels(const void * data, VGint dataStride, + VGImageFormat dataFormat, + VGint dx, VGint dy, + VGint width, VGint height) + { + OPENVG_TRACE("vgWritePixels data=0x%x, dataStride=%d, dataFormat=0x%x, dx=%d, dy=%d, width=%d, height=%d", + data, dataStride, dataFormat, dx, dy, width, height); + + TGuestOpenVg::vgWritePixels(data, dataStride, dataFormat, dx, dy, width, height); + } + +/* + Retrieves pixel data from the drawing surface into the image dst. The drawing surface + pixel (sx + i, sy + j) is copied to pixel (dx + i, dy + j) of the image dst, for + 0 <= i < width and 0 <= j < height. Pixels whose source lies outside of the bounds of + the drawing surface or whose destination lies outside the bounds of dst are ignored. + Pixel format conversion is applied as needed. The scissoring region does not affect + the reading of pixels. + + ERRORS + VG_BAD_HANDLE_ERROR + – if dst is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if dst is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgGetPixels(VGImage dst, VGint dx, VGint dy, + VGint sx, VGint sy, + VGint width, VGint height) + { + OPENVG_TRACE("vgGetPixels dst=0x%x, dx=%d, dy=%d, sx=%d, sy=%d, width=%d, height=%d", + dst, dx, dy, sx, sy, width, height); + + TGuestOpenVg::vgGetPixels(dst, dx, dy, sx, sy, width, height); + } + +/* + Copy pixels from one region of the drawing surface to another. Copies between + overlapping regions are allowed and always produce consistent results identical to + copying the entire source region to a scratch buffer followed by copying the scratch + buffer into the destination region. The drawing surface pixel (sx + i, sy + j) is + copied to pixel (dx + i, dy + j) for 0 <= i < width and 0 <= j < height. Pixels whose + source or destination lies outside of the bounds of the drawing surface are ignored. + Transformations, masking, and blending are not applied. Scissoring is applied to the + destination, but does not affect the reading of pixels. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +EXPORT_C void + vgCopyPixels(VGint dx, VGint dy, + VGint sx, VGint sy, + VGint width, VGint height) + { + OPENVG_TRACE("vgCopyPixels dx=%d, dy=%d, sx=%d, sy=%d, width=%d, height=%d", + dx, dy, sx, sy, width, height); + + TGuestOpenVg::vgCopyPixels(dx, dy, sx, sy, width, height); + } + +/* + Destroys the VGFont object pointed to by the font argument. + Note that vgDestroyFont will not destroy underlying objects that were used to + define glyphs in the font. It is the responsibility of an application to destroy all + VGPath or VGImage objects that were used in a VGFont, if they are no longer in + use. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + */ +EXPORT_C void + vgDestroyFont(VGFont font) + { + OPENVG_TRACE("vgDestroyFont font=0x%x", font); + + TGuestOpenVg::vgDestroyFont(font); + } + +/* + Creates a new glyph and assigns the given path to a glyph associated with the + glyphIndex in a font object. The glyphOrigin argument defines the coordinates of + the glyph origin within the path, and the escapement parameter determines the + advance width for this glyph. Both glyphOrigin and escapement coordinates are + defined in the same coordinate system as the path. For glyphs that have no + visual representation (e.g., the character), a value of VG_INVALID_HANDLE + is used for path. The reference count for the path is incremented. + + The path object may define either an original glyph outline, or an outline that + has been scaled and hinted to a particular size (in surface coordinate units); this + is defined by the isHinted parameter, which can be used by implementation + for text-specific optimizations (e.g., heuristic auto-hinting of unhinted outlines). + When isHinted is equal to VG_TRUE, the implementation will never apply + auto-hinting; otherwise, auto hinting will be applied at the implementation's + discretion. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + – if path is not a valid font handle or VG_INVALID_HANDLE, or is not shared + with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if the pointer to glyphOrigin or escapement is NULL or is not properly + aligned + */ +EXPORT_C void + vgSetGlyphToPath(VGFont font, + VGuint glyphIndex, + VGPath path, + VGboolean isHinted, + const VGfloat glyphOrigin [2], + const VGfloat escapement[2]) + { + OPENVG_TRACE("vgSetGlyphToPath font=0x%x, glyphIndex=%u, path=0x%x, isHinted=%d, glyphOrigin=0x%x, escapement=0x%x", + font, glyphIndex, path, isHinted, glyphOrigin, escapement); + + TGuestOpenVg::vgSetGlyphToPath(font, glyphIndex, path, isHinted, glyphOrigin, escapement); + } + +/* + Creates a new glyph and assigns the given image into a glyph associated with + the glyphIndex in a font object. The glyphOrigin argument defines the + coordinates of the glyph origin within the image, and the escapement parameter + determines the advance width for this glyph. Both glyphOrigin and escapement + coordinates are defined in the image coordinate system. Applying transformations + to an image (other than translations mapped to pixel grid in surface coordinate + system) should be avoided as much as possible. For glyphs that have no visual + representation (e.g., the character), a value of VG_INVALID_HANDLE is + used for image. The reference count for the image is incremented. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + – if image is not a valid image handle or VG_INVALID_HANDLE, or is not + shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if the pointer to glyphOrigin or escapement is NULL or is not properly + aligned + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +EXPORT_C void + vgSetGlyphToImage(VGFont font, + VGuint glyphIndex, + VGImage image, + const VGfloat glyphOrigin [2], + const VGfloat escapement[2]) + { + OPENVG_TRACE("vgSetGlyphToImage font=0x%x, glyphIndex=%d, image=0x%x, glyphOrigin=0x%x, escapement=0x%x", + font, glyphIndex, image, (void*)glyphOrigin, (void*)escapement); + + TGuestOpenVg::vgSetGlyphToImage(font, glyphIndex, image, glyphOrigin, escapement); + } + +/* + Deletes the glyph defined by a glyphIndex parameter from a font. The reference count + for the VGPath or VGImage object to which the glyph was previously set is decremented, + and the object's resources are released if the count has fallen to 0. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphIndex is not defined for the font + */ +EXPORT_C void + vgClearGlyph(VGFont font, + VGuint glyphIndex) + { + OPENVG_TRACE("vgClearGlyph font=0x%x, glyphIndex=%u", font, glyphIndex); + + TGuestOpenVg::vgClearGlyph(font, glyphIndex); + } + +/* + Renders a glyph defined by the glyphIndex using the given font object. The + user space position of the glyph (the point where the glyph origin will be + placed) is determined by value of VG_GLYPH_ORIGIN. vgDrawGlyph calculates the + new text origin by translating the glyph origin by the escapement vector of + the glyph defined by glyphIndex. Following the call, the VG_GLYPH_ORIGIN + parameter will be updated with the new origin. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphIndex has not been defined for a given font object + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration, or 0 + */ +EXPORT_C void + vgDrawGlyph(VGFont font, + VGuint glyphIndex, + VGbitfield paintModes, + VGboolean allowAutoHinting) + { + OPENVG_TRACE("vgDrawGlyph font=0x%x, glyphIndex=%u, paintModes=0x%x, allowAutoHinting=%d", + font, glyphIndex, paintModes, allowAutoHinting); + + TGuestOpenVg::vgDrawGlyph(font, glyphIndex, paintModes, allowAutoHinting); + } + +/* + Renders a sequence of glyphs defined by the array pointed to by glyphIndices + using the given font object. The values in the adjustments_x and adjustments_y + arrays define positional adjustment values for each pair of glyphs defined by + the glyphIndices array. The glyphCount parameter defines the number of elements + in the glyphIndices and adjustments_x and adjustments_y arrays. The adjustment + values defined in these arrays may represent kerning or other positional adjustments + required for each pair of glyphs. If no adjustments for glyph positioning in a + particular axis are required (all horizontal and/or vertical adjustments are zero), + NULL pointers may be passed for either or both of adjustment_x and + adjustment_y. The adjustments values should be defined in the same + coordinate system as the font glyphs; if the glyphs are defined by path objects + with path data scaled (e.g., by a factor of 1/units-per-EM), the values in the + adjustment_x and adjustment_y arrays are scaled using the same scale factor. + + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphCount is zero or a negative value + – if the pointer to the glyphIndices array is NULL or is not properly + aligned + – if a pointer to either of the adjustments_x or adjustments_y arrays are + non-NULL and are not properly aligned + – if any of the glyphIndices has not been defined in a given font object + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration, or 0 + */ +EXPORT_C void + vgDrawGlyphs(VGFont font, + VGint glyphCount, + const VGuint * glyphIndices, + const VGfloat * adjustments_x, + const VGfloat * adjustments_y, + VGbitfield paintModes, + VGboolean allowAutoHinting) + { + OPENVG_TRACE("vgDrawGlyphs font=0x%x, glyphCount=%d, glyphIndices=0x%x, adjustments_y=0x%x, " + "adjustments_x=0x%x, paintModes=0x%x, allowAutoHinting=%d", + font, glyphCount, (void*)glyphIndices, (void*)adjustments_x, (void*)adjustments_y, paintModes, allowAutoHinting); + + TGuestOpenVg::vgDrawGlyphs(font, glyphCount, glyphIndices, adjustments_x, adjustments_y, paintModes, allowAutoHinting); + } + +/* Image Filters */ + +/* + Computes a linear combination of color and alpha values (Rsrc, Gsrc, Bsrc, + ALPHAsrc) from the normalized source image src at each pixel. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if matrix is NULL + – if matrix is not properly aligned + */ +EXPORT_C void + vgColorMatrix(VGImage dst, VGImage src, + const VGfloat * matrix) + { + OPENVG_TRACE("vgColorMatrix dst=0x%x, src=0x%x, matrix=0x%x", dst, src, matrix); + + TGuestOpenVg::vgColorMatrix(dst, src, matrix); + } + +/* + Applies a user-supplied convolution kernel to a normalized source image src. The + dimensions of the kernel are given by kernelWidth and kernelHeight; the kernel values + are specified as kernelWidth*kernelHeight VGshorts in column-major order. That is, + the kernel entry (i, j) is located at position i*kernelHeight + j in the input sequence. + The shiftX and shiftY parameters specify a translation between the source and + destination images. The result of the convolution is multiplied by a scale factor, and + a bias is added. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if kernelWidth or kernelHeight is less than or equal to 0 or greater than + VG_MAX_KERNEL_SIZE + – if kernel is NULL + – if kernel is not properly aligned + – if tilingMode is not one of the values from the VGTilingMode enumeration + */ +EXPORT_C void + vgConvolve(VGImage dst, VGImage src, + VGint kernelWidth, VGint kernelHeight, + VGint shiftX, VGint shiftY, + const VGshort * kernel, + VGfloat scale, + VGfloat bias, + VGTilingMode tilingMode) + { + OPENVG_TRACE("vgConvolve dst=0x%x, src=0x%x, kW=%d, kH=%d, shX=%d, shY=%d, kernel=0x%x, scale=%f, bias=%f, tiling=0x%x", + dst, src, kernelWidth, kernelHeight, shiftX, shiftY, kernel, scale, bias, tilingMode); + + TGuestOpenVg::vgConvolve(dst, src, kernelWidth, kernelHeight, shiftX, shiftY, kernel, scale, bias, tilingMode); + } + +/* + Applies a user-supplied separable convolution kernel to a normalized source image src. + A separable kernel is a two-dimensional kernel in which each entry kij is equal to a + product kxi * kyj of elements from two one dimensional kernels, one horizontal and one + vertical. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if kernelWidth or kernelHeight is less than or equal to 0 or greater than + VG_MAX_SEPARABLE_KERNEL_SIZE + – if kernelX or kernelY is NULL + – if kernelX or kernelY is not properly aligned + – if tilingMode is not one of the values from the VGTilingMode + enumeration + */ +EXPORT_C void + vgSeparableConvolve(VGImage dst, VGImage src, + VGint kernelWidth, + VGint kernelHeight, + VGint shiftX, VGint shiftY, + const VGshort * kernelX, + const VGshort * kernelY, + VGfloat scale, + VGfloat bias, + VGTilingMode tilingMode) + { + OPENVG_TRACE("vgSeparableConvolve dst=0x%x, src=0x%x, kW=%d, kH=%d, shX=%d, shY=%d, kX=0x%x, kY=0x%x, scale=%f, bias=%f, tiling=0x%x", + dst, src, kernelWidth, kernelHeight, shiftX, shiftY, kernelX, kernelY, scale, bias, tilingMode); + + TGuestOpenVg::vgSeparableConvolve(dst, src, kernelWidth, kernelHeight, shiftX, shiftY, kernelX, kernelY, scale, bias, tilingMode); + } + +/* + Computes the convolution of a normalized source image src with a separable kernel + defined in each dimension by the Gaussian function G(x, s). + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if stdDeviationX or stdDeviationY is less than or equal to 0 or greater + than VG_MAX_GAUSSIAN_STD_DEVIATION + – if tilingMode is not one of the values from the VGTilingMode + enumeration + */ +EXPORT_C void + vgGaussianBlur(VGImage dst, VGImage src, + VGfloat stdDeviationX, + VGfloat stdDeviationY, + VGTilingMode tilingMode) + { + OPENVG_TRACE("vgGaussianBlur dst=0x%x, src=0x%x, stdDeviationX=%f, stdDeviationY=%f, tilingMode=%d", + dst, src, stdDeviationX, stdDeviationY, tilingMode); + + TGuestOpenVg::vgGaussianBlur(dst, src, stdDeviationX, stdDeviationY, tilingMode); + } + +/* + Passes each image channel of the normalized source image src through a separate lookup + table. + + Each channel of the normalized source pixel is used as an index into the lookup table for + that channel by multiplying the normalized value by 255 and rounding to obtain an 8-bit + integral value. Each LUT parameter should contain 256 VGubyte entries. The + outputs of the lookup tables are concatenated to form an RGBA_8888 pixel + value, which is interpreted as lRGBA_8888, lRGBA_8888_PRE, sRGBA_8888, + or sRGBA_8888_PRE, depending on the values of outputLinear and outputPremultiplied. + + The resulting pixels are converted into the destination format using the normal + pixel format conversion rules. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if any pointer parameter is NULL + */ +EXPORT_C void + vgLookup(VGImage dst, VGImage src, + const VGubyte * redLUT, + const VGubyte * greenLUT, + const VGubyte * blueLUT, + const VGubyte * alphaLUT, + VGboolean outputLinear, + VGboolean outputPremultiplied) + { + OPENVG_TRACE("vgLookup dst=0x%x, src=0x%x, redLUT=0x%x, greenLUT=0x%x, blueLUT=0x%x, alphaLUT=0x%x, opLin=%d, opPremul=%d", + dst, src, redLUT, greenLUT, blueLUT, alphaLUT, outputLinear, outputPremultiplied); + + TGuestOpenVg::vgLookup(dst, src, redLUT, greenLUT, blueLUT, alphaLUT, outputLinear, outputPremultiplied); + } + +/* + Passes a single image channel of the normalized source image src, selected by the + sourceChannel parameter, through a combined lookup table that produces whole pixel + values. Each normalized source channel value is multiplied by 255 and rounded to + obtain an 8 bit integral value. + + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if src is in an RGB pixel format and sourceChannel is not one of VG_RED, + VG_GREEN, VG_BLUE or VG_ALPHA from the VGImageChannel enumeration + – if lookupTable is NULL + – if lookupTable is not properly aligned + */ +EXPORT_C void + vgLookupSingle(VGImage dst, VGImage src, + const VGuint * lookupTable, + VGImageChannel sourceChannel, + VGboolean outputLinear, + VGboolean outputPremultiplied) + { + OPENVG_TRACE("vgLookupSingle dst=0x%x, src=0x%x, lookupTable=0x%x, sourceChannel=0x%x, opLin=%d, opPremul=%d", + dst, src, lookupTable, sourceChannel, outputLinear, outputPremultiplied); + + TGuestOpenVg::vgLookupSingle(dst, src, lookupTable, sourceChannel, outputLinear, outputPremultiplied); + } + +// guest support for OpenVG extension #4, KHR_EGL_image - vgCreateEGLImageTargetKHR(VGeglImageKHR image) +/* + Creates an EGLImage target VGImage object from the provided EGLImage + . should be of type EGLImageKHR, cast into the type + VGeglImageKHR. Assuming no errors are generated in this function, + the resulting VGImage will be an EGLImage target of the specified + EGLImage . As a side-effect of the referencing operation, + all of the pixel data in the used as the EGLImage source + resource (i.e., the parameter passed to the CreateImageKHR + command that returned ) will become undefined. + + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + - if the OpenVG implementation is not able to create a VGImage + compatible with the provided VGeglImageKHR for an implementation- + dependent reason (this could be caused by, but not limited to, + reasons such as unsupported pixel formats, anti-aliasing quality, + etc.). + + VG_ILLEGAL_ARGUMENT_ERROR + - if is not a valid VGeglImageKHR. + */ +VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR image) + { + OPENVG_TRACE("vgCreateEGLImageTargetKHR image=0x%x -->", image); + + VGImage imageHandle = TGuestOpenVg::vgCreateEGLImageTargetKHR(image); + OPENVG_TRACE("vgCreateEGLImageTargetKHR imageHandle=0x%x <--", imageHandle); + return imageHandle; + } + + +} /* extern "C" */ + +// end of file openvg.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgapi.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,2461 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// C++ version of Open VG API. + +#include "openvg.inl" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +// normalized IEEE 754 representations +const float KFloatMinusOne = -1.0f; +const float KFloatZero = 0.0f; + +const TInt KTransformMatrixSize = 9; + +///////////////////////////////////////////////////////////////////////////////////////////// +// TGuestOpenVg +///////////////////////////////////////////////////////////////////////////////////////////// + +// --------------------------------------------------------------------- +// TGuestOpenVg - private inline & paramater checking functions + +// helper function +/////////////////////////////////////////////////////////////////////////////////////////////// +// Implementation of Open VG APIs ... with comments summarising possible errors. + +//////////////////////////////////////////////////////////////////////////////////////////// +//Functions returning value +//////////////////////////////////////////////////////////////////////////////////////////// + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paintMode is not a valid value from the VGPaintMode enumeration + */ +VGPaint TGuestOpenVg::vgGetPaint(VGPaintMode aPaintMode) + { + VGPaint paintHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext && TCheck::ChkVGPaintMode(*vgContext, aPaintMode)) + { + TCleanupVgLocks vgLock(*vgContext); + paintHandle = vgLock.GetPaint(aPaintMode); + } + else if (!vgContext) + { + OPENVG_TRACE(" TGuestOpenVg::vgGetPaint - no VG context"); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgGetPaint - ParamCheck failed"); + } + return paintHandle; + } + + +/* + If insufficient memory is available to allocate a new object, VG_INVALID_HANDLE is returned. + */ +VGPaint TGuestOpenVg::vgCreatePaint() + { + VGPaint paintHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + TCleanupVgLocks vgLock(*vgContext); + paintHandle = vgLock.CreatePaint(); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreatePaint - no VG context"); + } + + return paintHandle; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if any of dstPath, startPath, or endPath is not a valid path handle, or is + not shared with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_INTERPOLATE_TO is not enabled for dstPath + – if VG_PATH_CAPABILITY_INTERPOLATE_FROM is not enabled for startPath or endPath + */ +VGboolean TGuestOpenVg::vgInterpolatePath(VGPath aDstPath, VGPath aStartPath, VGPath aEndPath, VGfloat aAmount) + { + VGboolean result = VG_FALSE; + MVgContext* vgContext = CVghwUtils::VgContext(); + + if ( vgContext ) + { + CVgPathInfo* dstPathInfo = NULL; + CVgPathInfo* startPathInfo = NULL; + CVgPathInfo* endPathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_TO) && + vgLock.CheckVGPath(aStartPath, &startPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_FROM) && + vgLock.CheckVGPath(aEndPath, &endPathInfo, VG_PATH_CAPABILITY_INTERPOLATE_FROM) ) + { + result = dstPathInfo->InterpolatePath(*vgContext, *startPathInfo, *endPathInfo, aAmount); + } + } + return result; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_LENGTH is not enabled for path + VG_ILLEGAL_ARGUMENT_ERROR + – if startSegment is less than 0 or greater than the index of the final path + segment + – if numSegments is less than or equal to 0 + – if (startSegment + numSegments – 1) is greater than the index of the final + path segment + */ +VGfloat TGuestOpenVg::vgPathLength(VGPath aPath, VGint aStartSegment, VGint aNumSegments) + { + VGfloat result = KFloatMinusOne; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_LENGTH) ) + { + if ( (aStartSegment < 0) || (aNumSegments <= 0) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + result = pathInfo->PathLength(*vgContext, aStartSegment, aNumSegments); + } + } + } + return result; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +VGbitfield TGuestOpenVg::vgGetPathCapabilities(VGPath aPath) + { + VGbitfield result = 0; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + result = pathInfo->GetPathCapabilities(*vgContext); + } + } + return result; + } + + +/* + ERRORS + VG_UNSUPPORTED_PATH_FORMAT_ERROR + – if pathFormat is not a supported format + VG_ILLEGAL_ARGUMENT_ERROR + – if datatype is not a valid value from the VGPathDatatype enumeration + – if scale is equal to 0 + */ +VGPath TGuestOpenVg::vgCreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, + VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities) + { + VGPath pathHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkVGPathFormat(*vgContext, aPathFormat) && TCheck::ChkVGPathDataType(*vgContext, aDatatype) ) + { + if (aScale == KFloatZero) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + TCleanupVgLocks vgLock(*vgContext); // Waits & holds VG mutex until destruction + pathHandle = vgLock.CreatePath(aPathFormat, aDatatype, aScale, aBias, aSegmentCapacityHint, aCoordCapacityHint, aCapabilities); + } + } + else if (!vgContext) + { + OPENVG_TRACE(" TGuestOpenVg::vgCreatePath - no VG context"); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreatePath - ParamCheck failed"); + } + + return pathHandle; + } + + +/* For vgGeti, vgGetf, and vgGetVectorSize. +If an error occurs during a call to vgGetf, vgGeti, or vgGetVectorSize, the return value +is undefined. + +ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a vector parameter in vgGetf or vgGeti +*/ +VGint TGuestOpenVg::HostGeti(MVgContext& aVgContext, VGParamType aType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGeti); + vgApiData.AppendParam(aType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGfloat TGuestOpenVg::HostGetf(MVgContext& aVgContext, VGParamType aType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetf); + vgApiData.AppendParam(aType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGint TGuestOpenVg::vgGeti(VGParamType aType) + { + // TODO validate aType + VGint result = 0; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + result = HostGeti(*vgContext, aType); + } + return result; + } + + +VGfloat TGuestOpenVg::vgGetf(VGParamType aType) + { + // TODO validate aType + VGfloat result = KFloatMinusOne; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + result = HostGetf(*vgContext, aType); + } + return result; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a vector parameter in vgGetParameterf or + vgGetParameteri + */ +VGint TGuestOpenVg::vgGetParameteri(VGHandle aObject, VGint aParamType) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) + { + return handleInfo->GetParameteri(*vgContext, aParamType); + } + } + return 0; + } + + +VGint TGuestOpenVg::HostGetVectorSize(MVgContext& aVgContext, VGParamType aType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetVectorSize); + vgApiData.AppendParam(aType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGint TGuestOpenVg::vgGetVectorSize(VGParamType aType) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { // **** Desirable: check aType + return HostGetVectorSize(*vgContext, aType); + } + return 0; + } + + +VGfloat TGuestOpenVg::vgGetParameterf(VGHandle aObject, VGint aParamType) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) + { + return handleInfo->GetParameterf(*vgContext, aParamType); + } + } + return KFloatMinusOne; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + */ +VGint TGuestOpenVg::vgGetParameterVectorSize(VGHandle aObject, VGint aParamType) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + // **** Desirable: check aParamType + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) + { + return handleInfo->GetParameterVectorSize(*vgContext, aParamType); + } + } + return 0; + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if width is greater than VG_MAX_IMAGE_WIDTH + – if height is greater than VG_MAX_IMAGE_HEIGHT + – if width*height is greater than VG_MAX_IMAGE_PIXELS + */ +VGMaskLayer TGuestOpenVg::vgCreateMaskLayer(VGint aWidth, VGint aHeight) + { + VGMaskLayer maskLayerHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkNewImageSize(*vgContext, aWidth, aHeight) ) + { + TCleanupVgLocks vgLock(*vgContext); + maskLayerHandle = vgLock.CreateMaskLayer(aWidth, aHeight); + } + else if (!vgContext) + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateMaskLayer - no VG context"); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateMaskLayer - ParamCheck failed"); + } + + return maskLayerHandle; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +VGuint TGuestOpenVg::vgGetColor(VGPaint aPaint) + { + VGuint result = 0; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPaintInfo* paintInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) + { + result = paintInfo->GetColor(*vgContext); + } + } + return result; + } + + +/* + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if format is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if width is greater than VG_MAX_IMAGE_WIDTH + – if height is greater than VG_MAX_IMAGE_HEIGHT + – if width*height is greater than VG_MAX_IMAGE_PIXELS + – if width*height*(pixel size of format) is greater than + VG_MAX_IMAGE_BYTES + – if allowedQuality is not a bitwise OR of values from the + VGImageQuality enumeration + */ +VGImage TGuestOpenVg::vgCreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality) + { + VGHandle imageHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkNewImageSize(*vgContext, aWidth, aHeight) && TCheck::ChkVgImageFormat(*vgContext, aFormat) ) + { // width > 0 && height > 0 + TCleanupVgLocks vgLock(*vgContext); + imageHandle = vgLock.CreateImage(aFormat, aWidth, aHeight, aAllowedQuality); + } + else if (!vgContext) + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateImage - no VG context"); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateImage - ParamCheck failed"); + } + + return imageHandle; + } + + +/* + Returns a new VGImage handle that refers to a portion of the parent image. The + region is given by the intersection of the bounds of the parent image with the + rectangle beginning at pixel (x, y) with dimensions width and height, which + must define a positive region contained entirely within parent. + + ERRORS + VG_BAD_HANDLE_ERROR + – if parent is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if parent is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if x is less than 0 or greater than or equal to the parent width + – if y is less than 0 or greater than or equal to the parent height + – if width or height is less than or equal to 0 + – if x + width is greater than the parent width + – if y + height is greater than the parent height + */ +VGImage TGuestOpenVg::vgChildImage(VGImage aParent, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + VGHandle imageHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* parentInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aParent, &parentInfo) && TCheck::ChkAreaIsWithinImage(*vgContext, parentInfo, aX, aY, aWidth, aHeight) ) + { // child image area is within parent image + imageHandle = vgLock.ChildImage(*parentInfo, aX, aY, aWidth, aHeight); + } + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgChildImage - no VG context"); + } + + return imageHandle; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +VGImage TGuestOpenVg::vgGetParent(VGImage aImage) + { + VGImage parentImage = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) ) + { + // baseline for a valid image is to return its own ClientHandle + parentImage = aImage; + // try to find a non-destroyed ancestor + // ToDo add getParent Api to CVgImageInfo + CVgImageInfo* parentInfo = imageInfo->Parent(); + while (parentInfo) + { + if ( !parentInfo->IsDestroyed() ) + { // nearest an ancestor + parentImage = parentInfo->ClientHandle(); + break; + } + parentInfo = parentInfo->Parent(); + } + } + } + return parentImage; + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphCapacityHint is negative + */ +VGFont TGuestOpenVg::vgCreateFont(VGint aGlyphCapacityHint) + { + VGHandle fontHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + TCleanupVgLocks vgLock(*vgContext); + fontHandle = vgLock.CreateFont(aGlyphCapacityHint); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateFont - no VG context"); + } + + return fontHandle; + } + + +/* Hardware Queries */ + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if key is not one of the values from the VGHardwareQueryType enumeration + – if setting is not one of the values from the enumeration associated with + key + */ +VGHardwareQueryResult TGuestOpenVg::vgHardwareQuery(VGHardwareQueryType aKey, VGint aSetting) + { + TBool paramsValid = EFalse; + + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + switch (aKey) + { + case VG_IMAGE_FORMAT_QUERY: + if (TCheck::ImageFormatByteDepth(static_cast(aSetting)) > 0) + paramsValid = ETrue; + break; + case VG_PATH_DATATYPE_QUERY: + switch (aSetting) + { + case VG_PATH_DATATYPE_S_8: + case VG_PATH_DATATYPE_S_16: + case VG_PATH_DATATYPE_S_32: + case VG_PATH_DATATYPE_F: + paramsValid = ETrue; + } + break; + } + if (paramsValid) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgHardwareQuery); + vgApiData.AppendParam(aKey); + vgApiData.AppendParam(aSetting); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + vgContext->ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return VG_HARDWARE_UNACCELERATED; + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if values is NULL in vgGetParameterfv or vgGetParameteriv + – if values is not properly aligned in vgGetParameterfv or vgGetParameteriv + – if count is less than or equal to 0 in vgGetParameterfv or vgGetParameteriv + – if count is greater than the value returned by vgGetParameterVectorSize for + the given parameter in vgGetParameterfv or vgGetParameteriv + */ +void TGuestOpenVg::vgGetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, VGfloat * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::Chk32bitPtr(*vgContext, aValues) ) + { + handleInfo->GetParameterfv(*vgContext, aParamType, aCount, aValues); + } + } + } + + +void TGuestOpenVg::vgGetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, VGint * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::Chk32bitPtr(*vgContext, aValues) ) + { + handleInfo->GetParameteriv(*vgContext, aParamType, aCount, aValues); + } + } + } + + +/* Renderer and Extension Information */ + +/* Getxv supports vgGetfv & vgGetiv APIs. + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if values is NULL in vgGetfv or vgGetiv + – if values is not properly aligned in vgGetfv or vgGetiv + – if count is less than or equal to 0 in vgGetfv or vgGetiv + – if count is greater than the value returned by vgGetVectorSize for the + given parameter in vgGetfv or vgGetiv + */ +// **** Desirable: can probably do common VGParamType checking for Getx & Getxv, Setx, & Setxv. +void TGuestOpenVg::vgGetfv(VGParamType aType, VGint aCount, const VGfloat * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext && TCheck::Chk32bitPtr(*vgContext, aValues)) + { + // **** Desirable: check all parameters + if ( (aCount <= 0) || (aCount > HostGetVectorSize(*vgContext, aType)) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetfv); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); + vgContext->ExecuteVgCommand(vgApiData); + } + } + } + + +void TGuestOpenVg::vgGetiv(VGParamType aType, VGint aCount, const VGint * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aValues) ) + { + // **** Desirable: check all parameters + if ( (aCount <= 0) || (aCount > HostGetVectorSize(*vgContext, aType)) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetiv); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); + vgContext->ExecuteVgCommand(vgApiData); + } + } + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +void TGuestOpenVg::vgGetMatrix(VGfloat* aM) + { + // check mat pointer is 32-bit aligned + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetMatrix); + vgApiData.AppendVector(aM, KTransformMatrixSize, RemoteFunctionCallData::EOut); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +void TGuestOpenVg::vgGetImageSubData(VGImage aImage, void* aData, VGint aDataStride, VGImageFormat aDataFormat, + VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && + TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + imageInfo->GetImageSubData(*vgContext, aData, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +void TGuestOpenVg::HostVgReadPixels(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer); + VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgReadPixels); + vgApiData.AppendVector(aPixmap, aPixmapSize, RemoteFunctionCallData::EOut); + vgApiData.AppendParam(aHostDataStride); + vgApiData.AppendParam(aDataFormat); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgApiData.AppendParam((VGint)aPixmapSize); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void TGuestOpenVg::vgReadPixels(void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aSx, VGint aSy, + VGint aWidth, VGint aHeight) + { + // **** Desirable: check all parameters + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { // width > 0 && height > 0 + TInt bitsPerPixel = CVgImageInfo::BitsPerPixelForVgImageFormat(aDataFormat); + TUint32 lineLength = static_cast(aWidth) * static_cast(bitsPerPixel); + TUint32 tailBits = lineLength & 7; + lineLength = (lineLength + 7) / 8; + OPENVG_TRACE("vgReadPixels.1 bitsPerPixel=%d, lineLength=%d, tailBits=%d", bitsPerPixel, lineLength, tailBits); + // ToDo clip aWidth & aHeight to the surface width & height + + if (bitsPerPixel <= 0) + { + vgContext->SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + } + else + { + if (lineLength == aDataStride) + { // use original params + OPENVG_TRACE("vgReadPixels.2a: lineLength == dataStride"); + HostVgReadPixels(*vgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aSx, aSy, aWidth, aHeight); + } + else if (0 == aDataStride) + { // unlikely unless aHeight = 1, but symmetric to fill function for vgWritePixels + OPENVG_TRACE("vgReadPixels.2b: 0 == dataStride"); + HostVgReadPixels(*vgContext, aData, lineLength, aDataStride, aDataFormat, aSx, aSy, aWidth, aHeight); + } + else + { // datastride maybe negative or simply > lineLength + TInt pixmapSize = lineLength * aHeight; + TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); + OPENVG_TRACE("vgReadPixels.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); + + if (localBuffer != NULL) + { // read pixels into temporary buffer + HostVgReadPixels(*vgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aSx, aSy, aWidth, aHeight); + // reformat into client memory + CVgImageInfo::PixmapBlit(static_cast(aData), localBuffer, aDataStride, lineLength, aHeight, lineLength, tailBits); + CVghwUtils::Free(localBuffer); + } + else + { // alloc failed, so do VG operation row by row + TUint8* dest = static_cast(aData); + for (VGint row = 0; row < aHeight; ++row) + { + HostVgReadPixels(*vgContext, dest, lineLength, lineLength, aDataFormat, aSx + row, aSy, aWidth, 1); + dest += aDataStride; + } + } + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if minX, minY, width, or height is NULL + – if minX, minY, width, or height is not properly aligned + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_BOUNDS is not enabled for path + */ +void TGuestOpenVg::vgPathBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_BOUNDS) ) + { + pathInfo->PathBounds(*vgContext, aMinX, aMinY, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if minX, minY, width, or height is NULL + – if minX, minY, width, or height is not properly aligned + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS is not enabled + for path + */ +void TGuestOpenVg::vgPathTransformedBounds(VGPath aPath, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo, VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS) ) + { + pathInfo->PathTransformedBounds(*vgContext, aMinX, aMinY, aWidth, aHeight); + } + } + } + + +//////////////////////////////////////////////////////////////////////////////////////////// +//Functions not returning value (possible to buffer) +//////////////////////////////////////////////////////////////////////////////////////////// +/* Getters and Setters */ + +/* + vgSeti and vgSetf + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a vector parameter in vgSetf or vgSeti + – if value is not a legal enumerated value for the given parameter in vgSetf or + vgSeti + */ +void TGuestOpenVg::vgSeti(VGParamType aType, VGint aValue) + { + // **** Desirable: check aType + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSeti, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aValue); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +void TGuestOpenVg::vgSetf(VGParamType aType, VGfloat aValue) + { + // **** Desirable: check aType + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetf, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aValue); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + vgSetiv and vgSetfv + + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the VGParamType enumeration + – if paramType refers to a scalar parameter in vgSetfv or vgSetiv and count is + not equal to 1 + – if values[i] is not a legal enumerated value for the given parameter in vgSetfv + or vgSetiv for 0 <= i < count + – if values is NULL in vgSetfv or vgSetiv and count is greater than 0 + – if values is not properly aligned in vgSetfv or vgSetiv + – if count is less than 0 in vgSetfv or vgSetiv + – if count is not a valid value for the given parameter + */ +void TGuestOpenVg::vgSetfv(VGParamType aType, VGint aCount, const VGfloat * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext && TCheck::Chk32bitPtr(*vgContext, aValues)) + { + // **** Desirable: check all params + // we should check count for not being too large for serialization, but + // there is no limit in spec for VG_SCISSOR_RECTS and VG_STROKE_DASH_PATTERN + if ( (aCount < 0) || (aCount > 100000) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetfv, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount); + vgContext->ExecuteVgCommand(vgApiData); + } + } + } + + +void TGuestOpenVg::vgSetiv(VGParamType aType, VGint aCount, const VGint * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aValues) ) + { + // **** Desirable: check all params + // we should check count for not being too large for serialization, but + // there is no limit in spec for VG_SCISSOR_RECTS and VG_STROKE_DASH_PATTERN + if ( (aCount < 0) || (aCount > 100000) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetiv, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount); + vgContext->ExecuteVgCommand(vgApiData); + } + } + } + + +/* + For vgSetParameterf and vgSetParameteri. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a vector parameter in vgSetParameterf or + vgSetParameteri + – if value is not a legal enumerated value for the given parameter in + vgSetParameterf or vgSetParameteri + */ + +void TGuestOpenVg::vgSetParameteri(VGHandle aObject, VGint aParamType, VGint aValue) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) + { + handleInfo->SetParameteri(*vgContext, aParamType, aValue); + } + } + } + + +void TGuestOpenVg::vgSetParameterf(VGHandle aObject, VGint aParamType, VGfloat aValue) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) ) + { + handleInfo->SetParameterf(*vgContext, aParamType, aValue); + } + } + } + + +/* + For vgSetParameterfv and vgSetParameteriv. + + The vgSetParameter functions set the value of a parameter on a given VGHandlebased + object. + + ERRORS + VG_BAD_HANDLE_ERROR + – if object is not a valid handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paramType is not a valid value from the appropriate enumeration + – if paramType refers to a scalar parameter in vgSetParameterfv or + vgSetParameteriv and count is not equal to 1 + – if values[i] is not a legal enumerated value for the given parameter + in vgSetParameterfv or vgSetParameteriv for 0 <= i < count + – if values is NULL in vgSetParameterfv or vgSetParameteriv and count is + greater than 0 + – if values is not properly aligned in vgSetParameterfv or vgSetParameteriv + – if count is less than 0 in vgSetParameterfv or vgSetParameteriv + – if count is not a valid value for the given parameter + */ +void TGuestOpenVg::vgSetParameterfv(VGHandle aObject, VGint aParamType, VGint aCount, const VGfloat * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + // ToDo review overlapping checks between TCheck::ParamCountAndValuesPtr to SetParameterfv + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::ChkParamCountAndValuesPtr(*vgContext, aCount, aValues) ) + { + handleInfo->SetParameterfv(*vgContext, aParamType, aCount, aValues); + } + } + } + + +void TGuestOpenVg::vgSetParameteriv(VGHandle aObject, VGint aParamType, VGint aCount, const VGint * aValues) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgHandleBase* handleInfo; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGAnyHandle(aObject, &handleInfo) && TCheck::ChkParamCountAndValuesPtr(*vgContext, aCount, aValues) ) + { + handleInfo->SetParameteriv(*vgContext, aParamType, aCount, aValues); + } + } + } + + +/* Matrix Manipulation */ +/* + No errors if Context is valid. + */ +void TGuestOpenVg::vgLoadIdentity() + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgLoadIdentity, RemoteFunctionCallData::EOpRequest); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +void TGuestOpenVg::vgLoadMatrix(const VGfloat* aM) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgLoadMatrix, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendVector(aM, KTransformMatrixSize); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if m is NULL + – if m is not properly aligned + */ +void TGuestOpenVg::vgMultMatrix(const VGfloat* aM) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::Chk32bitPtr(*vgContext, aM) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgMultMatrix, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendVector(aM, KTransformMatrixSize); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + No errors if Context is valid. + */ +void TGuestOpenVg::vgTranslate(VGfloat aTx, VGfloat aTy) + { + // **** Desirable: check all parameters + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgTranslate, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aTx); + vgApiData.AppendParam(aTy); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + No errors if Context is valid. + */ +// **** Desirable: Coalesce with vgTranslate +void TGuestOpenVg::vgScale(VGfloat aSx, VGfloat aSy) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgScale, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + No errors if Context is valid. + */ +// **** Desirable: Coalesce with vgTranslate +void TGuestOpenVg::vgShear(VGfloat aShx, VGfloat aShy) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgShear, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aShx); + vgApiData.AppendParam(aShy); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + No errors if Context is valid. + */ +void TGuestOpenVg::vgRotate(VGfloat aAngle) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgRotate, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aAngle); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if operation is not VG_CLEAR_MASK or VG_FILL_MASK, and mask is not a + valid mask layer or image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if mask is a VGImage that is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if operation is not a valid value from the VGMaskOperation + enumeration + – if width or height is less than or equal to 0 + – if mask is a VGMaskLayer and is not compatible with the current surface + mask + */ +void TGuestOpenVg::vgMask(VGHandle aMask, VGMaskOperation aOperation, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageBase* maskInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + // **** Desirable: mask/surface compatibility check + if ( vgLock.CheckVGMaskOperationAndHandle(aOperation, aMask, &maskInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgMask, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam( (maskInfo == NULL) ? VG_INVALID_HANDLE : maskInfo->HostHandle() ); + vgApiData.AppendParam(aOperation); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + TUint64 sgId(0L); + if ( maskInfo && (maskInfo->HandleType() == EVgHandleForImage) ) + { + CVgImageInfo* imageInfo = (CVgImageInfo*)maskInfo; + if (imageInfo->IsEglSibling()) + { + sgId = imageInfo->SgImageId(); + } + } + vgApiData.AppendTUint64(sgId); + vgContext->ExecuteVgCommand(vgApiData); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + – if operation is not a valid value from the VGMaskOperation enumeration + */ +void TGuestOpenVg::vgRenderToMask(VGPath aPath, VGbitfield aPaintModes, VGMaskOperation aOperation) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + pathInfo->RenderToMask(*vgContext, aPaintModes, aOperation); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask handle + */ +void TGuestOpenVg::vgDestroyMaskLayer(VGMaskLayer aMaskLayer) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + CVgMaskLayerInfo* maskLayerInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) ) + { + maskLayerInfo->Destroy(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask layer handle, or is not shared with the + current context + VG_ILLEGAL_ARGUMENT_ERROR + – if value is less than 0 or greater than 1 + – if width or height is less than or equal to 0 + – if x or y is less than 0 + – if x + width is greater than the width of the mask + – if y + height is greater than the height of the mask + */ +void TGuestOpenVg::vgFillMaskLayer(VGMaskLayer aMaskLayer, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgMaskLayerInfo* maskLayerInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) && TCheck::ChkAreaIsWithinImage(*vgContext, maskLayerInfo, aX, aY, aWidth, aHeight) ) + { + maskLayerInfo->FillMaskLayer(*vgContext, aX, aY, aWidth, aHeight, aValue); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if maskLayer is not a valid mask layer handle + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height are less than or equal to 0 + – if maskLayer is not compatible with the current surface mask + */ +void TGuestOpenVg::vgCopyMask(VGMaskLayer aMaskLayer, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgMaskLayerInfo* maskLayerInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGMaskLayer(aMaskLayer, &maskLayerInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + maskLayerInfo->CopyMask(*vgContext, aSx, aSy, aDx, aDy, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgClear(VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { // width > 0 && height > 0 + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgClear, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* Paths */ + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +void TGuestOpenVg::vgClearPath(VGPath aPath, VGbitfield aCapabilities) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + pathInfo->ClearPath(*vgContext, aCapabilities); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +void TGuestOpenVg::vgDestroyPath(VGPath aPath) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + pathInfo->Destroy(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + */ +void TGuestOpenVg::vgRemovePathCapabilities(VGPath aPath, VGbitfield aCapabilities) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + pathInfo->RemovePathCapabilities(*vgContext, aCapabilities); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dstPath or srcPath is not a valid path handle, or is not shared + with the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_APPEND_FROM is not enabled for srcPath + – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath + */ +void TGuestOpenVg::vgAppendPath(VGPath aDstPath, VGPath aSrcPath) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* dstPathInfo = NULL; + CVgPathInfo* srcPathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_APPEND_TO) && + vgLock.CheckVGPath(aSrcPath, &srcPathInfo, VG_PATH_CAPABILITY_APPEND_FROM) ) + { + dstPathInfo->AppendPath(*vgContext, *srcPathInfo); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if dstPath is not a valid path handle, or is not shared with the current + context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_APPEND_TO is not enabled for dstPath + VG_ILLEGAL_ARGUMENT_ERROR + – if pathSegments or pathData is NULL + – if pathData is not properly aligned + – if numSegments is less than or equal to 0 + – if pathSegments contains an illegal command + */ +void TGuestOpenVg::vgAppendPathData(VGPath aDstPath, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* dstPathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_APPEND_TO) ) + { + dstPathInfo->AppendPathData(*vgContext, aNumSegments, aPathSegments, aPathData); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if dstPath is not a valid path handle, or is not shared with the current + context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_MODIFY is not enabled for dstPath + VG_ILLEGAL_ARGUMENT_ERROR + – if pathData is NULL + – if pathData is not properly aligned + – if startIndex is less than 0 + – if numSegments is less than or equal to 0 + – if startIndex + numSegments is greater than the number of segments in the path + */ +void TGuestOpenVg::vgModifyPathCoords(VGPath aDstPath, VGint aStartIndex, VGint aNumSegments, const void* aPathData) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* dstPathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_MODIFY) ) + { + if ( (aStartIndex < 0) || (aNumSegments <= 0) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + dstPathInfo->ModifyPathCoords(*vgContext, aStartIndex, aNumSegments, aPathData); + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dstPath or srcPath is not a valid path handle, or is not shared with + the current context + VG_PATH_CAPABILITY_ERROR + – if VG_PATH_CAPABILITY_TRANSFORM_FROM is not enabled for srcPath + – if VG_PATH_CAPABILITY_TRANSFORM_TO is not enabled for dstPath + */ +void TGuestOpenVg::vgTransformPath(VGPath aDstPath, VGPath aSrcPath) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* dstPathInfo = NULL; + CVgPathInfo* srcPathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aDstPath, &dstPathInfo, VG_PATH_CAPABILITY_TRANSFORM_TO) && + vgLock.CheckVGPath(aSrcPath, &srcPathInfo, VG_PATH_CAPABILITY_TRANSFORM_FROM) ) + { + dstPathInfo->TransformPath(*vgContext, *srcPathInfo); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_PATH_CAPABILITY_ERROR + – If x and y are both non-NULL, and the VG_PATH_CAPABILITY_POINT_ALONG_PATH is + not enabled for path + – If tangentX and tangentY are both non-NULL, and the + VG_PATH_CAPABILITY_TANGENT_ALONG_PATH capability is not enabled for path + VG_ILLEGAL_ARGUMENT_ERROR + – if startSegment is less than 0 or greater than the index of the final path + segment + – if numSegments is less than or equal to 0 + – if (startSegment + numSegments – 1) is less than 0 or greater than the index + of the final path segment + – if x, y, tangentX or tangentY is not properly aligned + */ +void TGuestOpenVg::vgPointAlongPath(VGPath aPath, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, + VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + TBool getPoint = (aX && aY); + TBool getTangent = (aTangentX && aTangentY); + VGbitfield reqdCapabilities = 0; + if (getPoint) + { + reqdCapabilities |= VG_PATH_CAPABILITY_POINT_ALONG_PATH; + } + if (getTangent) + { + reqdCapabilities |= VG_PATH_CAPABILITY_TANGENT_ALONG_PATH; + } + if ( vgLock.CheckVGPath(aPath, &pathInfo, reqdCapabilities) ) + { + if ( (aStartSegment < 0) || (aNumSegments <= 0) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + pathInfo->PointAlongPath(*vgContext, aStartSegment, aNumSegments, aDistance, aX, aY, aTangentX, aTangentY); + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if path is not a valid path handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + */ +void TGuestOpenVg::vgDrawPath(VGPath aPath, VGbitfield aPaintModes) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPath(aPath, &pathInfo) ) + { + pathInfo->DrawPath(*vgContext, aPaintModes); + } + } + } + + +/* Paint */ + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +void TGuestOpenVg::vgDestroyPaint(VGPaint aPaint) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPaintInfo* paintInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) + { + paintInfo->Destroy(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is neither a valid paint handle nor equal to VG_INVALID_HANDLE, + or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration + */ +void TGuestOpenVg::vgSetPaint(VGPaint aPaint, VGbitfield aPaintModes) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPaintInfo* paintInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckOptionalVGPaint(aPaint, &paintInfo) && TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes)) + { + if (paintInfo) + { + paintInfo->SetPaint(*vgContext, aPaintModes); + } + else + { + CVgPaintInfo::ResetPaint(*vgContext); + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + */ +void TGuestOpenVg::vgSetColor(VGPaint aPaint, VGuint aRgba) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPaintInfo* paintInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPaint(aPaint, &paintInfo) ) + { + paintInfo->SetColor(*vgContext, aRgba); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if paint is not a valid paint handle, or is not shared with the current context + – if pattern is neither a valid image handle nor equal to VG_INVALID_HANDLE, or is + not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if pattern is currently a rendering target + */ +void TGuestOpenVg::vgPaintPattern(VGPaint aPaint, VGImage aPattern) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgPaintInfo* paintInfo = NULL; + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGPaint(aPaint, &paintInfo) && vgLock.CheckOptionalVGImage(aPattern, &imageInfo) ) + { + paintInfo->PaintPattern(*vgContext, imageInfo); + } + } + } + + +/* Images */ + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + */ +void TGuestOpenVg::vgDestroyImage(VGImage aImage) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) ) + { + imageInfo->Destroy(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgClearImage(VGImage aImage, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + imageInfo->ClearImage(*vgContext, aX, aY, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +void TGuestOpenVg::vgImageSubData(VGImage aImage, const void* aData, VGint aDataStride, VGImageFormat aDataFormat, + VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && + TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + imageInfo->ImageSubData(*vgContext, aData, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgCopyImage(VGImage aDst, VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, + VGint aWidth, VGint aHeight, VGboolean aDither) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + dstImageInfo->CopyImage(*vgContext, aDx, aDy, *srcImageInfo, aSx, aSy, aWidth, aHeight, aDither); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if image is not a valid image handle, or is not shared with the current + context + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +void TGuestOpenVg::vgDrawImage(VGImage aImage) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aImage, &imageInfo) ) + { + imageInfo->DrawImage(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if src is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgSetPixels(VGint aDx, VGint aDy, VGImage aSrc, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aSrc, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + imageInfo->SetPixels(*vgContext, aDx, aDy, aSx, aSy, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + – if dataFormat is not a valid value from the VGImageFormat enumeration + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + – if data is NULL + – if data is not properly aligned + */ +void TGuestOpenVg::HostVgWritePixels(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight) + { + VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer); + VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgWritePixels, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendVector(aPixmap, aPixmapSize); + vgApiData.AppendParam(aHostDataStride); + vgApiData.AppendParam(aDataFormat); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void TGuestOpenVg::vgWritePixels(const void* aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aDx, VGint aDy, + VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkImageAlignment(*vgContext, aDataFormat, aData) && + TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + TInt bitsPerPixel = CVgImageInfo::BitsPerPixelForVgImageFormat(aDataFormat); + size_t lineLength = ((static_cast(aWidth) * static_cast(bitsPerPixel)) + 7) / 8; + OPENVG_TRACE("vgWritePixels.1 bitsPerPixel=%d, lineLength=%d", bitsPerPixel, lineLength); + // ToDo clip aWidth & aHeight to the surface width & height + + if (bitsPerPixel <= 0) + { + vgContext->SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + } + else + { + if (lineLength == aDataStride) + { // use original parameters + OPENVG_TRACE("vgWritePixels.2a: lineLength == dataStride"); + HostVgWritePixels(*vgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aDx, aDy, aWidth, aHeight); + } + else if (0 == aDataStride) + { // Fill operation: pixmap size for the memcpy between Symbian & Host EGL is the lineLength + OPENVG_TRACE("vgWritePixels.2b: 0 == dataStride"); + HostVgWritePixels(*vgContext, aData, lineLength, aDataStride, aDataFormat, aDx, aDy, aWidth, aHeight); + } + else + { // datastride maybe negative or simply > lineLength + size_t pixmapSize = lineLength * aHeight; + TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); + OPENVG_TRACE("vgWritePixels.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); + if (localBuffer != NULL) + { // reformat data into temporary buffer + CVgImageInfo::PixmapBlit(localBuffer, static_cast(aData), lineLength, aDataStride, aHeight, lineLength); + HostVgWritePixels(*vgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aDx, aDy, aWidth, aHeight); + CVghwUtils::Free(localBuffer); + } + else + { // alloc failed, so do VG operation row by row + const TUint8* source = static_cast(aData); + for (VGint row = 0; row < aHeight; ++row) + { + HostVgWritePixels(*vgContext, source, lineLength, lineLength, aDataFormat, aDx + row, aDy, aWidth, 1); + source += aDataStride; + } + } + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if dst is not a valid image handle, or is not shared with the current context + VG_IMAGE_IN_USE_ERROR + – if dst is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgGetPixels(VGImage aDst, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGImage(aDst, &imageInfo) && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + imageInfo->GetPixels(*vgContext, aDx, aDy, aSx, aSy, aWidth, aHeight); + } + } + } + + +/* + ERRORS + VG_ILLEGAL_ARGUMENT_ERROR + – if width or height is less than or equal to 0 + */ +void TGuestOpenVg::vgCopyPixels(VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext && TCheck::ChkPositiveImageSize(*vgContext, aWidth, aHeight) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCopyPixels, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgContext->ExecuteVgCommand(vgApiData); + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + */ +void TGuestOpenVg::vgDestroyFont(VGFont aFont) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) ) + { + fontInfo->Destroy(*vgContext); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + – if path is not a valid path handle or VG_INVALID_HANDLE, or is not shared + with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if the pointer to glyphOrigin or escapement is NULL or is not properly + aligned + */ +void TGuestOpenVg::vgSetGlyphToPath(VGFont aFont, VGuint aGlyphIndex, VGPath aPath, VGboolean aIsHinted, + const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + CVgPathInfo* pathInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) && vgLock.CheckOptionalVGPath(aPath, &pathInfo) && + TCheck::Chk2x32bitPtr(*vgContext, aGlyphOrigin, aEscapement) ) + { + fontInfo->SetGlyphToPath(*vgContext, aGlyphIndex, pathInfo, aIsHinted, aGlyphOrigin, aEscapement); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + – if image is not a valid image handle or VG_INVALID_HANDLE, or is not + shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if the pointer to glyphOrigin or escapement is NULL or is not properly + aligned + VG_IMAGE_IN_USE_ERROR + – if image is currently a rendering target + */ +void TGuestOpenVg::vgSetGlyphToImage(VGFont aFont, VGuint aGlyphIndex, VGImage aImage, const VGfloat aGlyphOrigin [2], + const VGfloat aEscapement[2]) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + CVgImageInfo* imageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::Chk2x32bitPtr(*vgContext, aGlyphOrigin, aEscapement) && + vgLock.CheckOptionalVGImage(aImage, &imageInfo) ) + { + fontInfo->SetGlyphToImage(*vgContext, aGlyphIndex, imageInfo, aGlyphOrigin, aEscapement); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphIndex is not defined for the font + */ +void TGuestOpenVg::vgClearGlyph(VGFont aFont, VGuint aGlyphIndex) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) ) + { + fontInfo->ClearGlyph(*vgContext, aGlyphIndex); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphIndex has not been defined for a given font object + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration, or 0 + */ +void TGuestOpenVg::vgDrawGlyph(VGFont aFont, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes) ) + { + fontInfo->DrawGlyph(*vgContext, aGlyphIndex, aPaintModes, aAllowAutoHinting); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if font is not a valid font handle, or is not shared with the current context + VG_ILLEGAL_ARGUMENT_ERROR + – if glyphCount is zero or a negative value + – if the pointer to the glyphIndices array is NULL or is not properly + aligned + – if a pointer to either of the adjustments_x or adjustments_y arrays are + non-NULL and are not properly aligned + – if any of the glyphIndices has not been defined in a given font object + – if paintModes is not a valid bitwise OR of values from the VGPaintMode + enumeration, or 0 + */ +void TGuestOpenVg::vgDrawGlyphs(VGFont aFont, VGint aGlyphCount, const VGuint* aGlyphIndices, + const VGfloat* aAdjustmentsX, const VGfloat* aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgFontInfo* fontInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.CheckVGFont(aFont, &fontInfo) && TCheck::Chk32bitPtr(*vgContext, aGlyphIndices) && + TCheck::ChkVGPaintModesCombination(*vgContext, aPaintModes) && + TCheck::Chk2xOptional32bitPtr(*vgContext, aAdjustmentsX, aAdjustmentsY) ) + { + fontInfo->DrawGlyphs(*vgContext, aGlyphCount, aGlyphIndices, aAdjustmentsX, aAdjustmentsY, aPaintModes, aAllowAutoHinting); + } + } + } + + +/* Image Filters */ + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if matrix is NULL + – if matrix is not properly aligned + */ +void TGuestOpenVg::vgColorMatrix(VGImage aDst, VGImage aSrc, const VGfloat* aMatrix) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + // **** Desirable: check that neither aDst or aSrc are current rendering targets, or overlapping + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk32bitPtr(*vgContext, aMatrix) ) + { + dstImageInfo->ColorMatrix(*vgContext, *srcImageInfo, aMatrix); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if kernelWidth or kernelHeight is less than or equal to 0 or greater than + VG_MAX_KERNEL_SIZE + – if kernel is NULL + – if kernel is not properly aligned + – if tilingMode is not one of the values from the VGTilingMode enumeration + */ +void TGuestOpenVg::vgConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort* aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk16bitPtr(*vgContext, aKernel) && + TCheck::ChkVGTilingMode(*vgContext, aTilingMode) && + vgLock.CheckKernelWidthAndHeight(aKernelHeight, aKernelWidth, VG_MAX_KERNEL_SIZE) ) + { + dstImageInfo->Convolve(*vgContext, *srcImageInfo, aKernelWidth, aKernelHeight, + aShiftX, aShiftY, aKernel, aScale, aBias, aTilingMode); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if kernelWidth or kernelHeight is less than or equal to 0 or greater than + VG_MAX_SEPARABLE_KERNEL_SIZE + – if kernelX or kernelY is NULL + – if kernelX or kernelY is not properly aligned + – if tilingMode is not one of the values from the VGTilingMode + enumeration + */ +void TGuestOpenVg::vgSeparableConvolve(VGImage aDst, VGImage aSrc, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort* aKernelX, const VGshort* aKernelY, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && + TCheck::Chk2x16bitPtr(*vgContext, aKernelX, aKernelY) && TCheck::ChkVGTilingMode(*vgContext, aTilingMode) && + vgLock.CheckKernelWidthAndHeight(aKernelWidth, aKernelHeight, VG_MAX_SEPARABLE_KERNEL_SIZE) ) + { + dstImageInfo->SeparableConvolve(*vgContext, *srcImageInfo, aKernelWidth, aKernelHeight, + aShiftX, aShiftY, aKernelX, aKernelY, aScale, aBias, aTilingMode); + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if stdDeviationX or stdDeviationY is less than or equal to 0 or greater + than VG_MAX_GAUSSIAN_STD_DEVIATION + – if tilingMode is not one of the values from the VGTilingMode + enumeration + */ +void TGuestOpenVg::vgGaussianBlur(VGImage aDst, VGImage aSrc, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::ChkVGTilingMode(*vgContext, aTilingMode) ) + { + // **** Desirable: check against VG_MAX_GAUSSIAN_STD_DEVIATION limit from x86 VG implementation + if ( (aStdDeviationX <= KFloatZero) || (aStdDeviationY <= KFloatZero)) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + dstImageInfo->GaussianBlur(*vgContext, *srcImageInfo, aStdDeviationX, aStdDeviationY, aTilingMode); + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if any pointer parameter is NULL + */ +void TGuestOpenVg::vgLookup(VGImage aDst, VGImage aSrc, const VGubyte* aRedLUT, const VGubyte* aGreenLUT, + const VGubyte* aBlueLUT, const VGubyte* aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) ) + { + if ( (aRedLUT == NULL) || (aGreenLUT == NULL) || (aBlueLUT == NULL) || (aAlphaLUT == NULL) ) + { + vgContext->SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + dstImageInfo->Lookup(*vgContext, *srcImageInfo, aRedLUT, aGreenLUT, aBlueLUT, aAlphaLUT, aOutputLinear, aOutputPremultiplied); + } + } + } + } + + +/* + ERRORS + VG_BAD_HANDLE_ERROR + – if either dst or src is not a valid image handle, or is not shared with the + current context + VG_IMAGE_IN_USE_ERROR + – if either dst or src is currently a rendering target + VG_ILLEGAL_ARGUMENT_ERROR + – if src and dst overlap + – if src is in an RGB pixel format and sourceChannel is not one of VG_RED, + VG_GREEN, VG_BLUE or VG_ALPHA from the VGImageChannel enumeration + – if lookupTable is NULL + – if lookupTable is not properly aligned + */ +void TGuestOpenVg::vgLookupSingle(VGImage aDst, VGImage aSrc, const VGuint* aLookupTable, + VGImageChannel aSourceChannel, VGboolean aOutputLinear, VGboolean aOutputPremultiplied) + { + MVgContext* vgContext = CVghwUtils::VgContext(); + if ( vgContext ) + { + CVgImageInfo* dstImageInfo = NULL; + CVgImageInfo* srcImageInfo = NULL; + TCleanupVgLocks vgLock(*vgContext); // grab VG State Mutex & automatically release on destruction + + if ( vgLock.Check2VGImages(aDst, &dstImageInfo, aSrc, &srcImageInfo) && TCheck::Chk32bitPtr(*vgContext, aLookupTable) ) + { + dstImageInfo->LookupSingle(*vgContext, *srcImageInfo, aLookupTable, + aSourceChannel, aOutputLinear, aOutputPremultiplied); + } + } + } + + +/* + ERRORS + VG_UNSUPPORTED_IMAGE_FORMAT_ERROR + - if the OpenVG implementation is not able to create a VGImage + compatible with the provided VGeglImageKHR for an implementation- + dependent reason (this could be caused by, but not limited to, + reasons such as unsupported pixel formats, anti-aliasing quality, + etc.). + + VG_ILLEGAL_ARGUMENT_ERROR + - if is not a valid VGeglImageKHR. + */ +VGImage TGuestOpenVg::vgCreateEGLImageTargetKHR(VGeglImageKHR aImage) + { + VGImage imageHandle = VG_INVALID_HANDLE; + MVgContext* vgContext = CVghwUtils::VgContext(); + if (vgContext) + { + TCleanupVgLocks vgLock(*vgContext); + imageHandle = vgLock.CreateEGLImageTargetKHR(aImage); + } + else + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateEGLImageTargetKHR - no VG context"); + } + + return imageHandle; + } + + +// end of file vgapi.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgfont.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgfont.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,158 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Open VG handle based objects + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgFontInfo +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgFontInfo* CVgFontInfo::New() + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgFontInfo* self = new CVgFontInfo(); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +CVgFontInfo::~CVgFontInfo() + {} + + +CVgFontInfo::CVgFontInfo() : + CVgHandleBase(EVgHandleForFont) + {} + + +TBool CVgFontInfo::DestroyObject(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); + OPENVG_TRACE(" CVgFontInfo::DestroyObject HostHandle=0x%x", iHostHandle); + + if (iHostHandle) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDestroyFont, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + aVgContext.ExecuteVgCommand(vgApiData); + } + + return ETrue; + } + + +VGint CVgFontInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_FONT_NUM_GLYPHS: + return 1; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +void CVgFontInfo::SetGlyphToPath(MVgContext& aVgContext, VGuint aGlyphIndex, CVgPathInfo* aPathInfo, VGboolean aIsHinted, + const VGfloat aGlyphOrigin [2], const VGfloat aEscapement[2]) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetGlyphToPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aGlyphIndex); + vgApiData.AppendParam( (aPathInfo == NULL) ? VG_INVALID_HANDLE : aPathInfo->HostHandle()); + vgApiData.AppendParam(aIsHinted); + vgApiData.AppendVector(aGlyphOrigin, 2); + vgApiData.AppendVector(aEscapement, 2); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgFontInfo::SetGlyphToImage(MVgContext& aVgContext, VGuint aGlyphIndex, CVgImageInfo* aImageInfo, const VGfloat aGlyphOrigin [2], + const VGfloat aEscapement[2]) + { + // ToDo track use of VG Images (esp SgImages) as Font Glyphs + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetGlyphToImage, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aGlyphIndex); + vgApiData.AppendParam( (aImageInfo == NULL) ? VG_INVALID_HANDLE : aImageInfo->HostHandle()); + vgApiData.AppendVector(aGlyphOrigin, 2); + vgApiData.AppendVector(aEscapement, 2); + TUint64 sgId(0L); + if (aImageInfo && aImageInfo->IsEglSibling()) + { + sgId = aImageInfo->SgImageId(); + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgFontInfo::ClearGlyph(MVgContext& aVgContext, VGuint aGlyphIndex) + { + // **** Desirable: verify aGlyphIndex, ToDo decrement SgImage reference count + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgClearGlyph, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aGlyphIndex); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgFontInfo::DrawGlyph(MVgContext& aVgContext, VGuint aGlyphIndex, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) + { + // **** Desirable: verify aGlyphIndex + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDrawGlyph, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aGlyphIndex); + vgApiData.AppendParam(aPaintModes); + vgApiData.AppendParam(aAllowAutoHinting); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgFontInfo::DrawGlyphs(MVgContext& aVgContext, VGint aGlyphCount, const VGuint * aGlyphIndices, const VGfloat * aAdjustmentsX, + const VGfloat * aAdjustmentsY, VGbitfield aPaintModes, VGboolean aAllowAutoHinting) + { + // **** Desirable: verify glyph indices? + if (aGlyphCount <= 0) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDrawGlyphs, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aGlyphCount); + vgApiData.AppendVector(aGlyphIndices, aGlyphCount); + vgApiData.AppendVector(aAdjustmentsX, (aAdjustmentsX == NULL) ? 0 : aGlyphCount); + vgApiData.AppendVector(aAdjustmentsY, (aAdjustmentsY == NULL) ? 0 : aGlyphCount); + vgApiData.AppendParam(aPaintModes); + vgApiData.AppendParam(aAllowAutoHinting); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +// end of file vgfont.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vghandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vghandle.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,279 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Open VG handle based objects. + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +// defintions for all static member data for CVgHandleBase family of classes +THandleGen CVgHandleBase::iHandleGen; // for creating local UIDs for clients to use as VG Handles + + + +///////////////////////////////////////////////////////////////////////////////////////////// +// THandleGen +///////////////////////////////////////////////////////////////////////////////////////////// + +void THandleGen::Init(TUint aInit) + { + OPENVG_TRACE("THandleGen::Init aInit=0x%x", aInit); + VGPANIC_ASSERT_DEBUG(aInit != 0, EVgPanicUidGeneratorZeroSeed); + iValue = aInit; + } + + +TUint THandleGen::NextUid() + { + VGPANIC_ASSERT_DEBUG(iValue != 0, EVgPanicUidGeneratorZeroSeed); + TUint result = iValue; + ++iValue; + if (iValue == 0) + iValue = 1; + return result; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgHandleBase = base class for CVgImageInfo etc... +///////////////////////////////////////////////////////////////////////////////////////////// + +// Client Handle generates local UIDs for each VG Handle based object created +void CVgHandleBase::InitStatics() + { + // valued of first Client side VG Handle + TUint seed = 0x00010000; + iHandleGen.Init(seed); + } + + +void CVgHandleBase::Destroy(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(!IsDestroyed(), EVgPanicHandleAlreadyMarkedDestroyed); + iIsDestroyed = ETrue; + if (DestroyObject(aVgContext)) + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + OpenVgState.UnMapHandle(iClientHandle); + delete this; + CVghwUtils::SwitchFromVghwHeap(clientHeap); + } + } + + +VGint CVgHandleBase::HostVgGetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetParameterVectorSize); + vgApiData.AppendParam(HostHandle()); + vgApiData.AppendParam(aParamType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGint CVgHandleBase::HostVgGetParameteri(MVgContext& aVgContext, VGint aParamType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetParameteri); + vgApiData.AppendParam(HostHandle()); + vgApiData.AppendParam(aParamType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGfloat CVgHandleBase::HostVgGetParameterf(MVgContext& aVgContext, VGint aParamType) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetParameterf); + vgApiData.AppendParam(HostHandle()); + vgApiData.AppendParam(aParamType); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +void CVgHandleBase::HostVgGetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetParameterfv); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgHandleBase::HostVgGetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetParameteriv); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount, RemoteFunctionCallData::EOut); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgHandleBase::HostVgSetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetParameterf, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aValue); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgHandleBase::HostVgSetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetParameteri, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aValue); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgHandleBase::HostVgSetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetParameterfv, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgHandleBase::HostVgSetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetParameteriv, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aParamType); + vgApiData.AppendParam(aCount); + vgApiData.AppendVector(aValues, aCount); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +// Base version of GetParameter* use GetParameterVectorSize to validate aParamType then cal Host VG +VGfloat CVgHandleBase::GetParameterf(MVgContext& aVgContext, VGint aParamType) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + return HostVgGetParameterf(aVgContext, aParamType); + } + return KFloatMinusOne; + } + + +VGint CVgHandleBase::GetParameteri(MVgContext& aVgContext, VGint aParamType) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + return HostVgGetParameteri(aVgContext, aParamType); + } + return 0; + } + + +/* Base versions of GetParameter*v call: + * GetParameterVectorSize to validate aParamtType, + * if aCount is 1 they call GetParameterf/i for the object + * otherwise if aCount is valid they call HostVgGetParameter*v + * */ +void CVgHandleBase::GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + if (aCount == 1) + { + *aValues = GetParameterf(aVgContext, aParamType); + return; + } + else if ( (aCount > 0) && (aCount <= vSize) ) + { + return HostVgGetParameterfv(aVgContext, aParamType, aCount, aValues); + } + + // invalid aCount + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return; + } + + +void CVgHandleBase::GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + if (aCount == 1) + { + *aValues = GetParameteri(aVgContext, aParamType); + return; + } + else if ( (aCount > 0) && (aCount <= vSize) ) + { + return HostVgGetParameteriv(aVgContext, aParamType, aCount, aValues); + } + + // invalid aCount + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return; + } + + +// Base versions of SetParameter* assume any parameters are read-only, and give an error return +void CVgHandleBase::SetParameterf(MVgContext& aVgContext, VGint, VGfloat) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + + +void CVgHandleBase::SetParameteri(MVgContext& aVgContext, VGint, VGint) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + + +void CVgHandleBase::SetParameterfv(MVgContext& aVgContext, VGint, VGint, const VGfloat *) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + + +void CVgHandleBase::SetParameteriv(MVgContext& aVgContext, VGint, VGint, const VGint *) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + + +// end of file vghandle.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgimage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgimage.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,773 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Open VG handle based objects + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +const TInt KColorMatrixSize = 20; +const TInt KLUTLength = 256; + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgImageInfo +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgImageInfo::CVgImageInfo(VGImageFormat aFormat, VGint aWidth, VGint aHeight, CVgImageInfo* aParent, VGbitfield aAllowedQuality, + EGLImageKHR aEglImage, TUint64 aSgImageId) : + CVgImageBase(EVgHandleForImage, aWidth, aHeight), iFormat(aFormat), iParent(aParent), + iAllowedQuality(aAllowedQuality), iIsEglSibling( aSgImageId ? ETrue : EFalse), + iEglImage(aEglImage), iSgImageId(aSgImageId), + iChildCount(0) + { + if (aParent) + { + aParent->IncChildCount(); + } + } + + +// eglChildImage +CVgImageInfo* CVgImageInfo::New(VGint aWidth, VGint aHeight, CVgImageInfo* aParent) + { + VGPANIC_ASSERT_DEBUG(aParent, EVgPanicImageParentIsInvalid); + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgImageInfo* self = new CVgImageInfo(aParent->iFormat, aWidth, aHeight, aParent, aParent->AllowedQuality(), + aParent->EglImage(), aParent->SgImageId()); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +// vgCreateEGLImageTargetKHR +CVgImageInfo* CVgImageInfo::New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, EGLImageKHR aEglImage, TUint64& aSgImageId) + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgImageInfo* self = new CVgImageInfo(aFormat, aWidth, aHeight, VG_INVALID_HANDLE, 0, aEglImage, aSgImageId); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +// eglCreateImage +CVgImageInfo* CVgImageInfo::New(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality) + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgImageInfo* self = new CVgImageInfo(aFormat, aWidth, aHeight, VG_INVALID_HANDLE, aAllowedQuality, NULL, 0l); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +CVgImageInfo::~CVgImageInfo() + { + VGPANIC_ASSERT(iChildCount == 0, EVgPanicDeleteInUseVgImageInfo); + if (iParent) + { + iParent->DecChildCount(); + } + } + + +CVgImageInfo* CVgImageInfo::Parent() const + { + return iParent; + } + + +TInt CVgImageInfo::ChildCount() const + { + return iChildCount; + } + + +void CVgImageInfo::IncChildCount() + { + VGPANIC_ASSERT(!iIsDestroyed, EVgPanicParentImageAlreadyDestroyed); + User::LockedInc(iChildCount); + } + + +void CVgImageInfo::DecChildCount() + { + User::LockedDec(iChildCount); + if ((iChildCount == 0) && iIsDestroyed) + { + if (iParent == NULL) + { + if (IsEglSibling()) + { // close the root EglImage + OpenVgState.EglImageClose(iEglImage); + } + } + else + { + iParent->DecChildCount(); + } + // delete this image & remove it from HandleMap + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + OpenVgState.UnMapHandle(iClientHandle); + delete this; + CVghwUtils::SwitchFromVghwHeap(clientHeap); + } + } + + +VGbitfield CVgImageInfo::AllowedQuality() const + { + return iAllowedQuality; + } + + +TBool CVgImageInfo::IsEglSibling() const + { + return iIsEglSibling; + } + + +EGLImageKHR CVgImageInfo::EglImage() const + { + return iEglImage; + } + + +TUint64 CVgImageInfo::SgImageId() const + { + return iSgImageId; + } + + +TBool CVgImageInfo::DestroyObject(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); + OPENVG_TRACE(" CVgImageInfo::DestroyObject HostHandle=0x%x; ChildCount=%d, Parent=0x%x, IsEglSibling=%d, EglImage=0x%x", + iHostHandle, ChildCount(), Parent(), IsEglSibling(), EglImage()); + + if (iHostHandle) + { + // Destroy image, but not for eglImages/SgImages + if (!IsEglSibling()) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDestroyImage, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + aVgContext.ExecuteVgCommand(vgApiData); + } + iHostHandle = VG_INVALID_HANDLE; + } + + if (iChildCount == 0) + { + if (iParent == NULL) + { + if (IsEglSibling()) + { // close the root EglImage + OpenVgState.EglImageClose(iEglImage); + } + } + else + { + iParent->DecChildCount(); + } + return ETrue; + } + // don't delete this image until all children have been destroyed + return EFalse; + } + + +TInt CVgImageInfo::BitsPerPixelForVgImageFormat(VGImageFormat aFormat) + { + TInt result = -1; + if ((aFormat == VG_BW_1) || (aFormat == VG_A_1)) + { + result = 1; + } + else if (aFormat == VG_A_4) + { + result = 4; + } + else if ((aFormat == VG_sL_8) || (aFormat == VG_lL_8) || (aFormat == VG_A_8)) + { + result = 8; + } + else if ((aFormat >= 0) && (aFormat < 256)) + { // low bits of format number repeat in a pattern for 16/32 bit per pel + TInt format = aFormat & 0x3f; + if ((format >= VG_sRGB_565) && (format <= VG_sRGBA_4444)) + { + result = 16; + } + else if (format <= VG_lRGBA_8888_PRE) + { + result = 32; + } + } + return result; + } + + +void CVgImageInfo::PixmapBlit(TUint8* aDest, const TUint8* aSource, TInt aDestStride, TInt aSourceStride, TInt aRowCount, + size_t aRowLength, TInt aLastBits) + { + VGPANIC_ASSERT_DEBUG(aDest, EVgPanicNullPointer); + VGPANIC_ASSERT_DEBUG(aSource, EVgPanicNullPointer); + VGPANIC_ASSERT_DEBUG(aDestStride >= aRowLength, EVgPanicStrideSmallerThanRowLength); + VGPANIC_ASSERT_DEBUG(aSourceStride >= aRowLength, EVgPanicStrideSmallerThanRowLength); + VGPANIC_ASSERT_DEBUG(aRowCount > 0, EVgPanicBadRowCountParam); + VGPANIC_ASSERT_DEBUG(aRowLength > 0, EVgPanicBadRowLengthParam); + VGPANIC_ASSERT_DEBUG( (aLastBits >= 0) && (aLastBits <= 7), EVgPanicBadLastBitsParam); + + if (aLastBits) + { // bits per pixel < 8, only copy lowest from source to dest + TUint8 destMask = 0xFF << aLastBits; // high bits + TUint8 srcMask = 0xFF ^ destMask; // low bits + aRowLength -= 1; + for (VGint row = 0; row < aRowCount; ++row) + { + memcpy(aDest, aSource, aRowLength); + TUint8 byte = (aDest[aRowLength] & destMask) | (aSource[aRowLength] & srcMask); + aDest[aRowLength] = byte; + aSource += aSourceStride; + aDest += aDestStride; + } + } + else + { + for (VGint row = 0; row < aRowCount; ++row) + { + memcpy(aDest, aSource, aRowLength); + aSource += aSourceStride; + aDest += aDestStride; + } + } + } + + +VGint CVgImageInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_IMAGE_FORMAT: + case VG_IMAGE_WIDTH: + case VG_IMAGE_HEIGHT: + return 1; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGfloat CVgImageInfo::GetParameterf(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_IMAGE_FORMAT: + if (iFormat != VG_IMAGE_FORMAT_INVALID) + { + return (VGfloat)iFormat; + } + // for EglImage need to get format of underlying VgImage + return HostVgGetParameterf(aVgContext, aParamType); + + case VG_IMAGE_WIDTH: + return (VGfloat)iWidth; + + case VG_IMAGE_HEIGHT: + return (VGfloat)iHeight; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGint CVgImageInfo::GetParameteri(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_IMAGE_FORMAT: + if (iFormat != VG_IMAGE_FORMAT_INVALID) + { + return iFormat; + } + // for EglImage need to get format of underlying VgImage + iFormat = (VGImageFormat) HostVgGetParameteri(aVgContext, aParamType); + return iFormat; + + case VG_IMAGE_WIDTH: + return iWidth; + + case VG_IMAGE_HEIGHT: + return iHeight; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +void CVgImageInfo::ClearImage(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + // **** Desirable: check aImage is not rendering target + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgClearImage, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + TUint64 sgId(0L); + if (iIsEglSibling) + { + sgId = iSgImageId; + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::ImageSubData(MVgContext& aVgContext, const void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, + VGint aWidth, VGint aHeight) + { + // **** Desirable: check image is not a rendering target + + // Limit aWidth & aHeight to the dimensions of aImage + if (iWidth < aWidth) + { + aWidth = iWidth; + } + if (iHeight < aHeight) + { + aHeight = iHeight; + } + OPENVG_TRACE("CVgImageInfo::ImageSubData.1a dest Image: width=%d, height=%d; clipped width=%d, clipped height=%d", + iWidth, iHeight, aWidth, aHeight); + TInt bitsPerPixel = BitsPerPixelForVgImageFormat(aDataFormat); + TUint32 lineLength = ((static_cast(aWidth) * static_cast(bitsPerPixel)) + 7) / 8; + OPENVG_TRACE("CVgImageInfo::ImageSubData.1b bitsPerPixel=%d, lineLength=%d", bitsPerPixel, lineLength); + + if (bitsPerPixel <= 0) + { + aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + } + else + { + if (lineLength == aDataStride) + { // use original parameters + OPENVG_TRACE("CVgImageInfo::ImageSubData.2a: lineLength == dataStride"); + HostVgImageSubData(aVgContext, aData, aDataStride * aHeight, aDataStride, + aDataFormat, aX, aY, aWidth, aHeight); + } + else if (0 == aDataStride) + { // Fill operation, pixmap size = lineLength + OPENVG_TRACE("CVgImageInfo::ImageSubData.2b: 0 == dataStride"); + HostVgImageSubData(aVgContext, aData, lineLength, aDataStride, + aDataFormat, aX, aY, aWidth, aHeight); + } + else + { // try to alloc a translation buffer - datastride maybe negative or simply > lineLength + size_t pixmapSize = lineLength * aHeight; + TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); + OPENVG_TRACE("CVgImageInfo::ImageSubData.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); + if (localBuffer != NULL) + { // reformat data into temporary buffer + PixmapBlit(localBuffer, static_cast(aData), lineLength, aDataStride, aHeight, lineLength); + HostVgImageSubData(aVgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aX, aY, aWidth, aHeight); + CVghwUtils::Free(localBuffer); + } + else + { // alloc failed, so do VG operation row by row + const TUint8* source = static_cast(aData); + for (VGint row = 0; row < aHeight; ++row) + { + HostVgImageSubData(aVgContext, source, lineLength, lineLength, aDataFormat, aX + row, aY, aWidth, 1); + source += aDataStride; + } + } + } + } + } + + +void CVgImageInfo::HostVgImageSubData(MVgContext& aVgContext, const void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + VGPANIC_ASSERT(aPixmap != NULL, EVgPanicNullPixmapPointer); + VGPANIC_ASSERT(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); + + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgImageSubData, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendVector(aPixmap, aPixmapSize); + vgApiData.AppendParam(aHostDataStride); + vgApiData.AppendParam(aDataFormat); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + TUint64 sgId(0L); + if (iIsEglSibling) + { + sgId = iSgImageId; + } + OPENVG_TRACE("CVgImageInfo::HostVgImageSubData sgId 0x%lx", sgId); + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::GetImageSubData(MVgContext& aVgContext, void * aData, VGint aDataStride, VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + // **** Desirable: check VGImage is not currently a rendering target + + // Limit aWidth & aHeight to the dimensions of aImage + if (iWidth < aWidth) + { + aWidth = iWidth; + } + if (iHeight < aHeight) + { + aHeight = iHeight; + } + OPENVG_TRACE("CVgImageInfo::GetImageSubData.1a source Image: width=%d, height=%d; clipped width=%d, clipped height=%d", + iWidth, iHeight, aWidth, aHeight); + TInt bitsPerPixel = BitsPerPixelForVgImageFormat(aDataFormat); + TUint32 lineLength = static_cast(aWidth) * static_cast(bitsPerPixel); + TUint32 tailBits = lineLength & 7; + lineLength = (lineLength + 7) / 8; + OPENVG_TRACE("CVgImageInfo::GetImageSubData.1b bitsPerPixel=%d, lineLength=%d, tailBits=%d", bitsPerPixel, lineLength, tailBits); + + if (bitsPerPixel <= 0) + { + aVgContext.SetVgError(VG_UNSUPPORTED_IMAGE_FORMAT_ERROR); + } + else + { + if (lineLength == aDataStride) + { // use original params + OPENVG_TRACE("CVgImageInfo::GetImageSubData.2a: lineLength == dataStride"); + HostVgGetImageSubData(aVgContext, aData, aDataStride * aHeight, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); + } + else if (0 == aDataStride) + { // unlikely unless aHeight = 1, symmetric to fill function for vgGetImageSubData + OPENVG_TRACE("CVgImageInfo::GetImageSubData.2b: 0 == dataStride"); + HostVgGetImageSubData(aVgContext, aData, lineLength, aDataStride, aDataFormat, aX, aY, aWidth, aHeight); + } + else + { // datastride maybe negative or simply > lineLength + TInt pixmapSize = lineLength * aHeight; + TUint8* localBuffer = (TUint8*) CVghwUtils::Alloc(pixmapSize); + OPENVG_TRACE("CVgImageInfo::GetImageSubData.2c: dataStride not 0 or lineLength, localBuffer=0x%x", localBuffer); + + if (localBuffer != NULL) + { // read pixels into temporary buffer + HostVgGetImageSubData(aVgContext, localBuffer, pixmapSize, lineLength, aDataFormat, aX, aY, aWidth, aHeight); + // reformat into client memory + PixmapBlit(static_cast(aData), localBuffer, aDataStride, lineLength, aHeight, lineLength, tailBits); + CVghwUtils::Free(localBuffer); + } + else + { // alloc failed, so do VG operation row by row + TUint8* dest = static_cast(aData); + for (VGint row = 0; row < aHeight; ++row) + { + HostVgGetImageSubData(aVgContext, dest, lineLength, lineLength, aDataFormat, aX + row, aY, aWidth, 1); + dest += aDataStride; + } + } + } + } + } + + +void CVgImageInfo::HostVgGetImageSubData(MVgContext& aVgContext, void* aPixmap, size_t aPixmapSize, VGint aHostDataStride, + VGImageFormat aDataFormat, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + VGPANIC_ASSERT_DEBUG(aPixmap != NULL, EVgPanicNullPixmapPointer); + VGPANIC_ASSERT_DEBUG(aPixmapSize >= (aHostDataStride * aHeight), EVgPanicPixmapSizeError); + + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgGetImageSubData); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendVector(aPixmap, aPixmapSize, RemoteFunctionCallData::EOut); + vgApiData.AppendParam(aHostDataStride); + vgApiData.AppendParam(aDataFormat); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgApiData.AppendParam((VGint)aPixmapSize); // ToDo overload AppendParam for TUint32 + TUint64 sgId(0L); + if (iIsEglSibling) + { + sgId = iSgImageId; + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::CopyImage(MVgContext& aVgContext, VGint aDx, VGint aDy, CVgImageInfo& aSrcImageInfo, VGint aSx, VGint aSy, VGint aWidth, + VGint aHeight, VGboolean aDither) + { + // **** Desirable: verify src & dst are not a rendering target, ... + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCopyImage, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgApiData.AppendParam(aDither); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (iIsEglSibling) + { + dstSgId = iSgImageId; + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::DrawImage(MVgContext& aVgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDrawImage, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + TUint64 sgId(0L); + if (iIsEglSibling) + { + sgId = iSgImageId; + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::SetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + // **** Desirable: verify aSrc image is not a rendering target + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetPixels, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::GetPixels(MVgContext& aVgContext, VGint aDx, VGint aDy, VGint aSx, VGint aSy, VGint aWidth, VGint aHeight) + { + // **** Desirable: verify aDst is not currently a rendering target + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetPixels, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + TUint64 sgId(0L); + if (iIsEglSibling) + { + sgId = iSgImageId; + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::ColorMatrix(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGfloat * aMatrix) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgColorMatrix, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendVector(aMatrix, KColorMatrixSize); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (IsEglSibling()) + { + dstSgId = SgImageId(); + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::Convolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort * aKernel, VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) + { + // **** Desirable: verify aDst & aSrc are valid and do not overlap + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgConvolve, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendParam(aKernelWidth); + vgApiData.AppendParam(aKernelHeight); + vgApiData.AppendParam(aShiftX); + vgApiData.AppendParam(aShiftY); + vgApiData.AppendVector(aKernel, aKernelWidth*aKernelHeight); + vgApiData.AppendParam(aScale); + vgApiData.AppendParam(aBias); + vgApiData.AppendParam(aTilingMode); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::SeparableConvolve(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGint aKernelWidth, VGint aKernelHeight, + VGint aShiftX, VGint aShiftY, const VGshort * aKernelX, const VGshort * aKernelY, + VGfloat aScale, VGfloat aBias, VGTilingMode aTilingMode) + { + // **** Desirable: verify aDst & aSrc are valid and do not overlap + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSeparableConvolve, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendParam(aKernelWidth); + vgApiData.AppendParam(aKernelHeight); + vgApiData.AppendParam(aShiftX); + vgApiData.AppendParam(aShiftY); + vgApiData.AppendVector(aKernelX, aKernelWidth); + vgApiData.AppendVector(aKernelY, aKernelHeight); + vgApiData.AppendParam(aScale); + vgApiData.AppendParam(aBias); + vgApiData.AppendParam(aTilingMode); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (IsEglSibling()) + { + dstSgId = SgImageId(); + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::GaussianBlur(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, VGfloat aStdDeviationX, VGfloat aStdDeviationY, VGTilingMode aTilingMode) + { + // **** Desirable: verify aDst & src are not currently a rendering target or overlap + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGaussianBlur, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendParam(aStdDeviationX); + vgApiData.AppendParam(aStdDeviationY); + vgApiData.AppendParam(aTilingMode); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (IsEglSibling()) + { + dstSgId = SgImageId(); + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::Lookup(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGubyte * aRedLUT, const VGubyte * aGreenLUT, const VGubyte * aBlueLUT, + const VGubyte * aAlphaLUT, VGboolean aOutputLinear, VGboolean aOutputPremultiplied) + { + // **** Desirable: verify aDst & aSrc are not currently a rendering target or overlap + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgLookup, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendVector(aRedLUT, KLUTLength); + vgApiData.AppendVector(aGreenLUT, KLUTLength); + vgApiData.AppendVector(aBlueLUT, KLUTLength); + vgApiData.AppendVector(aAlphaLUT, KLUTLength); + vgApiData.AppendParam(aOutputLinear); + vgApiData.AppendParam(aOutputPremultiplied); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (IsEglSibling()) + { + dstSgId = SgImageId(); + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgImageInfo::LookupSingle(MVgContext& aVgContext, CVgImageInfo& aSrcImageInfo, const VGuint * aLookupTable, VGImageChannel aSourceChannel, + VGboolean aOutputLinear, VGboolean aOutputPremultiplied) + { + // **** Desirable: check aSrc is in an RGB pixel format, and that aSourceChannel is okay + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgLookupSingle, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcImageInfo.HostHandle()); + vgApiData.AppendVector(aLookupTable, KLUTLength); + vgApiData.AppendParam(aSourceChannel); + vgApiData.AppendParam(aOutputLinear); + vgApiData.AppendParam(aOutputPremultiplied); + TUint64 dstSgId(0L); + TUint64 srcSgId(0L); + if (IsEglSibling()) + { + dstSgId = SgImageId(); + } + if (aSrcImageInfo.IsEglSibling()) + { + srcSgId = aSrcImageInfo.SgImageId(); + } + vgApiData.AppendTUint64(dstSgId); + vgApiData.AppendTUint64(srcSgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +// end of file vgimage.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgmask.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgmask.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,104 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Open VG handle based objects + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgMaskLayerInfo +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgMaskLayerInfo* CVgMaskLayerInfo::New(VGint aWidth, VGint aHeight) + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgMaskLayerInfo* self = new CVgMaskLayerInfo(aWidth, aHeight); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +CVgMaskLayerInfo::~CVgMaskLayerInfo() + {} + + +CVgMaskLayerInfo::CVgMaskLayerInfo(VGint aWidth, VGint aHeight) : + CVgImageBase(EVgHandleForMaskLayer, aWidth, aHeight) + {} + + +TBool CVgMaskLayerInfo::DestroyObject(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); + OPENVG_TRACE(" CVgMaskLayerInfo::DestroyObject HostHandle=0x%x", iHostHandle); + + if (iHostHandle) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDestroyMaskLayer, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + aVgContext.ExecuteVgCommand(vgApiData); + } + + return ETrue; + } + + +VGint CVgMaskLayerInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); // VGMasks do not have any parameters + return 0; + } + + +void CVgMaskLayerInfo::FillMaskLayer(MVgContext& aVgContext, VGint aX, VGint aY, VGint aWidth, VGint aHeight, VGfloat aValue) + { + if ( (aValue < 0.0f) || (aValue > 1.0f) ) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgFillMaskLayer, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgApiData.AppendParam(aValue); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +void CVgMaskLayerInfo::CopyMask(MVgContext& aVgContext, VGint aSx, VGint aSy, VGint aDx, VGint aDy, VGint aWidth, VGint aHeight) + { + // **** Desirable: check maskLayer is compatible with the current surface mask + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCopyMask, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSx); + vgApiData.AppendParam(aSy); + vgApiData.AppendParam(aDx); + vgApiData.AppendParam(aDy); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +// end of file vgmask.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgpaint.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgpaint.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,429 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Open VG handle based objects + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgPaintInfo +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgPaintInfo* CVgPaintInfo::New() + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgPaintInfo* self = new CVgPaintInfo(); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +CVgPaintInfo::~CVgPaintInfo() + {} + + +CVgPaintInfo::CVgPaintInfo() : + CVgHandleBase(EVgHandleForPaint), + iPaintType(VG_PAINT_TYPE_COLOR), iColorRampSpreadMode(VG_COLOR_RAMP_SPREAD_PAD), + iColorRampPremultiplied(VG_TRUE), iPatternTilingMode(VG_TILE_FILL) + {} + + +TBool CVgPaintInfo::DestroyObject(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); + OPENVG_TRACE(" CVgPaintInfo::DestroyObject HostHandle=0x%x", iHostHandle); + + if (iHostHandle) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDestroyPaint, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + aVgContext.ExecuteVgCommand(vgApiData); + } + + return ETrue; + } + + +VGint CVgPaintInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + case VG_PAINT_PATTERN_TILING_MODE: + return 1; + + case VG_PAINT_COLOR: + case VG_PAINT_LINEAR_GRADIENT: + return 4; + + case VG_PAINT_COLOR_RAMP_STOPS: + return 10000; // note: finite limit due to Guest serialisation limits + + case VG_PAINT_RADIAL_GRADIENT: + return 5; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGfloat CVgPaintInfo::GetParameterf(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + return (VGfloat) iPaintType; + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + return (VGfloat) iColorRampSpreadMode; + case VG_PAINT_PATTERN_TILING_MODE: + return (VGfloat) iPatternTilingMode; + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + return (VGfloat) iColorRampPremultiplied; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + return HostVgGetParameterf(aVgContext, aParamType); + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGint CVgPaintInfo::GetParameteri(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + return iPaintType; + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + return iColorRampSpreadMode; + case VG_PAINT_PATTERN_TILING_MODE: + return iPatternTilingMode; + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + return iColorRampPremultiplied; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + return HostVgGetParameteri(aVgContext, aParamType); + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +void CVgPaintInfo::GetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGfloat * aValues) + { + if (aCount > 0) + { + // vSize = 0 means the ParamType is not valid for this object, and VG error is already set + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize == 0) + { // VG Error already set + return; + } + + if ( (aCount <= vSize) ) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + *aValues = (VGfloat) iPaintType; + return; + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + *aValues = (VGfloat) iColorRampSpreadMode; + return; + case VG_PAINT_PATTERN_TILING_MODE: + *aValues = (VGfloat) iPatternTilingMode; + return; + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + *aValues = (VGfloat) iColorRampPremultiplied; + return; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgGetParameterfv(aVgContext, aParamType, aCount, aValues); + return; + } + } + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return; + } + + +void CVgPaintInfo::GetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, VGint * aValues) + { + if (aCount > 0) + { + // vSize = 0 means the ParamType is not valid for this object, and VG error is already set + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize == 0) + { // VG Error already set + return; + } + + if ( (aCount <= vSize) ) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + *aValues = iPaintType; + return; + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + *aValues = iColorRampSpreadMode; + return; + case VG_PAINT_PATTERN_TILING_MODE: + *aValues = iPatternTilingMode; + return; + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + *aValues = iColorRampPremultiplied; + return; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgGetParameteriv(aVgContext, aParamType, aCount, aValues); + return; + } + } + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return; + } + + +void CVgPaintInfo::SetParameterf(MVgContext& aVgContext, VGint aParamType, VGfloat aValue) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + case VG_PAINT_PATTERN_TILING_MODE: + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + SetParameteri(aVgContext, aParamType, (VGint) aValue); + return; + // **** desireable: add full checks for valid Values + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgSetParameterf(aVgContext, aParamType, aValue); + return; + } + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); // invalid or Read-Only parameter + } + + +void CVgPaintInfo::SetParameteri(MVgContext& aVgContext, VGint aParamType, VGint aValue) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + if ( (aValue >= VG_PAINT_TYPE_COLOR) && (aValue <= VG_PAINT_TYPE_PATTERN) ) + { + iPaintType = (VGPaintType) aValue; + HostVgSetParameteri(aVgContext, aParamType, aValue); + return; + } + break; + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + if ( (aValue >= VG_COLOR_RAMP_SPREAD_PAD) && (aValue <= VG_COLOR_RAMP_SPREAD_REFLECT) ) + { + iColorRampSpreadMode = (VGColorRampSpreadMode) aValue; + HostVgSetParameteri(aVgContext, aParamType, aValue); + return; + } + break; + case VG_PAINT_PATTERN_TILING_MODE: + if ( (aValue >= VG_TILE_FILL) && (aValue <= VG_TILE_REFLECT) ) + { + iPatternTilingMode = (VGTilingMode) aValue; + HostVgSetParameteri(aVgContext, aParamType, aValue); + return; + } + break; + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + if ( (aValue == VG_FALSE) || (aValue == VG_TRUE) ) + { + iColorRampPremultiplied = (VGboolean) aValue; + HostVgSetParameteri(aVgContext, aParamType, aValue); + return; + } + break; + // **** desireable: add full checks for valid Values + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgSetParameteri(aVgContext, aParamType, aValue); + return; + } + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); // invalid or Read-Only parameter + } + + +void CVgPaintInfo::SetParameterfv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGfloat * aValues) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + if ( (aCount == 0) && (aValues == NULL) ) + { // pointless but legal according to Open VG 1.1 spec + return; + } + + if ( (aCount > 0) && (aCount <= vSize) ) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + case VG_PAINT_PATTERN_TILING_MODE: + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + SetParameteri(aVgContext, aParamType, (VGint) *aValues); + return; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgSetParameterfv(aVgContext, aParamType, aCount, aValues); + return; + } + } + // VGPaint parameter is Read-Only or should have a smaller vector + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + } + + +void CVgPaintInfo::SetParameteriv(MVgContext& aVgContext, VGint aParamType, VGint aCount, const VGint * aValues) + { + VGint vSize = GetParameterVectorSize(aVgContext, aParamType); + if (vSize > 0) + { + if ( (aCount == 0) && (aValues == NULL) ) + { // pointless but legal according to Open VG 1.1 spec + return; + } + + if ( (aCount > 0) && (aCount <= vSize) ) + { + switch (aParamType) + { + case VG_PAINT_TYPE: + case VG_PAINT_COLOR_RAMP_SPREAD_MODE: + case VG_PAINT_PATTERN_TILING_MODE: + case VG_PAINT_COLOR_RAMP_PREMULTIPLIED: + SetParameteri(aVgContext, aParamType, *aValues); + return; + case VG_PAINT_COLOR: + case VG_PAINT_COLOR_RAMP_STOPS: + case VG_PAINT_LINEAR_GRADIENT: + case VG_PAINT_RADIAL_GRADIENT: + HostVgSetParameteriv(aVgContext, aParamType, aCount, aValues); + return; + } + } + // VGPaint parameter is Read-Only or should have a smaller vector + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + } + + +void CVgPaintInfo::SetPaint(MVgContext& aVgContext, VGbitfield aPaintModes) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetPaint, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aPaintModes); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +//static +void CVgPaintInfo::ResetPaint(MVgContext& aVgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetPaint, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(VG_INVALID_HANDLE); + const VGuint KZero = 0; + vgApiData.AppendParam(KZero); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgPaintInfo::SetColor(MVgContext& aVgContext, VGuint aRgba) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgSetColor, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aRgba); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +VGuint CVgPaintInfo::GetColor(MVgContext& aVgContext) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetColor); + vgApiData.AppendParam(iHostHandle); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return vgApiData.ReturnValue(); + } + + +void CVgPaintInfo::PaintPattern(MVgContext& aVgContext, CVgImageInfo* aPatternInfo) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgPaintPattern, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + TUint64 sgId(0L); + if (aPatternInfo == NULL) + { + vgApiData.AppendParam(VG_INVALID_HANDLE); + } + else + { + vgApiData.AppendParam(aPatternInfo->HostHandle()); + if (aPatternInfo->IsEglSibling()) + { + sgId = aPatternInfo->SgImageId(); + } + } + vgApiData.AppendTUint64(sgId); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +// end of file vgpaint.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgpath.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgpath.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,467 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for OpenVG handle based objects + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + +///////////////////////////////////////////////////////////////////////////////////////////// +// CVgPathInfo +///////////////////////////////////////////////////////////////////////////////////////////// + +CVgPathInfo* CVgPathInfo::New(VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities) + { + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + CVgPathInfo* self = new CVgPathInfo(aDatatype, aScale, aBias, aCapabilities); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + return self; + } + + +void CVgPathInfo::ClearPath(MVgContext& aVgContext, VGbitfield aCapabilities) + { + iCapabilities = aCapabilities & VG_PATH_CAPABILITY_ALL; + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgClearPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(HostHandle()); + vgApiData.AppendParam(aCapabilities); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgPathInfo::RemovePathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities) + { + if (aCapabilities & VG_PATH_CAPABILITY_ALL) + { + iCapabilities = (iCapabilities & ~aCapabilities); + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgRemovePathCapabilities, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(HostHandle()); + vgApiData.AppendParam(aCapabilities & VG_PATH_CAPABILITY_ALL); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +VGbitfield CVgPathInfo::GetPathCapabilities(MVgContext& aVgContext) + { + // value is tracked in Client side - but Debug builds verify state with the Host Open VG +#ifdef _DEBUG + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgGetPathCapabilities); + vgApiData.AppendParam(HostHandle()); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + VGbitfield hostCapabilities = static_cast(vgApiData.ReturnValue()); + VGPANIC_ASSERT_DEBUG(hostCapabilities == iCapabilities, EVgPanicTemp); +#endif + return iCapabilities; + } + + +CVgPathInfo::~CVgPathInfo() + {} + +CVgPathInfo::CVgPathInfo(VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, VGbitfield aCapabilities) : + CVgHandleBase(EVgHandleForPath), iDatatype(aDatatype), iScale(aScale), iBias(aBias), iCapabilities(aCapabilities) + {} + + +VGPathDatatype CVgPathInfo::PathDatatype() const + { + return iDatatype; + } + + +TBool CVgPathInfo::CheckHasPathCapabilities(MVgContext& aVgContext, VGbitfield aCapabilities) + { + if ( aCapabilities == (aCapabilities & iCapabilities) ) + { + return ETrue; + } + + OPENVG_TRACE("CVgPathInfo::CheckHasPathCapabilities (iCapabilities=0x%x, aCapabilities=0x%x) setting VG_PATH_CAPABILITY_ERROR", + iCapabilities, aCapabilities); + aVgContext.SetVgError(VG_PATH_CAPABILITY_ERROR); + return EFalse; + } + + +TBool CVgPathInfo::CheckPathDataAlignment(MVgContext& aVgContext, const void* aPathData) + { + TBool result = EFalse; + if (aPathData != NULL) + { + switch (iDatatype) + { + case VG_PATH_DATATYPE_S_8: + result = ETrue; + break; + case VG_PATH_DATATYPE_S_16: + result = !( 1ul & (unsigned)aPathData ); + break; + case VG_PATH_DATATYPE_S_32: + case VG_PATH_DATATYPE_F: + result = !( 3ul & (unsigned)aPathData ); + break; + } + } + if (!result) + { + OPENVG_TRACE("CVgPathInfo::CheckPathDataAlignment (iDatatype=%d, aPathData=0x%x) setting VG_ILLEGAL_ARGUMENT_ERROR", + iDatatype, aPathData); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + return result; + } + + +// +TBool CVgPathInfo::CheckPathDataSize(MVgContext& aVgContext, const VGubyte* aPathSegments, VGint aNumSegments, VGint* aPathDataSize) + { + TBool checkOkay = EFalse; + VGint pathDataSize = 0; + + if ( (aNumSegments > 0) && (aPathSegments != NULL) ) + { + checkOkay = ETrue; + +#define SEGMENT_COMMAND(command) ((command) >> 1) + // Number of coordinates for each command + static const VGint KNumCoords[] = {0,2,2,1,1,4,6,2,4,5,5,5,5}; + + for (VGint segIdx = 0; segIdx < aNumSegments; ) + { + VGubyte segmentType = aPathSegments[segIdx++]; + if (segmentType > 25) // VGPathSegment max value 12 << 1 or'd with 0|1 + { + OPENVG_TRACE(" CheckPathDataSize - unknown segmentType-0x%x", segmentType); + checkOkay = EFalse; + break; + } + VGint command = SEGMENT_COMMAND(segmentType); + pathDataSize += KNumCoords[command]; + OPENVG_TRACE(" CheckPathDataSize segmentType=0x%x: command=0x%x, Total Coord Count=%d", segmentType, command, pathDataSize); + } + } + + if ( !checkOkay ) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + OPENVG_TRACE(" CheckPathDataSize - Illegal Argument Error, aPathSegments=0x%x, aNumSegments=%d", aPathSegments, aNumSegments); + } + else + { + // Number of bytes for each VGPathDatatype + static const VGint KNumBytes[] = {1,2,4,4}; + // convert coord count to bytes + pathDataSize *= KNumBytes[iDatatype]; + + *aPathDataSize = pathDataSize; + OPENVG_TRACE(" CheckPathDataSize - success, pathDataSize=%d bytes", pathDataSize); + } + return checkOkay; + } + + +// Check path parameters for vgAppendPathData +TBool CVgPathInfo::CheckAppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte* aPathSegments, const void* aPathData, + VGint* aPathDataSize) + { + return CheckPathDataAlignment(aVgContext, aPathData) && CheckPathDataSize(aVgContext, aPathSegments, aNumSegments, aPathDataSize); + } + + +TBool CVgPathInfo::DestroyObject(MVgContext& aVgContext) + { + VGPANIC_ASSERT_DEBUG(iIsDestroyed, EVgPanicTemp); + OPENVG_TRACE(" CVgPathInfo::DestroyObject HostHandle=0x%x", iHostHandle); + + if (iHostHandle) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDestroyPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + aVgContext.ExecuteVgCommand(vgApiData); + } + + return ETrue; + } + + +VGint CVgPathInfo::GetParameterVectorSize(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PATH_FORMAT: + case VG_PATH_DATATYPE: + case VG_PATH_SCALE: + case VG_PATH_BIAS: + case VG_PATH_NUM_SEGMENTS: + case VG_PATH_NUM_COORDS: + return 1; + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGfloat CVgPathInfo::GetParameterf(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PATH_DATATYPE: + return (VGfloat) iDatatype; + + case VG_PATH_SCALE: + return iScale; + + case VG_PATH_BIAS: + return iBias; + + case VG_PATH_FORMAT: + case VG_PATH_NUM_SEGMENTS: + case VG_PATH_NUM_COORDS: + return HostVgGetParameterf(aVgContext, aParamType); + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +VGint CVgPathInfo::GetParameteri(MVgContext& aVgContext, VGint aParamType) + { + switch (aParamType) + { + case VG_PATH_DATATYPE: + return iDatatype; + + case VG_PATH_SCALE: + return (VGint) iScale; + + case VG_PATH_BIAS: + return (VGint) iBias; + + case VG_PATH_FORMAT: + case VG_PATH_NUM_SEGMENTS: + case VG_PATH_NUM_COORDS: + return HostVgGetParameteri(aVgContext, aParamType); + } + + // invalid ParamType + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return 0; + } + + +void CVgPathInfo::AppendPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgAppendPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcPathInfo.HostHandle()); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +void CVgPathInfo::AppendPathData(MVgContext& aVgContext, VGint aNumSegments, const VGubyte * aPathSegments, const void* aPathData) + { + VGint pathDataSize = 0; + if ( CheckAppendPathData(aVgContext, aNumSegments, aPathSegments, aPathData, &pathDataSize) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgAppendPathData, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aNumSegments); + vgApiData.AppendVector(aPathSegments, aNumSegments); + vgApiData.AppendVector(aPathData, pathDataSize); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +//Private extension to Open VG API to get the path length +VGint CVgPathInfo::HostVgeGetPathCoordsSizeInBytes(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments) + { + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgePathCoordsSizeInBytes); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aStartIndex); + vgApiData.AppendParam(aNumSegments); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +void CVgPathInfo::ModifyPathCoords(MVgContext& aVgContext, VGint aStartIndex, VGint aNumSegments, const void* aPathData) + { + if (CheckPathDataAlignment(aVgContext, aPathData)) + { + // The host OpenVG implementation returns -1 if vgePathCoordsSizeInBytes is not supported + // It does not seem simple to reliably implement vgePathCoordsSizeInBytes in the Symbian client + VGint dataSize = HostVgeGetPathCoordsSizeInBytes(aVgContext, aStartIndex, aNumSegments); + OPENVG_TRACE("TGuestOpenVg::vgModifyPathCoords - dataSize=%d", dataSize); + if (dataSize <= 0) + { + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgModifyPathCoords, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aStartIndex); + vgApiData.AppendParam(aNumSegments); + vgApiData.AppendVector(aPathData, dataSize); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + } + + +void CVgPathInfo::TransformPath(MVgContext& aVgContext, CVgPathInfo& aSrcPathInfo) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgTransformPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aSrcPathInfo.HostHandle()); + aVgContext.ExecuteVgCommand(vgApiData); + } + + +VGboolean CVgPathInfo::InterpolatePath(MVgContext& aVgContext, CVgPathInfo& aStartPathInfo, CVgPathInfo& aEndPathInfo, VGfloat aAmount) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgInterpolatePath); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aStartPathInfo.HostHandle()); + vgApiData.AppendParam(aEndPathInfo.HostHandle()); + vgApiData.AppendParam(aAmount); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +VGfloat CVgPathInfo::PathLength(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgPathLength); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aStartSegment); + vgApiData.AppendParam(aNumSegments); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + aVgContext.ExecuteVgCommand(vgApiData); + return static_cast(vgApiData.ReturnValue()); + } + + +void CVgPathInfo::PointAlongPath(MVgContext& aVgContext, VGint aStartSegment, VGint aNumSegments, VGfloat aDistance, + VGfloat* aX, VGfloat* aY, VGfloat* aTangentX, VGfloat* aTangentY) + { + TBool getPoint = (aX && aY); + TBool getTangent = (aTangentX && aTangentY); + + if ( getPoint && !TCheck::Chk2x32bitPtr(aVgContext, aX, aY) ) + { + return; + } + if ( getTangent && !TCheck::Chk2x32bitPtr(aVgContext, aTangentX, aTangentY) ) + { + return; + } + if (getPoint || getTangent) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgPointAlongPath); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aStartSegment); + vgApiData.AppendParam(aNumSegments); + vgApiData.AppendParam(aDistance); + vgApiData.AppendVector(aX, getPoint ? 1 : 0, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aY, getPoint ? 1 : 0, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aTangentX, getTangent ? 1 : 0, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aTangentY, getTangent ? 1 : 0, RemoteFunctionCallData::EOut); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +void CVgPathInfo::PathBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) + { + if (TCheck::Chk4x32bitPtr(aVgContext, aMinX, aMinY, aWidth, aHeight) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgPathBounds); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendVector(aMinX, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aMinY, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aWidth, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aHeight, 1, RemoteFunctionCallData::EOut); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +void CVgPathInfo::PathTransformedBounds(MVgContext& aVgContext, VGfloat* aMinX, VGfloat* aMinY, VGfloat* aWidth, VGfloat* aHeight) + { + if (TCheck::Chk4x32bitPtr(aVgContext, aMinX, aMinY, aWidth, aHeight) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgPathTransformedBounds); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendVector(aMinX, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aMinY, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aWidth, 1, RemoteFunctionCallData::EOut); + vgApiData.AppendVector(aHeight, 1, RemoteFunctionCallData::EOut); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +void CVgPathInfo::DrawPath(MVgContext& aVgContext, VGbitfield aPaintModes) + { + if ( TCheck::ChkVGPaintModesCombination(aVgContext, aPaintModes) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgDrawPath, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aPaintModes); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +void CVgPathInfo::RenderToMask(MVgContext& aVgContext, VGbitfield aPaintModes, VGMaskOperation aOperation) + { + if ( TCheck::ChkVGPaintModesCombination(aVgContext, aPaintModes) && TCheck::ChkVGMaskOperation(aVgContext, aOperation) ) + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgRenderToMask, RemoteFunctionCallData::EOpRequest); + vgApiData.AppendParam(iHostHandle); + vgApiData.AppendParam(aPaintModes); + vgApiData.AppendParam(aOperation); + aVgContext.ExecuteVgCommand(vgApiData); + } + } + + +// end of file vgpath.cpp diff -r 220791dae4c4 -r acbd4400e82b guestrendering/guestopenvg/src/vgstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guestrendering/guestopenvg/src/vgstate.cpp Wed Sep 08 17:02:34 2010 +0100 @@ -0,0 +1,788 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Client-side state information for Symbian DLL + +#include "vgstate.h" +#include "remotefunctioncall.h" +#include "openvgrfc.h" + + + +// VG Client-side state is Writeable Static Data in the DLL, (holds state information for the process) +// Constructor/Destructor called on process load/unload to perform initialiser/release of static resources +XOpenVgState OpenVgState; + + + +_LIT(KVgPanicCategory, "Guest VG"); + +void VgPanic(TVgPanic aPanicCode, char* aPanicName, char* aCondition, char* aFile, TInt aLine) + { + if (aPanicName && aCondition && aFile) + { // normal for Debug builds + RDebug::Printf("Guest Open VG DLL Panic %s for failed Assert (%s),\n\tat %s:%d", aPanicName, aCondition, aFile, aLine); + } + else if (aPanicName && aFile) + { // Debug builds Assert Always + RDebug::Printf("Guest Open VG DLL Panic %s at %s:%d", aPanicName, aFile, aLine); + } + else + { // normal for Release builds + RDebug::Printf("Guest Open VG DLL Panic %d (line %d)", aPanicCode, aLine); + } + + User::Panic(KVgPanicCategory, aPanicCode); + } + + + +///////////////////////////////////////////////////////////////////////////////////////////// +// TCheck - parameter checking utility functions +///////////////////////////////////////////////////////////////////////////////////////////// + + +/* + aWidth & aHeight parameters must be >0, also ax, ay, aX + aWidth and aY + aHeight must all + be within image size, otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged. + */ +TBool TCheck::ChkAreaIsWithinImage(MVgContext& aVgContext, CVgImageBase* aImageInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + VGPANIC_ASSERT_DEBUG(aImageInfo, EVgPanicTemp); + if ( (aX >= 0) && (aY >= 0) && (aWidth > 0) && (aHeight > 0) ) + { + VGint maxX = aWidth + aX; + VGint maxY = aHeight + aY; + if ( (maxX > 0) && (maxY > 0) && (aImageInfo->Width() >= maxX) && (aImageInfo->Height() >= maxY) ) + { + return ETrue; + } + } + OPENVG_TRACE("TCheck::ChkAreaIsWithinImage setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + + +VGint TCheck::ImageFormatByteDepth(VGImageFormat aImageFormat) + { + switch (aImageFormat) + { + case VG_sRGBX_8888: + case VG_sRGBA_8888: + case VG_sRGBA_8888_PRE: + case VG_lRGBX_8888: + case VG_lRGBA_8888: + case VG_lRGBA_8888_PRE: + case VG_sXRGB_8888: + case VG_sARGB_8888: + case VG_sARGB_8888_PRE: + case VG_lXRGB_8888: + case VG_lARGB_8888: + case VG_lARGB_8888_PRE: + case VG_sBGRX_8888: + case VG_sBGRA_8888: + case VG_sBGRA_8888_PRE: + case VG_lBGRX_8888: + case VG_lBGRA_8888: + case VG_lBGRA_8888_PRE: + case VG_sXBGR_8888: + case VG_sABGR_8888: + case VG_sABGR_8888_PRE: + case VG_lXBGR_8888: + case VG_lABGR_8888: + case VG_lABGR_8888_PRE: + return 4; + case VG_sRGB_565: + case VG_sRGBA_5551: + case VG_sRGBA_4444: + case VG_sARGB_1555: + case VG_sARGB_4444: + case VG_sBGR_565: + case VG_sBGRA_5551: + case VG_sBGRA_4444: + case VG_sABGR_1555: + case VG_sABGR_4444: + return 2; + case VG_sL_8: + case VG_lL_8: + case VG_A_8: + case VG_A_4: + case VG_A_1: + case VG_BW_1: + return 1; + case VG_IMAGE_FORMAT_INVALID: + default: + return 0; + } + } + + +// Checks aCount & aValues for SetParameteriv & SetParameterfv +TBool TCheck::ChkParamCountAndValuesPtr(MVgContext& aVgContext, VGint aCount, const void* aValues) + { + VGErrorCode error = VG_NO_ERROR; + if (aValues == NULL) + { + if (aCount != 0) + { + error = VG_ILLEGAL_ARGUMENT_ERROR; + } + } + // we should check count for not being too large for serialization, but + // there is no limit in spec for VG_SCISSOR_RECTS and VG_STROKE_DASH_PATTERN + else if ( (3ul & (unsigned)aValues) || (aCount < 0) || (aCount > 100000) ) + { + error = VG_ILLEGAL_ARGUMENT_ERROR; + } + + if (error != VG_NO_ERROR) + { + OPENVG_TRACE("TCheck::ChkParamCountAndValuesPtr setting error=0x%x", error); + aVgContext.SetVgError(error); + return EFalse; + } + return ETrue; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// XOpenVgState +///////////////////////////////////////////////////////////////////////////////////////////// + +// Singleton object is in WSD memory, so this Constructor is called when the DLL is loaded +XOpenVgState::XOpenVgState() : + iEglManagementApi(NULL), iKVgMaxKernelSize(0), iKVgMaxSeparableKernelSize(0) + { + OPENVG_TRACE("XOpenVgState::XOpenVgState 1. start Process=0x%lx, Thread=0x%lx", RProcess().Id().Id(), RThread().Id().Id()); + + TInt createErr1 = iStateLock.CreateLocal(EOwnerProcess); + OPENVG_TRACE("XOpenVgState::XOpenVgState 2. iStateLock.CreateLocal error=%d, Handle=0x%x", createErr1, iStateLock.Handle()); + + TInt createErr2 = iMapLock.CreateLocal(EOwnerProcess); + OPENVG_TRACE("XOpenVgState::XOpenVgState 2. iMapLock.CreateLocal error=%d, Handle=0x%x", createErr2, iMapLock.Handle()); + // cannot continue if there is an error, so Panic + VGPANIC_ASSERT( (createErr1 == KErrNone) && (createErr2 == KErrNone), EVgPanicTemp); + + CVgHandleBase::InitStatics(); + + // publish MVgApiforEgl vtable + CVghwUtils::SetVgApiForEgl(this); + } + + +// Desstructor is called when the DLL is unloaded +XOpenVgState::~XOpenVgState() + { + OPENVG_TRACE("XOpenVgState::~XOpenVgState 1. iStateLock handle=0x%x, iMapLock handle=0x%x, Process=0x%lx, Thread=0x%lx", + iStateLock.Handle(), iMapLock.Handle(), RProcess().Id().Id(), RThread().Id().Id()); + + if (iStateLock.Handle()) + { + iStateLock.Close(); + OPENVG_TRACE("XOpenVgState::~XOpenVgState 2. iStateLock Handle=0x%x", iStateLock.Handle()); + } + if (iMapLock.Handle()) + { + iMapLock.Close(); + OPENVG_TRACE("XOpenVgState::~XOpenVgState 3. iMapLock Handle=0x%x", iMapLock.Handle()); + } + + // unpublish MVgApiforEgl vtable + CVghwUtils::SetVgApiForEgl(NULL); + } + + +TBool XOpenVgState::CheckVGHandle(MVgContext& aVgContext, VGHandle aHandle, CVgHandleBase** aHandleInfo, TVgHandleType aMatchType) + { // client side VGHandle is an opaque data handle to Host Open VG objects such as VGPath or VGImage + // only check for logic errors in VG code in Debug builds + VGPANIC_ASSERT_DEBUG(iStateLock.IsHeld(), EVgPanicStateLockMutexNotHeld); + VGPANIC_ASSERT_DEBUG(aHandleInfo, EVgPanicFunctionParameterIsNull); + + if (aHandle != VG_INVALID_HANDLE) + { + iMapLock.Wait(); + CVgHandleBase** pHandleInfo = iHandleHashMap.Find(aHandle); + if (pHandleInfo) + { + CVgHandleBase* handleInfo = *pHandleInfo; + if (handleInfo && !handleInfo->IsDestroyed() && + ( (aMatchType == EVgHandleAny) || (aMatchType == handleInfo->HandleType()) ) ) + { + // ToDo confirm handle belongs to this context or is shared with this context + *aHandleInfo = handleInfo; + OPENVG_TRACE(" XOpenVgState::CheckVGHandle client handle=0x%x, match type=%d; found matching Host VG Handle=0x%x", + aHandle, aMatchType, handleInfo->HostHandle()); + iMapLock.Signal(); + return ETrue; + } + } + iMapLock.Signal(); + } + OPENVG_TRACE(" XOpenVgState::CheckVGHandle client handle=0x%x, match type=%d, setting VG_BAD_HANDLE_ERROR", aHandle, aMatchType); + aVgContext.SetVgError(VG_BAD_HANDLE_ERROR); + return EFalse; + } + + +/* + aKernelWidth or aKernelHeight must be >0 and <= [Size Limit], otherwise a VG_ILLEGAL_ARGUMENT_ERROR is flagged + */ +TBool XOpenVgState::CheckKernelWidthAndHeight(MVgContext& aVgContext, VGint aKernelWidth, VGint aKernelHeight, VGParamType aLimitType) + { + VGPANIC_ASSERT_DEBUG(iStateLock.IsHeld(), EVgPanicStateLockMutexNotHeld); + VGint limit = 0; + // aLimitType must be either VG_MAX_KERNEL_SIZE or VG_MAX_SEPARABLE_KERNEL_SIZE + if (aLimitType == VG_MAX_KERNEL_SIZE) + { + if (iKVgMaxKernelSize == 0) + { // first access, so fetch value from Host + iKVgMaxKernelSize = TGuestOpenVg::HostGeti(aVgContext, VG_MAX_KERNEL_SIZE); + } + limit = iKVgMaxKernelSize; + } + else if (aLimitType == VG_MAX_SEPARABLE_KERNEL_SIZE) + { + if (iKVgMaxSeparableKernelSize == 0) + { // first access, so fetch value from Host + iKVgMaxSeparableKernelSize = TGuestOpenVg::HostGeti(aVgContext, VG_MAX_SEPARABLE_KERNEL_SIZE); + } + limit = iKVgMaxSeparableKernelSize; + } + VGPANIC_ASSERT(limit > 0, EVgPanicValueFromHostVgIsInvalid); + + if ( (aKernelHeight > 0) && (aKernelHeight <= limit) && (aKernelWidth > 0) && (aKernelWidth <= limit) ) + { + return ETrue; + } + OPENVG_TRACE("XOpenVgState::CheckKernelWidthAndHeight setting VG_ILLEGAL_ARGUMENT_ERROR"); + aVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + + +TBool XOpenVgState::AddToHashMap(MVgContext& aVgContext, CVgHandleBase* aHandleInfo, VGHandle aHostHandle) + { + VGPANIC_ASSERT_DEBUG(iStateLock.IsHeld(), EVgPanicStateLockMutexNotHeld); + + OPENVG_TRACE(" XOpenVgState::AddToHashMap aHandleInfo=0x%x, aHostHandle=0x%x, ClientHandle=0x%x", + aHandleInfo, aHostHandle, aHandleInfo->ClientHandle()); + aHandleInfo->SetHostHandle(aHostHandle); + + iMapLock.Wait(); + RHeap* clientHeap = CVghwUtils::SwitchToVghwHeap(); + // ClientHandle is key to finding object, its Host Handle, object type, etc... + TInt err = iHandleHashMap.Insert(aHandleInfo->ClientHandle(), aHandleInfo); + CVghwUtils::SwitchFromVghwHeap(clientHeap); + iMapLock.Signal(); + + if (err == KErrNone) + { + return ETrue; + } + + // Failed, Cleanup ... + OPENVG_TRACE(" XOpenVgState::AddToHashMap insert error = %d", err); + aVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + return EFalse; + } + + +void XOpenVgState::UnMapHandle(TUint32 aClientHandle) + { + OPENVG_TRACE(" XOpenVgState::UnMapHandle aHandleInfo=0x%x -->", aClientHandle); + VGPANIC_ASSERT_DEBUG(iStateLock.IsHeld(), EVgPanicStateLockMutexNotHeld); + VGPANIC_ASSERT_DEBUG( CVghwUtils::UsingVghwHeap(), EVgPanicTemp); + + iMapLock.Wait(); +#ifdef _DEBUG + TInt dbgErr = +#endif + iHandleHashMap.Remove(aClientHandle); + iMapLock.Signal(); + + OPENVG_TRACE(" XOpenVgState::UnMapHandle ... dbgErr =%d <--", dbgErr); + } + + +TBool XOpenVgState::EglImageOpenForVgImage(EGLImageKHR aImage, TSize& aSize, VGHandle& aVgHandle, TUint64& aSgImageId) + { + if (!iEglManagementApi) + { // try to get EGL interface via VghwUtils + iEglManagementApi = CVghwUtils::EglManagementApi(); + VGPANIC_ASSERT_DEBUG(iEglManagementApi, EVgPanicMissingEglInterface); + } + if (iEglManagementApi) + { + return iEglManagementApi->EglImageOpenForVgImage(aImage, aSize, aVgHandle, aSgImageId); + } + return EFalse; + } + + +void XOpenVgState::EglImageClose(EGLImageKHR aImage) + { + if (iEglManagementApi) + { + iEglManagementApi->EglImageClose(aImage); + } + } + + +// Guest Open VG extension export support for eglGetProcAddress +typedef struct + { + const char* procName; // procedure name + ExtensionProcPointer procAddr; + } TVgExtnInfo; + +// VG extension functions +static const TVgExtnInfo vgProcedures[] = + { + { "vgCreateEGLImageTargetKHR", (ExtensionProcPointer)vgCreateEGLImageTargetKHR }, + }; + +const TInt KVgProcCount = sizeof(vgProcedures) / sizeof(TVgExtnInfo); + +ExtensionProcPointer XOpenVgState::guestGetVgProcAddress (const char *aProcName) + { + // exhaustive search + for (TInt idx = 0; idx < KVgProcCount; idx++) + { + if (!strcmp(aProcName, vgProcedures[idx].procName)) + return vgProcedures[idx].procAddr; + } + return NULL; + } + + +///////////////////////////////////////////////////////////////////////////////////////////// +// TCleanupVgLocks +///////////////////////////////////////////////////////////////////////////////////////////// + +TCleanupVgLocks::TCleanupVgLocks(MVgContext& aVgContext) : + iVgContext(aVgContext), iMutex(OpenVgState.MutexWait()), iIsHeld(ETrue) + {} + +TCleanupVgLocks::~TCleanupVgLocks() + { + if (iIsHeld) + { + SignalMutex(); + } + } + +void TCleanupVgLocks::SignalMutex() + { + VGPANIC_ASSERT_DEBUG(iIsHeld && iMutex.IsHeld(), EVgPanicTemp); + iMutex.Signal(); + iIsHeld = EFalse; + } + + +/* + Returns false & sets VG error to VG_ILLEGAL_ARGUMENT_ERROR if VGMaskOperation is not a supported operation + */ +TBool TCleanupVgLocks::CheckVGMaskOperationAndHandle(VGMaskOperation aOperation, VGHandle aMask, CVgImageBase** aHandleInfo) + { + VGPANIC_ASSERT_DEBUG(iIsHeld, EVgPanicStateLockMutexNotHeld); + *aHandleInfo = NULL; + switch (aOperation) + { + case VG_CLEAR_MASK: + case VG_FILL_MASK: + // aMask is not used for these operations + return ETrue; + case VG_SET_MASK: + case VG_UNION_MASK: + case VG_INTERSECT_MASK: + case VG_SUBTRACT_MASK: + { + if (aMask == VG_INVALID_HANDLE) + return ETrue; + + CVgHandleBase* tempInfo; + if (CheckVGAnyHandle(aMask, &tempInfo)) + { + if ( (tempInfo->HandleType() == EVgHandleForMaskLayer) || (tempInfo->HandleType() == EVgHandleForImage) ) + { + *aHandleInfo = (CVgImageBase*)tempInfo; + // TODO if handle is a VgImage verify that it is not a rendering target + return ETrue; + } + OPENVG_TRACE("TCleanupVgLocks::CheckVGMaskOperationAndHandle setting VG_BAD_HANDLE_ERROR"); + iVgContext.SetVgError(VG_BAD_HANDLE_ERROR); + } + return EFalse; + } + default: + OPENVG_TRACE("TCleanupVgLocks::CheckVGMaskOperationAndHandle setting VG_ILLEGAL_ARGUMENT_ERROR"); + iVgContext.SetVgError(VG_ILLEGAL_ARGUMENT_ERROR); + return EFalse; + } + } + + +VGFont TCleanupVgLocks::CreateFont(VGint aGlyphCapacityHint) + { + VGPANIC_ASSERT_DEBUG(iIsHeld && iMutex.IsHeld(), EVgPanicTemp); + + CVgFontInfo* fontInfo = CVgFontInfo::New(); + if (fontInfo == NULL) + { + OPENVG_TRACE(" TGuestOpenVg::vgCreateFont - CVgFontInfo::New() failed"); + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreateFont); + vgApiData.AppendParam(aGlyphCapacityHint); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGFont hostFont = static_cast(vgApiData.ReturnValue()); + OPENVG_TRACE(" TCleanupVgLocks::CreateFont - CVgFontInfo::New() success, hostFont=0x%x", hostFont); + + if ( (hostFont != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, fontInfo, hostFont) ) + { + return fontInfo->ClientHandle(); + } + + fontInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGImage TCleanupVgLocks::ChildImage(CVgImageInfo& aParentInfo, VGint aX, VGint aY, VGint aWidth, VGint aHeight) + { + CVgImageInfo* imageInfo = CVgImageInfo::New(aWidth, aHeight, &aParentInfo); + if (imageInfo == NULL) + { + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + OPENVG_TRACE(" TCleanupVgLocks::ChildImage - CVgImageInfo::New() failed"); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgChildImage); + vgApiData.AppendParam(aParentInfo.HostHandle()); + vgApiData.AppendParam(aX); + vgApiData.AppendParam(aY); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGImage hostImageHandle = static_cast(vgApiData.ReturnValue()); + + OPENVG_TRACE(" TCleanupVgLocks::ChildImage - CVgImageInfo::New() success, hostImageHandle=0x%x", hostImageHandle); + if ( (hostImageHandle != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, imageInfo, hostImageHandle) ) + { + return imageInfo->ClientHandle(); + } + imageInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGImage TCleanupVgLocks::CreateImage(VGImageFormat aFormat, VGint aWidth, VGint aHeight, VGbitfield aAllowedQuality) + { + CVgImageInfo* imageInfo = CVgImageInfo::New(aFormat, aWidth, aHeight, aAllowedQuality); + if (imageInfo == NULL) + { + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + OPENVG_TRACE(" TCleanupVgLocks::CreateImage - CVgImageInfo::New() failed"); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreateImage); + vgApiData.AppendParam(aFormat); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + vgApiData.AppendParam(aAllowedQuality); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGImage hostImageHandle = static_cast(vgApiData.ReturnValue()); + + OPENVG_TRACE(" TCleanupVgLocks::CreateImage - CVgImageInfo::New() success, hostImageHandle=0x%x", hostImageHandle); + if ( (hostImageHandle != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, imageInfo, hostImageHandle) ) + { + return imageInfo->ClientHandle(); + } + imageInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGMaskLayer TCleanupVgLocks::CreateMaskLayer(VGint aWidth, VGint aHeight) + { + CVgMaskLayerInfo* maskLayerInfo = CVgMaskLayerInfo::New(aWidth, aHeight); + if (maskLayerInfo == NULL) + { + OPENVG_TRACE(" TCleanupVgLocks::CreateMaskLayer - CVgMaskLayerInfo::New() failed"); + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreateMaskLayer); + vgApiData.AppendParam(aWidth); + vgApiData.AppendParam(aHeight); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGMaskLayer hostMaskHandle = static_cast(vgApiData.ReturnValue()); + + OPENVG_TRACE(" TCleanupVgLocks::CreateMaskLayer - CVgMaskLayerInfo::New() success, hostMaskHandle=0x%x", hostMaskHandle); + if ( (hostMaskHandle != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, maskLayerInfo, hostMaskHandle) ) + { + return maskLayerInfo->ClientHandle(); + } + maskLayerInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGPaint TCleanupVgLocks::CreatePaint() + { + CVgPaintInfo* paintInfo = CVgPaintInfo::New(); + if (paintInfo == NULL) + { + OPENVG_TRACE(" TCleanupVgLocks::CreatePaint - CVgPaintInfo::New() failed"); + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreatePaint); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGPaint hostPaint = static_cast(vgApiData.ReturnValue()); + + OPENVG_TRACE(" TCleanupVgLocks::CreatePaint - CVgPaintInfo::New() success, clientHandle=0x%x, hostHandle=0x%x", + paintInfo->ClientHandle(), hostPaint); + if ( (hostPaint != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, paintInfo, hostPaint) ) + { + return paintInfo->ClientHandle(); + } + paintInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGPaint TCleanupVgLocks::GetPaint(VGPaintMode aPaintMode) + { + CVgPaintInfo* paintInfo = CVgPaintInfo::New(); + if (paintInfo == NULL) + { + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + OPENVG_TRACE(" TCleanupVgLocks::GetPaint - CVgPaintInfo::New() failed"); + } + else + { + RemoteFunctionCallData rfcdata; OpenVgRFC vgApiData(rfcdata); + vgApiData.Init(OpenVgRFC::EvgGetPaint); + vgApiData.AppendParam(aPaintMode); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGPaint hostPaint = static_cast(vgApiData.ReturnValue()); + + OPENVG_TRACE(" TCleanupVgLocks::GetPaint - CVgPaintInfo::New() success, clientHandle=0x%x, hostHandle=0x%x", + paintInfo->ClientHandle(), hostPaint); + if ( (hostPaint != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, paintInfo, hostPaint) ) + { + return paintInfo->ClientHandle(); + } + paintInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGPath TCleanupVgLocks::CreatePath(VGint aPathFormat, VGPathDatatype aDatatype, VGfloat aScale, VGfloat aBias, + VGint aSegmentCapacityHint, VGint aCoordCapacityHint, VGbitfield aCapabilities) + { + VGPANIC_ASSERT_DEBUG(iIsHeld && iMutex.IsHeld(), EVgPanicTemp); + + aCapabilities &= VG_PATH_CAPABILITY_ALL; + CVgPathInfo* pathInfo = CVgPathInfo::New(aDatatype, aScale, aBias, aCapabilities); + if (pathInfo == NULL) + { + OPENVG_TRACE(" TCleanupVgLocks::CreatePath - CVgPathInfo::New() failed"); + iVgContext.SetVgError(VG_OUT_OF_MEMORY_ERROR); + } + else + { + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreatePath); + vgApiData.AppendParam(aPathFormat); + vgApiData.AppendParam(aDatatype); + vgApiData.AppendParam(aScale); + vgApiData.AppendParam(aBias); + vgApiData.AppendParam(aSegmentCapacityHint); + vgApiData.AppendParam(aCoordCapacityHint); + vgApiData.AppendParam(aCapabilities); + VGPANIC_ASSERT_DEBUG(vgApiData.Data().Header().iOpType == RemoteFunctionCallData::EOpRequestWithReply, EVgPanicNotReplyOpcode); + iVgContext.ExecuteVgCommand(vgApiData); + VGPath hostPath = static_cast(vgApiData.ReturnValue()); + OPENVG_TRACE(" TCleanupVgLocks::CreatePath - CVgPathInfo::New() success, hostHandle=0x%x", hostPath); + + if ( (hostPath != VG_INVALID_HANDLE) && OpenVgState.AddToHashMap(iVgContext, pathInfo, hostPath) ) + { + return pathInfo->ClientHandle(); + } + + pathInfo->Destroy(iVgContext); + } + + return VG_INVALID_HANDLE; + } + + +VGImage TCleanupVgLocks::CreateEGLImageTargetKHR(VGeglImageKHR aImage) + { + VGErrorCode error = VG_NO_ERROR; + + if (aImage == NULL) + { + error = VG_ILLEGAL_ARGUMENT_ERROR; + } + else + { + // Try to open EGL Image from handle, and get info such as image size + TSize imageSize; + TUint64 sgImageId; + VGHandle vgHandle; + if (!OpenVgState.EglImageOpenForVgImage((EGLImageKHR) aImage, imageSize, vgHandle, sgImageId)) + { + error = VG_UNSUPPORTED_IMAGE_FORMAT_ERROR; + } + else + { // Open success, create a CVgImageInfo with all the details ... + // ToDo get & store VGImageFormat of underlying VGImage + CVgImageInfo* newImageInfo = CVgImageInfo::New(VG_IMAGE_FORMAT_INVALID, imageSize.iWidth, imageSize.iHeight, + (EGLImageKHR) aImage, sgImageId); + OPENVG_TRACE("TGuestOpenVg::vgCreateEGLImageTargetKHR imageSize=%d,%d, vgHandle=0x%x, sgImageId=0x%lx newImageInfo=0x%x", + imageSize.iWidth, imageSize.iHeight, vgHandle, sgImageId, newImageInfo); + if (newImageInfo == NULL) + { + error = VG_OUT_OF_MEMORY_ERROR; + OpenVgState.EglImageClose((EGLImageKHR) aImage); + } + else + { + if (OpenVgState.AddToHashMap(iVgContext, newImageInfo, vgHandle)) + { + // Notify Command Scheduler & KhronosWrappers + RemoteFunctionCallData data; OpenVgRFC vgApiData(data); + vgApiData.Init(OpenVgRFC::EvgCreateEGLImageTargetKHR, RemoteFunctionCallData::EOpRequestWithReply); + vgApiData.AppendParam(aImage); + // ToDo any other parameters needed? Is this really a Request with Reply? + iVgContext.ExecuteVgCommand(vgApiData); + return newImageInfo->ClientHandle(); + } + newImageInfo->Destroy(iVgContext); + } + } + } + + + if (error != VG_NO_ERROR) + { + iVgContext.SetVgError(error); + OPENVG_TRACE("TGuestOpenVg::vgCreateEGLImageTargetKHR fail - error=0x%x", error); + } + + return VG_INVALID_HANDLE; + } + + + + +// **** Desirable: could check VGParamType for vgGet & vgSet scalar & vector operations. +/* + // Mode settings + VG_MATRIX_MODE ??? + VG_FILL_RULE ??? + VG_IMAGE_QUALITY ??? + VG_RENDERING_QUALITY ??? + VG_BLEND_MODE ??? + VG_IMAGE_MODE ??? + + // Scissoring rectangles + VG_SCISSOR_RECTS ??? + + // Color Transformation + VG_COLOR_TRANSFORM ??? + VG_COLOR_TRANSFORM_VALUES ??? + + // Stroke parameters + VG_STROKE_LINE_WIDTH ??? + VG_STROKE_CAP_STYLE ??? + VG_STROKE_JOIN_STYLE ??? + VG_STROKE_MITER_LIMIT ??? + VG_STROKE_DASH_PATTERN ??? + VG_STROKE_DASH_PHASE ??? + VG_STROKE_DASH_PHASE_RESET ??? + + // Edge fill color for VG_TILE_FILL tiling mode + VG_TILE_FILL_COLOR ??? + + // Color for vgClear + VG_CLEAR_COLOR ??? + + // Glyph origin + VG_GLYPH_ORIGIN ??? + + // Enable/disable alpha masking and scissoring + VG_MASKING ??? + VG_SCISSORING ??? + + // Pixel layout information + VG_PIXEL_LAYOUT ??? + VG_SCREEN_LAYOUT ??? + + // Source format selection for image filters + VG_FILTER_FORMAT_LINEAR ??? + VG_FILTER_FORMAT_PREMULTIPLIED ??? + + // Destination write enable mask for image filters + VG_FILTER_CHANNEL_MASK ??? + + // Implementation limits (read-only) + VG_MAX_SCISSOR_RECTS, ReadOnly, Scalar + VG_MAX_DASH_COUNT ??? + VG_MAX_KERNEL_SIZE ??? + VG_MAX_SEPARABLE_KERNEL_SIZE ??? + VG_MAX_COLOR_RAMP_STOPS ??? + VG_MAX_IMAGE_WIDTH ??? + VG_MAX_IMAGE_HEIGHT ??? + VG_MAX_IMAGE_PIXELS ??? + VG_MAX_IMAGE_BYTES ??? + VG_MAX_FLOAT ??? + VG_MAX_GAUSSIAN_STD_DEVIATION ??? + */ + +////////////////////////////////////////////////////////////////////////// + +// end of file vgstate.cpp