From: Adeel Kazmi Date: Fri, 22 Jul 2022 13:30:35 +0000 (+0000) Subject: Merge "DALi Version 2.1.32" into devel/master X-Git-Tag: dali_2.1.33~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87bc33f1fbbedcc4fbabfecc37b9030d8a8dfae5;hp=d184afb1ae80e66d0776f944108e6fae8b981f33;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Merge "DALi Version 2.1.32" into devel/master --- diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h b/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h index 8569640..6c96e76 100644 --- a/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h +++ b/dali/devel-api/adaptor-framework/vector-animation-renderer-plugin.h @@ -36,6 +36,7 @@ class VectorAnimationRendererPlugin { public: using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType; + using VectorProperty = Dali::VectorAnimationRenderer::VectorProperty; /** * @brief Constructor @@ -138,6 +139,30 @@ public: virtual void InvalidateBuffer() = 0; /** + * @brief Sets property value for the specified keyPath. This keyPath can resolve to multiple contents. + * In that case, the callback's value will apply to all of them. + * + * @param[in] keyPath The key path used to target a specific content or a set of contents that will be updated. + * @param[in] property The property to set. + * @param[in] callback The callback what gets called every time the animation is rendered. + * @param[in] id The Id to specify the callback. It should be unique and will be passed when the callback is called. + * + * @note A callback of the following type may be used: + * id The id to specify the callback. + * property The property that represent what you are trying to change. + * frameNumber The current frame number. + * It returns a Property::Value to set according to the property type. + * + * @code + * Property::Value MyFunction(int32_t id, VectorProperty property, uint32_t frameNumber); + * @endcode + * + * The keypath should conatin object names separated by (.) and can handle globe(**) or wildchar(*). + * Ownership of the callback is passed onto this class. + */ + virtual void AddPropertyValueCallback(const std::string& keyPath, VectorProperty property, CallbackBase* callback, int32_t id) = 0; + + /** * @brief Connect to this signal to be notified when the texture upload is completed. * * @return The signal to connect to. diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp b/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp index 47d6368..5663e81 100644 --- a/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp +++ b/dali/devel-api/adaptor-framework/vector-animation-renderer.cpp @@ -108,6 +108,11 @@ void VectorAnimationRenderer::InvalidateBuffer() GetImplementation(*this).InvalidateBuffer(); } +void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPath, VectorProperty property, CallbackBase* callback, int32_t id) +{ + GetImplementation(*this).AddPropertyValueCallback(keyPath, property, callback, id); +} + VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal() { return GetImplementation(*this).UploadCompletedSignal(); diff --git a/dali/devel-api/adaptor-framework/vector-animation-renderer.h b/dali/devel-api/adaptor-framework/vector-animation-renderer.h index 956dc94..37cb214 100644 --- a/dali/devel-api/adaptor-framework/vector-animation-renderer.h +++ b/dali/devel-api/adaptor-framework/vector-animation-renderer.h @@ -46,6 +46,20 @@ class VectorAnimationRenderer; class DALI_ADAPTOR_API VectorAnimationRenderer : public BaseHandle { public: + enum class VectorProperty + { + FILL_COLOR, ///< Fill color of the object, Type Property::VECTOR3 + FILL_OPACITY, ///< Fill opacity of the object, Type Property::FLOAT + STROKE_COLOR, ///< Stroke color of the object, Type Property::VECTOR3 + STROKE_OPACTY, ///< Stroke opacity of the object, Type Property::FLOAT + STROKE_WIDTH, ///< Stroke width of the object, Type Property::FLOAT + TRANSFORM_ANCHOR, ///< Transform anchor of the Layer and Group object, Type Property::VECTOR2 + TRANSFORM_POSITION, ///< Transform position of the Layer and Group object, Type Property::VECTOR2 + TRANSFORM_SCALE, ///< Transform scale of the Layer and Group object, Type Property::VECTOR2 [0..100] + TRANSFORM_ROTATION, ///< Transform rotation of the Layer and Group object, Type Property::FLOAT [0..360] in degrees + TRANSFORM_OPACITY ///< Transform opacity of the Layer and Group object, Type Property::FLOAT + }; + /// @brief UploadCompleted signal type. using UploadCompletedSignalType = Signal; @@ -168,6 +182,30 @@ public: */ void InvalidateBuffer(); + /** + * @brief Sets property value for the specified keyPath. This keyPath can resolve to multiple contents. + * In that case, the callback's value will apply to all of them. + * + * @param[in] keyPath The key path used to target a specific content or a set of contents that will be updated. + * @param[in] property The property to set. + * @param[in] callback The callback that gets called every time the animation is rendered. + * @param[in] id The Id to specify the callback. It should be unique and will be passed when the callback is called. + * + * @note A callback of the following type may be used: + * id The id to specify the callback. + * property The property that represent what you are trying to change. + * frameNumber The current frame number. + * It returns a Property::Value to set according to the property type. + * + * @code + * Property::Value MyFunction(int32_t id, VectorProperty property, uint32_t frameNumber); + * @endcode + * + * The keypath should contain object names separated by (.) and can handle globe(**) or wildchar(*). + * Ownership of the callback is passed onto this class. + */ + void AddPropertyValueCallback(const std::string& keyPath, VectorProperty property, CallbackBase* callback, int32_t id); + public: // Signals /** * @brief Connect to this signal to be notified when the texture upload is completed. diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index 2456deb..b903c0c 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp @@ -659,14 +659,19 @@ void EglGraphicsController::ProcessTextureUpdateQueue() info.srcExtent2D.height != (createInfo.size.height / (1 << info.level))); auto* sourceBuffer = reinterpret_cast(source.memorySource.memory); + auto sourceStride = info.srcStride; std::vector tempBuffer; + if(mGlAbstraction->TextureRequiresConverting(srcFormat, destFormat, isSubImage)) { // Convert RGB to RGBA if necessary. - texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer); - sourceBuffer = &tempBuffer[0]; - srcFormat = destFormat; - srcType = GLES::GLTextureFormatType(createInfo.format).type; + if(texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcStride, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer)) + { + sourceBuffer = &tempBuffer[0]; + sourceStride = 0u; // Converted buffer compacted. make stride as 0. + srcFormat = destFormat; + srcType = GLES::GLTextureFormatType(createInfo.format).type; + } } // Calculate the maximum mipmap level for the texture @@ -682,7 +687,7 @@ void EglGraphicsController::ProcessTextureUpdateQueue() } mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1); - mGlAbstraction->PixelStorei(GL_UNPACK_ROW_LENGTH, info.srcStride); + mGlAbstraction->PixelStorei(GL_UNPACK_ROW_LENGTH, sourceStride); mCurrentContext->BindTexture(bindTarget, texture->GetTextureTypeId(), texture->GetGLTexture()); @@ -770,10 +775,11 @@ void EglGraphicsController::UpdateTextures(const std::vector& // TODO: using PBO with GLES3, this is just naive // oldschool way - char* stagingBuffer = reinterpret_cast(malloc(info.srcSize)); - std::copy(&reinterpret_cast(source.memorySource.memory)[info.srcOffset], - reinterpret_cast(source.memorySource.memory) + info.srcSize, - stagingBuffer); + uint8_t* stagingBuffer = reinterpret_cast(malloc(info.srcSize)); + + uint8_t* srcMemory = &reinterpret_cast(source.memorySource.memory)[info.srcOffset]; + + std::copy(srcMemory, srcMemory + info.srcSize, stagingBuffer); mTextureUploadTotalCPUMemoryUsed += info.srcSize; diff --git a/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp b/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp index aaafc0e..f7a2aef 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -51,18 +51,29 @@ struct ColorConversion void (*pConversionWriteFunc)(const void*, uint32_t, uint32_t, uint32_t, uint32_t, void*); }; -inline void WriteRGB32ToRGBA32(const void* pData, uint32_t sizeInBytes, uint32_t width, uint32_t height, uint32_t rowStride, void* pOutput) +inline void WriteRGB32ToRGBA32(const void* __restrict__ pData, uint32_t sizeInBytes, uint32_t width, uint32_t height, uint32_t rowStride, void* __restrict__ pOutput) { - auto inData = reinterpret_cast(pData); - auto outData = reinterpret_cast(pOutput); - auto outIdx = 0u; - for(auto i = 0u; i < sizeInBytes; i += 3) + const uint8_t* __restrict__ inData = reinterpret_cast(pData); + uint8_t* __restrict__ outData = reinterpret_cast(pOutput); + if(rowStride == 0u) { - outData[outIdx] = inData[i]; - outData[outIdx + 1] = inData[i + 1]; - outData[outIdx + 2] = inData[i + 2]; - outData[outIdx + 3] = 0xff; - outIdx += 4; + rowStride = width; + } + for(auto y = 0u; y < height; ++y) + { + auto inIdx = 0u; + auto outIdx = 0u; + for(auto x = 0u; x < width; ++x) + { + outData[outIdx] = inData[inIdx]; + outData[outIdx + 1] = inData[inIdx + 1]; + outData[outIdx + 2] = inData[inIdx + 2]; + outData[outIdx + 3] = 0xff; + outIdx += 4; + inIdx += 3; + } + inData += rowStride * 3u; + outData += width * 4u; } } @@ -380,7 +391,7 @@ void Texture::Prepare() * This function tests whether format is supported by the driver. If possible it applies * format conversion to suitable supported pixel format. */ -bool Texture::TryConvertPixelData(const void* pData, Graphics::Format srcFormat, Graphics::Format destFormat, uint32_t sizeInBytes, uint32_t width, uint32_t height, std::vector& outputBuffer) +bool Texture::TryConvertPixelData(const void* pData, Graphics::Format srcFormat, Graphics::Format destFormat, uint32_t sizeInBytes, uint32_t inStride, uint32_t width, uint32_t height, std::vector& outputBuffer) { // No need to convert if(srcFormat == destFormat) @@ -399,7 +410,7 @@ bool Texture::TryConvertPixelData(const void* pData, Graphics::Format srcFormat, } auto begin = reinterpret_cast(pData); - outputBuffer = std::move(it->pConversionFunc(begin, sizeInBytes, width, height, 0u)); + outputBuffer = std::move(it->pConversionFunc(begin, sizeInBytes, width, height, inStride)); return !outputBuffer.empty(); } diff --git a/dali/internal/graphics/gles-impl/gles-graphics-texture.h b/dali/internal/graphics/gles-impl/gles-graphics-texture.h index ee7b1c2..32df147 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-texture.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-texture.h @@ -2,7 +2,7 @@ #define DALI_GRAPHICS_GLES_TEXTURE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -129,12 +129,14 @@ public: /** * @param pData Input data * @param sizeInBytes Size of the input data in bytes - * @param width Width of the output buffer - * @param height height of the output buffer + * @param inStride Stride of the input data. + * @param width Width of the input/output buffer + * @param height Height of the intput/output buffer * @param outputBuffer The buffer to write to + * @note output Buffer will be packed without stride. * @return true if converted, or false otherwise */ - bool TryConvertPixelData(const void* pData, Graphics::Format srcFormat, Graphics::Format destFormat, uint32_t sizeInBytes, uint32_t width, uint32_t height, std::vector& outputBuffer); + bool TryConvertPixelData(const void* pData, Graphics::Format srcFormat, Graphics::Format destFormat, uint32_t sizeInBytes, uint32_t inStride, uint32_t width, uint32_t height, std::vector& outputBuffer); bool InitializeNativeImage(); diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp b/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp index 0116570..3ff18f2 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp +++ b/dali/internal/vector-animation/common/vector-animation-renderer-impl.cpp @@ -111,6 +111,11 @@ void VectorAnimationRenderer::InvalidateBuffer() mPlugin.InvalidateBuffer(); } +void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id) +{ + mPlugin.AddPropertyValueCallback(keyPath, property, callback, id); +} + Dali::VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal() { return mPlugin.UploadCompletedSignal(); diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-impl.h b/dali/internal/vector-animation/common/vector-animation-renderer-impl.h index 1924cf4..b9522cb 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-impl.h +++ b/dali/internal/vector-animation/common/vector-animation-renderer-impl.h @@ -103,6 +103,11 @@ public: void InvalidateBuffer(); /** + * @copydoc Dali::VectorAnimationRenderer::AddPropertyValueCallback() + */ + void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id); + + /** * @copydoc Dali::VectorAnimationRenderer::UploadCompletedSignal() */ Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal(); diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp index d5d0f0f..000c319 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp +++ b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.cpp @@ -195,6 +195,14 @@ void VectorAnimationRendererPluginProxy::InvalidateBuffer() } } +void VectorAnimationRendererPluginProxy::AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id) +{ + if(mPlugin) + { + mPlugin->AddPropertyValueCallback(keyPath, property, callback, id); + } +} + VectorAnimationRendererPlugin::UploadCompletedSignalType& VectorAnimationRendererPluginProxy::UploadCompletedSignal() { if(mPlugin) diff --git a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h index c71dc87..6537256 100644 --- a/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h +++ b/dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h @@ -99,6 +99,11 @@ public: void InvalidateBuffer(); /** + * @copydoc Dali::VectorAnimationRendererPlugin::AddPropertyValueCallback() + */ + void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id); + + /** * @copydoc Dali::VectorAnimationRendererPlugin::UploadCompletedSignal() */ VectorAnimationRendererPlugin::UploadCompletedSignalType& UploadCompletedSignal();