This is a combination of 3 commits.
Let we remove many cases of dali-toolkit when we can be call 0u - 1u, which is undefined behavior.
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
(Scene3D) Fix svace issue : convert uint32_t to std::streamoff + minor
Fix svace issue when we try to convert from 32bit unsigned integer
to (might) 64bit signed integer.
+
Fix the name of function collision issue
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
Fix svace issue : Avoid to divide by zero cases
Change-Id: If11884693253cd86f89cb98704e93473166faca1
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return FindFloor(position, outPosition, faceIndex);
}
-bool NavigationMesh::FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& faceIndex)
+bool NavigationMesh::FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& outFaceIndex)
{
[[maybe_unused]] auto newPos = PointSceneToLocal(Dali::Vector3(position));
std::sort(results.begin(), results.end(), [](const IntersectResult& lhs, const IntersectResult& rhs) { return lhs.distance < rhs.distance; });
outPosition = PointLocalToScene(results.front().point);
- faceIndex = results.front().faceIndex;
- mCurrentFace = results.front().faceIndex;
+ outFaceIndex = results.front().faceIndex;
+ mCurrentFace = outFaceIndex;
return true;
}
#define DALI_SCENE3D_INTERNAL_NAVIGATION_MESH_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @copydoc Dali::Scene3D::Algorithm::NavigationMesh::FindFloor()
*/
- bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& faceIndex);
+ bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& outFaceIndex);
/**
* @copydoc Dali::Scene3D::Algorithm::NavigationMesh::GetFace()
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
ReadInt(tnKeyFramesBin->GetChild("byteOffset"), byteOffset);
DALI_ASSERT_ALWAYS(byteOffset >= 0);
- binAniFile.seekg(byteOffset, std::ios::beg);
+ binAniFile.seekg(static_cast<std::streamoff>(byteOffset), std::ios::beg);
int numKeys = 0;
ReadInt(tnKeyFramesBin->GetChild("numKeys"), numKeys);
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
auto& stream = context.mOutput.mResources.mBuffers[bufferIndex].GetBufferStream();
stream.clear();
- stream.seekg(textureInfo.mTexture->mSource->mBufferView->mByteOffset, stream.beg);
+ stream.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(textureInfo.mTexture->mSource->mBufferView->mByteOffset)), stream.beg);
std::vector<uint8_t> dataBuffer;
dataBuffer.resize(textureInfo.mTexture->mSource->mBufferView->mByteLength);
stream.read(reinterpret_cast<char*>(dataBuffer.data()), static_cast<std::streamsize>(static_cast<size_t>(textureInfo.mTexture->mSource->mBufferView->mByteLength)));
}
auto& stream = buffer.GetBufferStream();
stream.clear();
- stream.seekg(offset, stream.beg);
+ stream.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(offset)), stream.beg);
stream.read(reinterpret_cast<char*>(dataBuffer.Begin()), static_cast<std::streamsize>(static_cast<size_t>(size)));
}
DALI_LOG_ERROR("Failed to load from stream\n");
}
mStream.clear();
- mStream.seekg(accessor.mBufferView->mByteOffset + accessor.mByteOffset, mStream.beg);
+ mStream.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(accessor.mBufferView->mByteOffset + accessor.mByteOffset)), mStream.beg);
}
virtual void Provide(Matrix& inverseBindMatrix) override
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return mImpl->GetVertexCount();
}
-bool NavigationMesh::FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& faceIndex)
+bool NavigationMesh::FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& outFaceIndex)
{
- return mImpl->FindFloor(position, outPosition, faceIndex);
+ return mImpl->FindFloor(position, outPosition, outFaceIndex);
}
bool NavigationMesh::FindFloorForFace(const Dali::Vector3& position, FaceIndex faceIndex, bool dontCheckNeighbours, Dali::Vector3& outPosition)
#define DALI_SCENE3D_NAVIGATION_MESH_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @brief Looks for the floor under specified position
* @param[in] position Position to investigate
- * @param[in] outPosition Position on the floor in found
- * @param[out] faceIndex Index of NavigationMesh face associated with floor
+ * @param[out] outPosition Position on the floor in found
+ * @param[out] outFaceIndex Index of NavigationMesh face associated with floor
*
* @return True if floor has been found, False otherwise
*/
- bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& faceIndex);
+ bool FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& outFaceIndex);
/**
* @brief Looks for a floor starting from specified face
}
// Skip the key-values:
- if(fp.seekg(header.bytesOfKeyValueData, fp.cur).good() == false)
+ if(fp.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(header.bytesOfKeyValueData)), fp.cur).good() == false)
{
return false;
}
bool ReadBlob(const MeshDefinition::Blob& descriptor, std::istream& source, uint8_t* target)
{
source.clear();
- if(!source.seekg(descriptor.mOffset, std::istream::beg))
+ if(!source.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(descriptor.mOffset)), std::istream::beg))
{
return false;
}
{
readSize += descriptor.mStride;
target += descriptor.mElementSizeHint;
- source.seekg(diff, std::istream::cur);
+ source.seekg(static_cast<std::streamoff>(static_cast<std::size_t>(diff)), std::istream::cur);
}
return readSize == totalSize;
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
else
{
+ DALI_ASSERT_ALWAYS((startPos > 0u && size > 0u) && "Replacement keyword getter have some problem!\n");
+
const std::string str(initialValue.substr(startPos, size));
Property::Value* value = FindReplacement(str, overrideMap, defaultMap);
{
Vector2 dir(direction);
- int halfRange = displacement.x / 2;
+ int rangeX = std::max(static_cast<int>(displacement.x), 1); // To avoid divide by zero issue.
+ int rangeY = std::max(static_cast<int>(displacement.y), 1); // To avoid divide by zero issue.
+
+ int halfRangeX = displacement.x / 2;
// for the y coordinate, always negative, so bubbles always go upwards
- Vector2 randomVec(rand_r(&mRandomSeed) % static_cast<int>(displacement.x) - halfRange, -rand_r(&mRandomSeed) % static_cast<int>(displacement.y));
+ Vector2 randomVec(rand_r(&mRandomSeed) % rangeX - halfRangeX, -rand_r(&mRandomSeed) % rangeY);
dir.Normalize();
- randomVec.x -= dir.x * halfRange;
+ randomVec.x -= dir.x * halfRangeX;
randomVec.y *= 1.0f - fabsf(dir.x) * 0.33f;
if(randomVec.y > 0.0f)
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mIndexInvertedMovementArea = mRenderer.RegisterUniqueProperty("uInvertedMovementArea", Vector2(1.f, 1.f) / movementArea);
mIndicesOffset.resize(9);
- int offset = movementArea.Length() / 10.f;
+ int offset = std::max(static_cast<int>(movementArea.Length() / 10.f), 1); // To avoid divide by zero issue.
uint32_t seed = static_cast<uint32_t>(time(NULL));
{
namespace
{
+constexpr float MIN_DURATION_SECONDS = 1e-2f;
+
// Utility functions
const TreeNode* Tidx(const TreeNode* node, uint32_t index)
{
LoadDataFromAccessor<T>(currentSampler.output, outputBufferData, path, accessorArray, bufferViewArray, bufferArray);
uint32_t keyframeNum = inputBufferData.Size();
- float lengthAnimation = inputBufferData[inputBufferData.Size() - 1];
+ float lengthAnimation = std::max((inputBufferData.Size() > 0u ? inputBufferData[inputBufferData.Size() - 1] : MIN_DURATION_SECONDS), MIN_DURATION_SECONDS);
for(uint32_t i = 0; i < keyframeNum; i++)
{
if(propIndex == Dali::Actor::Property::ORIENTATION)
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
boundedParagraphRuns.Remove(paragraphToDelete);
numberOfRuns--;
+ if(lastRunIndexToUpdate == 0u)
+ {
+ break;
+ }
lastRunIndexToUpdate--;
continue;
mTextUpdateInfo.mRequestedNumberOfCharacters = mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove;
mTextUpdateInfo.mStartGlyphIndex = mModel->mVisualModel->mGlyphs.Count();
- mTextUpdateInfo.mStartLineIndex = mModel->mVisualModel->mLines.Count() - 1u;
+ mTextUpdateInfo.mStartLineIndex = (mModel->mVisualModel->mLines.Count() > 0u) ? mModel->mVisualModel->mLines.Count() - 1u : 0u;
// Nothing else to do;
return;
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
const Vector<GlyphInfo>& glyphs = layoutParameters.textModel->mVisualModel->mGlyphs;
+ if(glyphs.Size() == 0u)
+ {
+ // Do nothing.
+ return;
+ }
+
// Need to add a new line with no characters but with height to increase the layoutSize.height
const GlyphInfo& glyphInfo = glyphs[glyphs.Count() - 1u];
{
GlyphInfo glyph;
bool addHyphen = ((hyphenIndex < hyphensCount) && hyphenIndices && ((i + startIndexOfGlyphs) == hyphenIndices[hyphenIndex]));
- if(addHyphen && hyphens)
+ // TODO : Shouldn't we have to control here when i == 0 cases?
+ if(addHyphen && hyphens && i > 0u)
{
glyph = hyphens[hyphenIndex];
i--;
// Whether the given glyph is a color one.
const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
- const uint32_t glyphAlphaIndex = glyphPixelSize - 1u;
+ const uint32_t glyphAlphaIndex = (glyphPixelSize > 0u) ? glyphPixelSize - 1u : 0u;
// Determinate iterator range.
const int32_t lineIndexRangeMin = std::max(0, -yOffset);
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
std::sort(mGradientStops.Begin(), mGradientStops.End());
- unsigned int numStops = mGradientStops.Count();
+ uint32_t numStops = mGradientStops.Count();
+ DALI_ASSERT_ALWAYS(numStops > 0u && "The number of gradient stop should not be zero!");
/**
* If the stops have not covered the whole zero to one range,
unsigned int Gradient::EstimateTextureResolution()
{
- float minInterval = 1.0;
- for(unsigned int i = 0, numStops = mGradientStops.Count(); i < numStops - 1u; i++)
+ float minInterval = 1.0;
+ const uint32_t numStops = mGradientStops.Count();
+ DALI_ASSERT_ALWAYS(numStops > 0u && "The number of gradient stop should not be zero!");
+ for(uint32_t i = 0; i < numStops - 1u; i++)
{
float interval = mGradientStops[i + 1].mOffset - mGradientStops[i].mOffset;
minInterval = interval > minInterval ? minInterval : interval;