#define DALI_INTERNAL_PROPERTY_INPUT_IMPL_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 reinterpret_cast<const Matrix&>(*this);
}
- /**
- * Retrieve the address of the property value. Only for use
- * when writing uniforms.
- */
- virtual const void* GetValueAddress(BufferIndex bufferIndex) const = 0;
-
- /**
- * Retrieve the size of the property value for use in copying.
- * Only for use when writing uniforms.
- */
- virtual size_t GetValueSize() const = 0;
-
// Accessors for Constraint functions
/**
namespace
{
+// Helper to get the property value getter by type
+typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
+constexpr FuncGetter GetPropertyValueGetter(Property::Type type)
+{
+ switch(type)
+ {
+ case Property::BOOLEAN:
+ {
+ return FuncGetter(&PropertyInputImpl::GetBoolean);
+ }
+ case Property::INTEGER:
+ {
+ return FuncGetter(&PropertyInputImpl::GetInteger);
+ }
+ case Property::FLOAT:
+ {
+ return FuncGetter(&PropertyInputImpl::GetFloat);
+ }
+ case Property::VECTOR2:
+ {
+ return FuncGetter(&PropertyInputImpl::GetVector2);
+ }
+ case Property::VECTOR3:
+ {
+ return FuncGetter(&PropertyInputImpl::GetVector3);
+ }
+ case Property::VECTOR4:
+ {
+ return FuncGetter(&PropertyInputImpl::GetVector4);
+ }
+ case Property::MATRIX3:
+ {
+ return FuncGetter(&PropertyInputImpl::GetMatrix3);
+ }
+ case Property::MATRIX:
+ {
+ return FuncGetter(&PropertyInputImpl::GetMatrix);
+ }
+ default:
+ {
+ return nullptr;
+ }
+ }
+}
+
+/**
+ * Helper function that returns size of uniform datatypes based
+ * on property type.
+ */
+constexpr int GetPropertyValueSizeForUniform(Property::Type type)
+{
+ switch(type)
+ {
+ case Property::Type::BOOLEAN:
+ {
+ return sizeof(bool);
+ }
+ case Property::Type::FLOAT:
+ {
+ return sizeof(float);
+ }
+ case Property::Type::INTEGER:
+ {
+ return sizeof(int);
+ }
+ case Property::Type::VECTOR2:
+ {
+ return sizeof(Vector2);
+ }
+ case Property::Type::VECTOR3:
+ {
+ return sizeof(Vector3);
+ }
+ case Property::Type::VECTOR4:
+ {
+ return sizeof(Vector4);
+ }
+ case Property::Type::MATRIX3:
+ {
+ return sizeof(Matrix3);
+ }
+ case Property::Type::MATRIX:
+ {
+ return sizeof(Matrix);
+ }
+ default:
+ {
+ return 0;
+ }
+ };
+}
+
/**
* Helper function to calculate the correct alignment of data for uniform buffers
* @param dataSize size of uniform buffer
{
auto& uniform = iter;
int arrayIndex = uniform.arrayIndex;
- if(!uniform.initialized)
+ if(!uniform.uniformFunc)
{
auto uniformInfo = Graphics::UniformInfo{};
auto uniformFound = program.GetUniform(uniform.uniformName.GetStringView(),
uniform.uniformOffset = uniformInfo.offset;
uniform.uniformLocation = uniformInfo.location;
uniform.uniformBlockIndex = uniformInfo.bufferIndex;
- uniform.initialized = true;
auto dst = ubo->GetOffset() + uniformInfo.offset;
- const auto typeSize = iter.propertyValue->GetValueSize();
+ const auto typeSize = GetPropertyValueSizeForUniform(iter.propertyValue->GetType());
const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = GetPropertyValueGetter(iter.propertyValue->GetType());
+ uniform.uniformSize = typeSize;
+ uniform.uniformFunc = func;
- ubo->Write(iter.propertyValue->GetValueAddress(updateBufferIndex),
+ ubo->Write(&(iter.propertyValue->*func)(updateBufferIndex),
typeSize,
dest);
}
UniformBufferView* ubo = uboViews[uniform.uniformBlockIndex].get();
auto dst = ubo->GetOffset() + uniform.uniformOffset;
- const auto typeSize = iter.propertyValue->GetValueSize();
+ const auto typeSize = uniform.uniformSize;
const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = uniform.uniformFunc;
- ubo->Write(iter.propertyValue->GetValueAddress(updateBufferIndex),
+ ubo->Write(&(iter.propertyValue->*func)(updateBufferIndex),
typeSize,
dest);
}
using Hash = std::size_t;
+ typedef const float& (PropertyInputImpl::*FuncGetter)(BufferIndex) const;
+
struct UniformIndexMap
{
ConstString uniformName; ///< The uniform name
Hash uniformNameHashNoArray{0u};
int32_t arrayIndex{-1}; ///< The array index
- int16_t uniformLocation{0u};
- uint16_t uniformOffset{0u};
- uint16_t uniformBlockIndex{0u};
- bool initialized{false};
+ int16_t uniformLocation{0u};
+ uint16_t uniformOffset{0u};
+ uint16_t uniformSize{0u};
+ uint16_t uniformBlockIndex{0u};
+ FuncGetter uniformFunc{0};
};
StencilParameters mStencilParameters; ///< Struct containing all stencil related options
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(bool);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(int);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(float);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector2);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector3);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
OnSet();
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
-
/**
* Change the property value by a relative amount.
* @param[in] bufferIndex The buffer to write.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Matrix);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Matrix3);
- }
-
/**
* Set the property value. This will only persist for the current frame; the property
* will be reset with the base value, at the beginning of the next frame.
#define DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector3);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector3()
*/
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector4()
*/
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
*/
return mValue[bufferIndex];
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Matrix);
- }
-
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
*/
#define DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 mValue;
}
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue;
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector2);
- }
};
/**
{
return mValue;
}
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &mValue;
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(bool);
- }
};
} // namespace SceneGraph
return Get(bufferIndex);
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &GetVector3(bufferIndex);
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector3);
- }
-
const float& GetFloatComponent(uint32_t component) const override
{
return GetTxManagerData()->Manager()->GetVector3PropertyComponentValue(GetTxManagerData()->Id(), PropertyT, component);
{
return Get(bufferIndex);
}
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &Get(bufferIndex);
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
};
/**
return mValue;
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &GetVector3(bufferIndex);
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector3);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector3()
*/
return mValue;
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- return &GetQuaternion(bufferIndex);
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Vector4);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
*/
return Matrix::IDENTITY;
}
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueAddress()
- */
- const void* GetValueAddress(BufferIndex bufferIndex) const override
- {
- static const Matrix identityMatrix(Matrix::IDENTITY);
- auto transformManagerData = GetTxManagerData();
- auto id = transformManagerData->Id();
- if(id != INVALID_TRANSFORM_ID)
- {
- return &(transformManagerData->Manager()->GetWorldMatrix(id));
- }
- return &identityMatrix;
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetValueSize()
- */
- size_t GetValueSize() const override
- {
- return sizeof(Matrix);
- }
-
/**
* @copydoc Dali::PropertyInput::GetConstraintInputMatrix()
*/