Merge branch 'devel/master' into tizen
authorWoochanlee <wc0917.lee@samsung.com>
Tue, 16 Feb 2021 04:15:36 +0000 (13:15 +0900)
committerWoochanlee <wc0917.lee@samsung.com>
Tue, 16 Feb 2021 04:15:36 +0000 (13:15 +0900)
16 files changed:
automated-tests/src/dali/utc-Dali-Animation.cpp
dali/devel-api/animation/key-frames-devel.cpp [new file with mode: 0644]
dali/devel-api/animation/key-frames-devel.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/event/animation/key-frames-impl.cpp
dali/internal/event/animation/key-frames-impl.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/render/shaders/scene-graph-shader.cpp
dali/internal/render/shaders/scene-graph-shader.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/public-api/dali-core-version.cpp
packaging/dali.spec

index d453600..1f28227 100644 (file)
@@ -18,6 +18,7 @@
 #include <dali-test-suite-utils.h>
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/animation/animation-devel.h>
+#include <dali/devel-api/animation/key-frames-devel.h>
 #include <dali/public-api/dali-core.h>
 #include <stdlib.h>
 
@@ -9187,6 +9188,48 @@ int UtcDaliAnimationKeyFrames07N(void)
   END_TEST;
 }
 
+int UtcDaliAnimationKeyFramesGetKeyFrameCountP(void)
+{
+  TestApplication application;
+
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
+  keyFrames.Add(0.6f, Vector4(0.0f, 0.0f, 0.0f, 0.3f));
+  keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
+
+  DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliAnimationKeyFramesGetKeyFrameP(void)
+{
+  TestApplication application;
+
+  float inputTime = 0.6f;
+  Vector4 inputValue = Vector4(0.0f, 0.0f, 0.0f, 0.3f);
+
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
+  keyFrames.Add(inputTime, inputValue);
+  keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
+
+  float outputTime;
+  Property::Value outputValue;
+
+  DevelKeyFrames::GetKeyFrame(keyFrames, 3, outputTime, outputValue);
+
+  DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::NONE, TEST_LOCATION);
+
+  DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+  DALI_TEST_EQUALS(outputTime, inputTime, TEST_LOCATION);
+  DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::VECTOR4, TEST_LOCATION);
+  DALI_TEST_EQUALS(outputValue.Get<Vector4>(), inputValue, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
 {
   TestApplication application;
diff --git a/dali/devel-api/animation/key-frames-devel.cpp b/dali/devel-api/animation/key-frames-devel.cpp
new file mode 100644 (file)
index 0000000..f94c6b6
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/animation/key-frames-devel.h>
+#include <dali/internal/event/animation/key-frames-impl.h>
+
+namespace Dali
+{
+namespace DevelKeyFrames
+{
+
+std::size_t GetKeyFrameCount(KeyFrames keyFrames)
+{
+  return GetImplementation(keyFrames).GetKeyFrameCount();
+}
+
+void GetKeyFrame(KeyFrames keyFrames, std::size_t index, float& time, Property::Value& value)
+{
+  GetImplementation(keyFrames).GetKeyFrame(index, time, value);
+}
+
+} // namespace DevelKeyFrames
+
+} // namespace Dali
diff --git a/dali/devel-api/animation/key-frames-devel.h b/dali/devel-api/animation/key-frames-devel.h
new file mode 100644 (file)
index 0000000..a24e48e
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef DALI_KEY_FRAMES_DEVEL_H
+#define DALI_KEY_FRAMES_DEVEL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/animation/key-frames.h>
+
+namespace Dali
+{
+namespace DevelKeyFrames
+{
+using ValueConvertor = Property::Value (*)(const Property::Value& input);
+
+/**
+ * @brief Get the number of key frames.
+ * @param[in] keyFrames The KeyFrames object to perform this operation on
+ * @return Total number of key frames
+ */
+DALI_CORE_API std::size_t GetKeyFrameCount(KeyFrames keyFrames);
+
+/**
+ * Get a key frame.
+ * @param[in] keyFrames The KeyFrames object to perform this operation on
+ * @param[in] index The index of the key frame to fetch
+ * @param[out] time The progress of the given key frame
+ * @param[out] value The value of the given key frame
+ */
+DALI_CORE_API void GetKeyFrame(KeyFrames keyFrames, std::size_t index, float& time, Property::Value& value);
+
+} // namespace DevelKeyFrames
+
+} // namespace Dali
+
+#endif // DALI_KEY_FRAMES_DEVEL_H
index 1973073..c28900e 100644 (file)
@@ -7,6 +7,7 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/actors/custom-actor-devel.cpp
   ${devel_api_src_dir}/animation/animation-data.cpp
   ${devel_api_src_dir}/animation/animation-devel.cpp
+  ${devel_api_src_dir}/animation/key-frames-devel.cpp
   ${devel_api_src_dir}/animation/path-constrainer.cpp
   ${devel_api_src_dir}/common/addon-binder.cpp
   ${devel_api_src_dir}/common/capabilities.cpp
@@ -59,6 +60,7 @@ SET( devel_api_core_animation_header_files
   ${devel_api_src_dir}/animation/animation-data.h
   ${devel_api_src_dir}/animation/path-constrainer.h
   ${devel_api_src_dir}/animation/animation-devel.h
+  ${devel_api_src_dir}/animation/key-frames-devel.h
 )
 
 
index b7bfda3..bd486e5 100644 (file)
@@ -157,11 +157,25 @@ Property::Value KeyFrames::GetLastKeyFrameValue() const
   std::size_t noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames();
   if(noOfKeyFrames)
   {
-    mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, value);
+    float time;
+    mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, time, value);
   }
 
   return value;
 }
 
+std::size_t KeyFrames::GetKeyFrameCount() const
+{
+  return mKeyFrames->GetNumberOfKeyFrames();
+}
+
+void KeyFrames::GetKeyFrame(std::size_t index, float& time, Property::Value& value) const
+{
+  if(index < mKeyFrames->GetNumberOfKeyFrames())
+  {
+    mKeyFrames->GetKeyFrameAsValue(index, time, value);
+  }
+}
+
 } // namespace Internal
 } // namespace Dali
index 1c4dc45..919fedf 100644 (file)
@@ -82,6 +82,16 @@ public:
    */
   Dali::Property::Value GetLastKeyFrameValue() const;
 
+  /**
+   * @copydoc Dali::DevelKeyFrames::GetKeyFrameCount()
+   */
+  std::size_t GetKeyFrameCount() const;
+
+  /**
+   * @copydoc Dali::DevelKeyFrames::GetKeyFrame()
+   */
+  void GetKeyFrame(std::size_t index, float& time, Property::Value& value) const;
+
 private:
   Dali::Property::Type          mType{Property::NONE}; // Type of the specialization
   std::unique_ptr<KeyFrameSpec> mKeyFrames;            // Pointer to the specialized key frame object
@@ -101,9 +111,10 @@ public:
   /**
    * Get the key frame value as a Property::Value.
    * @param[in] index The index of the key frame to fetch
+   * @param[out] time The progress of the given key frame
    * @param[out] value The value of the given key frame
    */
-  virtual void GetKeyFrameAsValue(std::size_t index, Property::Value& value) = 0;
+  virtual void GetKeyFrameAsValue(std::size_t index, float& time, Property::Value& value) const = 0;
 };
 
 /**
@@ -153,9 +164,11 @@ public:
   /**
    * @copydoc KeyFrameSpec::GetKeyFrameAsValue()
    */
-  void GetKeyFrameAsValue(std::size_t index, Property::Value& value) override
+  void GetKeyFrameAsValue(std::size_t index, float& time, Property::Value& value) const override
   {
-    value = mChannel.mValues[index].mValue;
+    const auto& element = mChannel.mValues[index];
+    time                = element.mProgress;
+    value               = element.mValue;
   }
 
   /**
index c8b399a..ecf2894 100644 (file)
@@ -203,10 +203,8 @@ void Shader::SetShader(std::string_view          vertexSource,
   size_t              shaderHash;
   mShaderData = shaderFactory.Load(vertexSource, fragmentSource, hints, shaderHash);
 
-  // Add shader program to scene-object using a message to the UpdateManager
-  EventThreadServices&       eventThreadServices = GetEventThreadServices();
-  SceneGraph::UpdateManager& updateManager       = eventThreadServices.GetUpdateManager();
-  SetShaderProgramMessage(updateManager, GetShaderSceneObject(), mShaderData, (hints & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
+  // Add shader data to scene-object
+  SceneGraph::SetShaderDataMessage(GetEventThreadServices(), GetShaderSceneObject(), mShaderData);
 }
 
 Shader::~Shader()
index 32b6c81..ab3548d 100644 (file)
@@ -247,7 +247,7 @@ void RenderManager::SetShaderSaver(ShaderSaver& upstream)
 void RenderManager::AddRenderer(OwnerPointer<Render::Renderer>& renderer)
 {
   // Initialize the renderer as we are now in render thread
-  renderer->Initialize(mImpl->context);
+  renderer->Initialize(mImpl->context, mImpl->programController);
 
   mImpl->rendererContainer.PushBack(renderer.Release());
 }
@@ -335,6 +335,7 @@ void RenderManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer)
     }
   }
 }
+
 void RenderManager::InitializeScene(SceneGraph::Scene* scene)
 {
   scene->Initialize(*mImpl->CreateSceneContext());
index cea62ab..1ffc12f 100644 (file)
@@ -130,6 +130,7 @@ Renderer::Renderer(SceneGraph::RenderDataProvider* dataProvider,
 : mRenderDataProvider(dataProvider),
   mContext(nullptr),
   mGeometry(geometry),
+  mProgramCache(nullptr),
   mUniformIndexMap(),
   mAttributesLocation(),
   mUniformsHash(),
@@ -154,9 +155,10 @@ Renderer::Renderer(SceneGraph::RenderDataProvider* dataProvider,
   mBlendingOptions.SetBlendColor(blendColor);
 }
 
-void Renderer::Initialize(Context& context)
+void Renderer::Initialize(Context& context, ProgramCache& programCache)
 {
-  mContext = &context;
+  mContext      = &context;
+  mProgramCache = &programCache;
 }
 
 Renderer::~Renderer() = default;
@@ -585,8 +587,11 @@ void Renderer::Render(Context&                                             conte
     return;
   }
 
-  // Get the program to use:
-  Program* program = mRenderDataProvider->GetShader().GetProgram();
+  // Get the program to use
+  // The program cache owns the Program object so we don't need to worry about this raw allocation here.
+  ShaderDataPtr shaderData = mRenderDataProvider->GetShader().GetShaderData();
+  Program*      program    = Program::New(*mProgramCache, shaderData, (shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
+
   if(!program)
   {
     DALI_LOG_ERROR("Failed to get program for shader at address %p.\n", reinterpret_cast<void*>(&mRenderDataProvider->GetShader()));
index d6668a1..b62bd78 100644 (file)
@@ -39,6 +39,7 @@ namespace Internal
 class Context;
 class Texture;
 class Program;
+class ProgramCache;
 
 namespace SceneGraph
 {
@@ -165,8 +166,9 @@ public:
    * Second-phase construction.
    * This is called when the renderer is inside render thread
    * @param[in] context Context used by the renderer
+   * @param[in] programCache Cache of program objects
    */
-  void Initialize(Context& context);
+  void Initialize(Context& context, ProgramCache& programCache);
 
   /**
    * Destructor
@@ -446,6 +448,8 @@ private:
   Context*          mContext;
   Render::Geometry* mGeometry;
 
+  ProgramCache* mProgramCache;
+
   struct UniformIndexMap
   {
     uint32_t                 uniformIndex; ///< The index of the cached location in the Program
index e6eb761..c3a35da 100644 (file)
@@ -33,7 +33,6 @@ namespace SceneGraph
 {
 Shader::Shader(Dali::Shader::Hint::Value& hints)
 : mHints(hints),
-  mProgram(nullptr),
   mConnectionObservers()
 {
   AddUniformMapObserver(*this);
@@ -44,24 +43,18 @@ Shader::~Shader()
   mConnectionObservers.Destroy(*this);
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// The following methods are called during RenderManager::Render()
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void Shader::SetProgram(Internal::ShaderDataPtr shaderData,
-                        ProgramCache*           programCache,
-                        bool                    modifiesGeometry)
+void Shader::SetShaderData(ShaderDataPtr shaderData)
 {
   DALI_LOG_TRACE_METHOD_FMT(Debug::Filter::gShader, "%d\n", shaderData->GetHashValue());
 
-  mProgram = Program::New(*programCache, shaderData, modifiesGeometry);
-  // The program cache owns the Program object so we don't need to worry about this raw allocation here.
+  mShaderData = shaderData;
 
   mConnectionObservers.ConnectionsChanged(*this);
 }
 
-Program* Shader::GetProgram()
+ShaderDataPtr Shader::GetShaderData() const
 {
-  return mProgram;
+  return mShaderData;
 }
 
 void Shader::AddConnectionObserver(ConnectionChangePropagator::Observer& observer)
index 4b6bda6..6e25894 100644 (file)
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/common/shader-data.h>
+#include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 
@@ -95,21 +96,16 @@ public:
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
   /**
-   * @brief Set the program for this shader.
-   * @param[in] shaderData        The program's vertex/fragment source and optionally precompiled shader binary.
-   * @param[in] programCache      Owner of the Programs.
-   * @param[in] modifiesGeometry  True if the vertex shader changes the positions of vertexes such that
-   * they might exceed the bounding box of vertexes passing through the default transformation.
+   * @brief Set the shader data for this shader.
+   * @param[in] shaderData The program's vertex/fragment source and optionally pre-compiled shader binary.
    */
-  void SetProgram(Internal::ShaderDataPtr shaderData,
-                  ProgramCache*           programCache,
-                  bool                    modifiesGeometry);
+  void SetShaderData(ShaderDataPtr shaderData);
 
   /**
-   * Get the program built for this shader
-   * @return The program built from the shader sources.
+   * Get the shader data for this shader.
+   * @return The shader data.
    */
-  Program* GetProgram();
+  ShaderDataPtr GetShaderData() const;
 
 public: // Implementation of ConnectionChangePropagator
   /**
@@ -131,11 +127,22 @@ public: // UniformMap::Observer
 private: // Data
   Dali::Shader::Hint::Value mHints;
 
-  Program* mProgram;
+  ShaderDataPtr mShaderData;
 
   ConnectionChangePropagator mConnectionObservers;
 };
 
+inline void SetShaderDataMessage(EventThreadServices& eventThreadServices, const Shader& shader, ShaderDataPtr shaderData)
+{
+  using LocalType = MessageValue1<Shader, ShaderDataPtr>;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new(slot) LocalType(&shader, &Shader::SetShaderData, shaderData);
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal
index fa8d9cd..b082a9c 100644 (file)
@@ -582,22 +582,6 @@ void UpdateManager::RemoveShader(Shader* shader)
   EraseUsingDiscardQueue(mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
 }
 
-void UpdateManager::SetShaderProgram(Shader*                 shader,
-                                     Internal::ShaderDataPtr shaderData,
-                                     bool                    modifiesGeometry)
-{
-  if(shaderData)
-  {
-    using DerivedType = MessageValue3<Shader, Internal::ShaderDataPtr, ProgramCache*, bool>;
-
-    // Reserve some memory inside the render queue
-    uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
-
-    // Construct message in the render queue memory; note that delete should not be called on the return value
-    new(slot) DerivedType(shader, &Shader::SetProgram, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry);
-  }
-}
-
 void UpdateManager::SaveBinary(Internal::ShaderDataPtr shaderData)
 {
   DALI_ASSERT_DEBUG(shaderData && "No NULL shader data pointers please.");
index a63cf22..29d0e0f 100644 (file)
@@ -300,12 +300,11 @@ public:
   void RemoveShader(Shader* shader);
 
   /**
-   * Set the shader program for a Shader object
+   * Set the shader data for a Shader object
    * @param[in] shader        The shader to modify
    * @param[in] shaderData    Source code, hash over source, and optional compiled binary for the shader program
-   * @param[in] modifiesGeometry True if the vertex shader modifies geometry
    */
-  void SetShaderProgram(Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry);
+  void SetShaderData(Shader* shader, Internal::ShaderDataPtr shaderData);
 
   /**
    * @brief Accept compiled shaders passed back on render thread for saving.
@@ -1016,20 +1015,6 @@ inline void RemoveShaderMessage(UpdateManager& manager, const Shader* shader)
   new(slot) LocalType(&manager, &UpdateManager::RemoveShader, const_cast<Shader*>(shader));
 }
 
-inline void SetShaderProgramMessage(UpdateManager&          manager,
-                                    const Shader&           shader,
-                                    Internal::ShaderDataPtr shaderData,
-                                    bool                    modifiesGeometry)
-{
-  using LocalType = MessageValue3<UpdateManager, Shader*, Internal::ShaderDataPtr, bool>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = manager.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&manager, &UpdateManager::SetShaderProgram, const_cast<Shader*>(&shader), shaderData, modifiesGeometry);
-}
-
 inline void SurfaceReplacedMessage(UpdateManager& manager, const SceneGraph::Scene& constScene)
 {
   // The scene-graph thread owns this object so it can safely edit it.
index 58c6c2c..5409b39 100644 (file)
@@ -27,7 +27,7 @@ namespace Dali
 {
 const uint32_t    CORE_MAJOR_VERSION = 2;
 const uint32_t    CORE_MINOR_VERSION = 0;
-const uint32_t    CORE_MICRO_VERSION = 12;
+const uint32_t    CORE_MICRO_VERSION = 13;
 const char* const CORE_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index d8e67af..4158ad8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2
 Summary:    DALi 3D Engine
-Version:    2.0.12
+Version:    2.0.13
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT