doc: add documentation

- add documentation for CKGlobals, VxMath (partly)
- Fix build issue in CKDefines, CKGlobals, VxMath.
- Bring libcmo exception in CKGlobals and VxMath for some illegal input.
This commit is contained in:
2024-08-21 17:57:35 +08:00
parent f7708c28e0
commit a7c1028926
7 changed files with 261 additions and 144 deletions

View File

@ -11,7 +11,8 @@ namespace LibCmo::VxMath {
}
void VxCopyStructure(CKDWORD Count, void* Dst, CKDWORD OutStride, CKDWORD SizeSrc, const void* Src, CKDWORD InStride) {
if (Dst == nullptr || Src == nullptr) return;
if ((Dst == nullptr || Src == nullptr) && Count != 0u)
throw LogicException("Source or destination buffer should not be nullptr.");
CKBYTE* cdst = static_cast<CKBYTE*>(Dst);
const CKBYTE* csrc = static_cast<const CKBYTE*>(Src);
@ -27,8 +28,10 @@ namespace LibCmo::VxMath {
#pragma region Graphic Utilities
void VxDoBlit(const VxImageDescEx* origin, VxImageDescEx* dst) {
if (dst == nullptr || origin == nullptr) return;
if (!dst->IsValid() || !origin->IsValid()) return;
if (dst == nullptr || origin == nullptr)
throw LogicException("VxImageDescEx* should not be nullptr.");
if (!dst->IsValid() || !origin->IsValid())
throw LogicException("VxImageDescEx* should not be invalid.");
// if have same size, directly copy it
if (dst->IsHWEqual(*origin)) {
@ -48,8 +51,10 @@ namespace LibCmo::VxMath {
}
void VxDoBlitUpsideDown(const VxImageDescEx* origin, VxImageDescEx* dst) {
if (dst == nullptr || origin == nullptr) return;
if (!dst->IsValid() || !origin->IsValid()) return;
if (dst == nullptr || origin == nullptr)
throw LogicException("VxImageDescEx* should not be nullptr.");
if (!dst->IsValid() || !origin->IsValid())
throw LogicException("VxImageDescEx* should not be invalid.");
// if size is not matched, return
if (!dst->IsHWEqual(*origin)) {
@ -99,7 +104,8 @@ namespace LibCmo::VxMath {
//}
void VxDoAlphaBlit(VxImageDescEx* dst_desc, CKBYTE AlphaValue) {
if (dst_desc == nullptr) return;
if (dst_desc == nullptr || !dst_desc->IsValid())
throw LogicException("VxImageDescEx* should not be nullptr or invalid.");
CKDWORD* pixels = dst_desc->GetMutablePixels();
CKDWORD pixelcount = dst_desc->GetPixelCount();
@ -111,7 +117,10 @@ namespace LibCmo::VxMath {
}
void VxDoAlphaBlit(VxImageDescEx* dst_desc, const CKBYTE* AlphaValues) {
if (dst_desc == nullptr) return;
if (dst_desc == nullptr || !dst_desc->IsValid() || AlphaValues == nullptr)
throw LogicException("VxImageDescEx* should not be nullptr or invalid.");
if (AlphaValues == nullptr)
throw LogicException("Alpha channel buffer should not be nullptr.");
CKDWORD* pixels = dst_desc->GetMutablePixels();
CKDWORD pixelcount = dst_desc->GetPixelCount();

View File

@ -7,23 +7,27 @@ namespace LibCmo::VxMath {
/**
* @brief Fills a memory buffer with a source buffer pattern.
* @param Count[in] Number of element to set in the destination buffer
* @param Dst[out] Destination buffer
* @param Stride[in] Amount in bytes between each element in the destination buffer
* @param SizeSrc[in] Size in bytes of an element int the Src buffer
* @param Src[in] Source buffer
* @remark This function can be used to initialized an array of structure when only some members should be modified.
* @details This function can be used to initialized an array of structure when only some members should be modified.
* @param[in] Count Number of element to set in the destination buffer
* @param[out] Dst Destination buffer
* @param[in] Stride Amount in bytes between each element in the destination buffer
* @param[in] SizeSrc Size in bytes of an element int the Src buffer
* @param[in] Src Source buffer
* @exception LogicException Raised if source or destination buffer is nullptr, and count is not zero.
* @remarks If given buffer is not sufficient to perform operations, it will cause undefined behavior.
*/
void VxFillStructure(CKDWORD Count, void* Dst, CKDWORD Stride, CKDWORD SizeSrc, const void* Src);
/**
* @brief copies an array of elements between two memory buffers.
* @param Count[in] Number of element to copy in the destination buffer
* @param Dst[out] Destination buffer
* @param OutStride[in] Amount in bytes between each element in the destination buffer
* @param SizeSrc[in] Size in bytes of an element
* @param Src[in] Source buffer.
* @param InStride[in] Amount in bytes between each element in the source buffer
* @remark This function can be used to initialized an array of structure when only some members should be modified.
* @details This function can be used to initialized an array of structure when only some members should be modified.
* @param[in] Count Number of element to copy in the destination buffer
* @param[out] Dst Destination buffer
* @param[in] OutStride Amount in bytes between each element in the destination buffer
* @param[in] SizeSrc Size in bytes of an element
* @param[in] Src Source buffer.
* @param[in] InStride Amount in bytes between each element in the source buffer
* @exception LogicException Raised if source or destination buffer is nullptr, and count is not zero.
* @remarks If given buffer is not sufficient to perform operations, it will cause undefined behavior.
*/
void VxCopyStructure(CKDWORD Count, void* Dst, CKDWORD OutStride, CKDWORD SizeSrc, const void* Src, CKDWORD InStride);
@ -31,55 +35,63 @@ namespace LibCmo::VxMath {
/**
* @brief Performs a blit between two images. This method can resize (shrink or grow) images.
* @remark The source image must be in a 32 bit ARGB8888 per pixel format.
* @param dest[out] The dest image.
* @param origin[in] The origin image.
* @param[out] dst The destination image.
* @param[in] origin The origin image.
* @remarks The source image must be in a 32 bit ARGB8888 per pixel format.
* @exception LogicException Raised if given image description is nullptr or invalid.
*/
void VxDoBlit(const VxImageDescEx* origin, VxImageDescEx* dst);
/**
* @brief Performs a blit between two images. This method can inverts the destination image.
* @remark
+ The source image must be in a 32 bit ARGB8888 per pixel format.
+ This function usually used in the covertion between texture coordinate
system and UV coordinate system.
* @param dest[out] The dest image.
* @param origin[in] The origin image.
* @param[out] dst The destination image.
* @param[in] origin The origin image.
* @remarks
* \li The source image must be in a 32 bit ARGB8888 per pixel format.
* \li This function usually used in the covertion between texture coordinate system and UV coordinate system.
* @exception LogicException Raised if given image description is nullptr or invalid.
*/
void VxDoBlitUpsideDown(const VxImageDescEx* origin, VxImageDescEx* dst);
/**
* @brief Counts number of bits to representing a value in dwMask
* @brief Get the total count of set(1) bit in given value.
* @param[in] dwMask The value for counting.
* @return The total count of set(1) bit.
*/
CKDWORD VxGetBitCount(CKDWORD dwMask);
/**
* @brief Counts number of bits to shift to acces a non zero value in dwMask.
* @brief Get the offset in bit to first set(1) bit when performing right shift.
* @param[in] dwMask The value for fetching offset.
* @return The offset in bit to first set(1) bit.
* If there is no set(1) bit in given value, return 0 instead.
*/
CKDWORD VxGetBitShift(CKDWORD dwMask);
///**
// * @brief scale the integer to a new range.
// * @param val The int need to be scale
// * @param srcBitCount The bit count which source integer consumed.
// * @param dstBitCount The bit count which dest integer consumed.
// * @remark This function usually used in image color factor assign with mask.
// /**
// * @brief Scale the integer to a new range.
// * @param[in] val The int need to be scale
// * @param[in] srcBitCount The bit count which source integer consumed.
// * @param[in] dstBitCount The bit count which dest integer consumed.
// * @remarks This function usually used in image color factor assign with mask.
// * @return The result integer.
//*/
//CKDWORD VxScaleFactor(CKDWORD val, CKDWORD srcBitCount, CKDWORD dstBitCount);
/**
* @brief Sets the alpha component of an image.
* @remark The source image must be in a 32 bit ARGB8888 per pixel format.
* @param dst_desc[in] A pointer to a structure describing the destination image format.
* @param AlphaValue[in] A CKBYTE value containing the alpha value to set to the whole image
* @remark If the destination image does not have alpha information the function returns immediatly.
* @param[in] dst_desc A pointer to a structure describing the destination image format.
* @param[in] AlphaValue A CKBYTE value containing the alpha value to set to the whole image
* @remarks The source image must be in a 32 bit ARGB8888 per pixel format.
* @exception LogicException Raised if given image description is nullptr or invalid.
*/
void VxDoAlphaBlit(VxImageDescEx* dst_desc, CKBYTE AlphaValue);
/**
* @brief Sets the alpha component of an image.
* @remark The source image must be in a 32 bit ARGB8888 per pixel format.
* @param dst_desc[in] A pointer to a structure describing the destination image format.
* @param AlphaValues[in] A BYTE array containing the alpha values for each pixel. This array should be allocated to Width*Height bytes.
* @remark If the destination image does not have alpha information the function returns immediatly.
* @param[in] dst_desc A pointer to a structure describing the destination image format.
* @param[in] AlphaValues A BYTE array containing the alpha values for each pixel. This array should be allocated to Width * Height bytes.
* @remarks
* \li The source image must be in a 32 bit ARGB8888 per pixel format.
* \li If given alpha channel buffer do not have correct length, it will cause undefined behavior.
* @exception LogicException Raised if given image description or alpha channel buffer is nullptr or invalid.
*/
void VxDoAlphaBlit(VxImageDescEx* dst_desc, const CKBYTE* AlphaValues);