From: György Straub Date: Mon, 21 Dec 2020 17:05:03 +0000 (+0000) Subject: Cosmetic fixes in dali-scene-loader. X-Git-Tag: dali_2.0.7~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=151ed31bc62c3db2e423ac5b9f1a1065e40ea6ce Cosmetic fixes in dali-scene-loader. - implementation of (public-api) structors moved out of headers; - default structors replaced with 'default' keyword where possible; - disallowed construction of 'namespace' classes; - whitespace; - etc. Change-Id: I9c2e5ef3d8620cad9f7077cd2e8bacd352ea37ee Signed-off-by: György Straub --- diff --git a/dali-scene-loader/public-api/animation-definition.cpp b/dali-scene-loader/public-api/animation-definition.cpp index b41b8d5..ee2b519 100644 --- a/dali-scene-loader/public-api/animation-definition.cpp +++ b/dali-scene-loader/public-api/animation-definition.cpp @@ -32,11 +32,10 @@ Animation::EndAction AnimationDefinition::StopForModification(Animation& anim) return endAction; } -AnimationDefinition::AnimationDefinition() -{} +AnimationDefinition::AnimationDefinition() = default; AnimationDefinition::AnimationDefinition(AnimationDefinition&& other) -: mName(std::move(other.mName)), +: mName(std::move(other.mName)), mDuration(other.mDuration), mLoopCount(other.mLoopCount), mDisconnectAction(other.mDisconnectAction), diff --git a/dali-scene-loader/public-api/blend-shape-details.h b/dali-scene-loader/public-api/blend-shape-details.h index 7ea6d3f..67283a8 100644 --- a/dali-scene-loader/public-api/blend-shape-details.h +++ b/dali-scene-loader/public-api/blend-shape-details.h @@ -68,6 +68,8 @@ struct DALI_SCENE_LOADER_API BlendShapes * on the given @a shader and @a actor. */ static void ConfigureProperties(const std::pair& mesh, Shader shader, Actor actor); + + BlendShapes() = delete; }; } diff --git a/dali-scene-loader/public-api/camera-parameters.h b/dali-scene-loader/public-api/camera-parameters.h index 20b3ee3..044c7f4 100644 --- a/dali-scene-loader/public-api/camera-parameters.h +++ b/dali-scene-loader/public-api/camera-parameters.h @@ -35,23 +35,12 @@ namespace SceneLoader struct DALI_SCENE_LOADER_API CameraParameters { - CameraParameters() - : matrix(Matrix::IDENTITY), - orthographicSize(-1.f, 1.f, 1.f, -1.f), - yFov(60.f), - zNear(0.1f), - zFar(1000.f), - isPerspective(true) - {} - - ~CameraParameters() = default; - - Matrix matrix; - Vector4 orthographicSize; - float yFov; - float zNear; - float zFar; - bool isPerspective; + Matrix matrix = Matrix::IDENTITY; + Vector4 orthographicSize = Vector4{ -1.f, 1.f, 1.f, -1.f }; + float yFov = 60.f; + float zNear = 0.1f; + float zFar = 1000.f; + bool isPerspective = true; /** * @return The view-projection matrix of the camera. diff --git a/dali-scene-loader/public-api/dli-loader.cpp b/dali-scene-loader/public-api/dli-loader.cpp index 06268eb..11dc036 100644 --- a/dali-scene-loader/public-api/dli-loader.cpp +++ b/dali-scene-loader/public-api/dli-loader.cpp @@ -159,9 +159,9 @@ void ReadArcField(const TreeNode* eArc, ArcNode& arc) ReadFloat(eArc->GetChild("endAngle"), arc.mEndAngleDegrees); } -const TreeNode *Tidx(const TreeNode *node, int index) +const TreeNode *GetNthChild(const TreeNode *node, uint32_t index) { - int i = 0; + uint32_t i = 0; for (TreeNode::ConstIterator it = (*node).CBegin(); it != (*node).CEnd(); ++it, ++i) { if (i == index) @@ -463,8 +463,8 @@ void DliLoader::Impl::ParseScene(LoadParams& params) void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes, const Toolkit::TreeNode* tnNodes, LoadParams& params) { - auto getSceneRootIdx = [&](Index iScene) { - auto tn = Tidx(tnScenes, iScene); // now a "scene" object + auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) { + auto tn = GetNthChild(tnScenes, iScene); // now a "scene" object if (!tn) { ExceptionFlinger(ASSERT_LOCATION) << iScene << " is out of bounds access into " << SCENES << "."; @@ -483,7 +483,7 @@ void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* " must define a node id."; } - tn = Tidx(tn, 0); // now the first element of the array + tn = GetNthChild(tn, 0); // now the first element of the array Index iRootNode; if (!ReadIndex(tn, iRootNode)) { @@ -496,7 +496,7 @@ void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* ExceptionFlinger(ASSERT_LOCATION) << "Root node index << " << iRootNode << " of scene " << iScene << " is out of bounds."; } - tn = Tidx(tnNodes, iRootNode); // now a "node" object + tn = GetNthChild(tnNodes, iRootNode); // now a "node" object if (tn->GetType() != TreeNode::OBJECT) { ExceptionFlinger(ASSERT_LOCATION) << "Root node of scene " << iScene << " is of invalid JSON type; object required"; @@ -1095,7 +1095,7 @@ void DliLoader::Impl::ParseNodesInternal(const TreeNode* const nodes, Index inde std::vector resourceIds; resourceIds.reserve(4); - if (auto node = Tidx(nodes, index)) + if (auto node = GetNthChild(nodes, index)) { NodeDefinition nodeDef; nodeDef.mParentIdx = inOutParentStack.empty() ? INVALID_INDEX : inOutParentStack.back(); diff --git a/dali-scene-loader/public-api/material-definition.cpp b/dali-scene-loader/public-api/material-definition.cpp index ca1244b..952a824 100644 --- a/dali-scene-loader/public-api/material-definition.cpp +++ b/dali-scene-loader/public-api/material-definition.cpp @@ -100,6 +100,11 @@ Sampler SamplerFlags::MakeSampler(Type flags) return sampler; } +TextureDefinition::TextureDefinition(const std::string& imageUri, SamplerFlags::Type samplerFlags) +: mImageUri(imageUri), + mSamplerFlags(samplerFlags) +{} + MaterialDefinition::RawData MaterialDefinition::LoadRaw(const std::string& imagesPath) const { diff --git a/dali-scene-loader/public-api/material-definition.h b/dali-scene-loader/public-api/material-definition.h index 619e849..d360c88 100644 --- a/dali-scene-loader/public-api/material-definition.h +++ b/dali-scene-loader/public-api/material-definition.h @@ -116,10 +116,7 @@ struct DALI_SCENE_LOADER_API TextureDefinition std::string mImageUri; SamplerFlags::Type mSamplerFlags; - TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT) - : mImageUri(imageUri), - mSamplerFlags(samplerFlags) - {} + TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT); }; /** diff --git a/dali-scene-loader/public-api/mesh-definition.cpp b/dali-scene-loader/public-api/mesh-definition.cpp index 9823295..2cea908 100644 --- a/dali-scene-loader/public-api/mesh-definition.cpp +++ b/dali-scene-loader/public-api/mesh-definition.cpp @@ -64,7 +64,7 @@ private: }; -const std::string QUAD_STRING("quad"); +const std::string QUAD("quad"); ///@brief Reads a blob from the given stream @a source into @a target, which must have /// at least @a descriptor.length bytes. @@ -290,10 +290,10 @@ void CalculateTextureSize(uint32_t totalTextureSize, uint32_t& textureWidth, uin { DALI_ASSERT_DEBUG(0u != totalTextureSize && "totalTextureSize is zero.") - // Calculate the dimensions of the texture. - // The total size of the texture is the length of the blend shapes blob. + // Calculate the dimensions of the texture. + // The total size of the texture is the length of the blend shapes blob. - textureWidth = 0u; + textureWidth = 0u; textureHeight = 0u; if (0u == totalTextureSize) @@ -443,14 +443,14 @@ void CalculateGltf2BlendShapes(uint8_t* geometryBuffer, std::ifstream& binFile, } MeshDefinition::SparseBlob::SparseBlob(const Blob& indices, const Blob& values, uint32_t count) -: mIndices{indices}, +: mIndices{indices}, mValues{values}, mCount{count} {} MeshDefinition::Accessor::Accessor(const MeshDefinition::Blob& blob, const MeshDefinition::SparseBlob& sparse) -: mBlob{blob}, +: mBlob{blob}, mSparse{(sparse.mIndices.IsDefined() && sparse.mValues.IsDefined()) ? new SparseBlob{sparse} : nullptr} {} @@ -489,6 +489,15 @@ void MeshDefinition::Blob::ApplyMinMax(const std::vector& min, const std: } } +MeshDefinition::Blob::Blob(uint32_t offset, uint32_t length, uint16_t stride, uint16_t elementSizeHint, const std::vector& min, const std::vector& max) +: mOffset(offset), + mLength(length), + mStride(stride), + mElementSizeHint(elementSizeHint), + mMin(min), + mMax(max) +{} + uint32_t MeshDefinition::Blob::GetBufferSize() const { return IsConsecutive() ? mLength : (mLength * mElementSizeHint / mStride); @@ -511,7 +520,7 @@ void MeshDefinition::RawData::Attrib::AttachBuffer(Geometry& g) const bool MeshDefinition::IsQuad() const { - return CaseInsensitiveStringCompare("quad", mUri); + return CaseInsensitiveStringCompare(QUAD, mUri); } bool MeshDefinition::IsSkinned() const diff --git a/dali-scene-loader/public-api/mesh-definition.h b/dali-scene-loader/public-api/mesh-definition.h index 6a1eaa6..057aad7 100644 --- a/dali-scene-loader/public-api/mesh-definition.h +++ b/dali-scene-loader/public-api/mesh-definition.h @@ -81,14 +81,7 @@ struct DALI_SCENE_LOADER_API MeshDefinition Blob() = default; Blob(uint32_t offset, uint32_t length, uint16_t stride = 0, uint16_t elementSizeHint = 0, - const std::vector& min = {}, const std::vector& max = {}) - : mOffset(offset), - mLength(length), - mStride(stride), - mElementSizeHint(elementSizeHint), - mMin(min), - mMax(max) - {} + const std::vector& min = {}, const std::vector& max = {}); /** * @brief Calculates the size of a tightly-packed buffer for the elements from the blob. diff --git a/dali-scene-loader/public-api/node-definition.h b/dali-scene-loader/public-api/node-definition.h index 994ec18..3dec499 100644 --- a/dali-scene-loader/public-api/node-definition.h +++ b/dali-scene-loader/public-api/node-definition.h @@ -44,8 +44,7 @@ class ViewProjection; class DALI_SCENE_LOADER_API IResourceReceiver { public: - virtual ~IResourceReceiver() - {} + virtual ~IResourceReceiver() = default; virtual void Register(ResourceType::Value type, Index id) = 0; }; @@ -58,8 +57,7 @@ public: class DALI_SCENE_LOADER_API IResourceReflector { public: - virtual ~IResourceReflector() - {} + virtual ~IResourceReflector() = default; virtual void Reflect(ResourceType::Value type, Index& id) = 0; }; @@ -163,7 +161,7 @@ public: // TYPES Index mShaderIdx = INVALID_INDEX; public: // METHODS - virtual ~Renderable() {} + virtual ~Renderable() = default; virtual void RegisterResources(IResourceReceiver& receiver) const; virtual void ReflectResources(IResourceReflector& reflector); @@ -189,7 +187,7 @@ public: // TYPES virtual void Finish(NodeDefinition& n) = 0; protected: - ~IVisitor() {} + ~IVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable. }; class IConstVisitor @@ -199,7 +197,7 @@ public: // TYPES virtual void Finish(const NodeDefinition& n) = 0; protected: - ~IConstVisitor() {} + ~IConstVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable. }; struct Extra diff --git a/dali-scene-loader/public-api/scene-definition.cpp b/dali-scene-loader/public-api/scene-definition.cpp index 0bafc3b..409d285 100644 --- a/dali-scene-loader/public-api/scene-definition.cpp +++ b/dali-scene-loader/public-api/scene-definition.cpp @@ -206,7 +206,7 @@ class ActorCreatorVisitor : public NodeDefinition::IConstVisitor { public: ActorCreatorVisitor(NodeDefinition::CreateParams& params) - : mCreationContext(params) + : mCreationContext(params) {} void Start(const NodeDefinition& n) @@ -400,7 +400,7 @@ SceneDefinition::SceneDefinition() } SceneDefinition::SceneDefinition(SceneDefinition&& other) -: mNodes(std::move(other.mNodes)), +: mNodes(std::move(other.mNodes)), mRootNodeIds(std::move(other.mRootNodeIds)) { #ifdef DEBUG_JOINTS diff --git a/dali-scene-loader/public-api/skinning-details.h b/dali-scene-loader/public-api/skinning-details.h index 38dd628..415d25a 100644 --- a/dali-scene-loader/public-api/skinning-details.h +++ b/dali-scene-loader/public-api/skinning-details.h @@ -39,6 +39,8 @@ struct DALI_SCENE_LOADER_API Skinning * @brief Name of bone matrix uniform (array). */ static const std::string BONE_UNIFORM_NAME; + + Skinning() = delete; }; } diff --git a/dali-scene-loader/public-api/utils.cpp b/dali-scene-loader/public-api/utils.cpp index 382e118..dbfb8e8 100644 --- a/dali-scene-loader/public-api/utils.cpp +++ b/dali-scene-loader/public-api/utils.cpp @@ -35,6 +35,23 @@ namespace thread_local char sExceptionFlingerMessageBuffer[ExceptionFlinger::MESSAGE_BUFFER_SIZE]{}; } +StreamBuffer::StreamBuffer(char* buffer, size_t size) noexcept(true) +{ + setp(buffer, buffer + size); +} + +ExceptionFlinger::ExceptionFlinger(const char* location) noexcept(true) +: mLocation(location), + mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1), + mStream(&mStreamBuffer) +{} + +ExceptionFlinger::~ExceptionFlinger() noexcept(false) +{ + operator<<('\0'); + throw DaliException(mLocation, GetMessageBuffer()); +} + char* ExceptionFlinger::GetMessageBuffer() noexcept(true) { return sExceptionFlingerMessageBuffer; diff --git a/dali-scene-loader/public-api/utils.h b/dali-scene-loader/public-api/utils.h index 3ab0c33..70009a2 100644 --- a/dali-scene-loader/public-api/utils.h +++ b/dali-scene-loader/public-api/utils.h @@ -41,10 +41,7 @@ namespace SceneLoader class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf { public: - StreamBuffer(char* buffer, size_t size) noexcept(true) - { - setp(buffer, buffer + size); - } + StreamBuffer(char* buffer, size_t size) noexcept(true); }; /* @@ -57,18 +54,10 @@ class DALI_SCENE_LOADER_API ExceptionFlinger public: enum { MESSAGE_BUFFER_SIZE = 512 }; - ExceptionFlinger(const char* location) noexcept(true) - : mLocation(location), - mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1), - mStream(&mStreamBuffer) - {} + ExceptionFlinger(const char* location) noexcept(true); [[noreturn]] - ~ExceptionFlinger() noexcept(false) - { - operator<<('\0'); - throw DaliException(mLocation, GetMessageBuffer()); - } + ~ExceptionFlinger() noexcept(false); template ExceptionFlinger& operator<<(const T& rhs) noexcept(true)