#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>
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;
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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
${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
${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
)
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
*/
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
/**
* 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;
};
/**
/**
* @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;
}
/**
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()
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());
}
}
}
}
+
void RenderManager::InitializeScene(SceneGraph::Scene* scene)
{
scene->Initialize(*mImpl->CreateSceneContext());
: mRenderDataProvider(dataProvider),
mContext(nullptr),
mGeometry(geometry),
+ mProgramCache(nullptr),
mUniformIndexMap(),
mAttributesLocation(),
mUniformsHash(),
mBlendingOptions.SetBlendColor(blendColor);
}
-void Renderer::Initialize(Context& context)
+void Renderer::Initialize(Context& context, ProgramCache& programCache)
{
- mContext = &context;
+ mContext = &context;
+ mProgramCache = &programCache;
}
Renderer::~Renderer() = default;
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()));
class Context;
class Texture;
class Program;
+class ProgramCache;
namespace SceneGraph
{
* 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
Context* mContext;
Render::Geometry* mGeometry;
+ ProgramCache* mProgramCache;
+
struct UniformIndexMap
{
uint32_t uniformIndex; ///< The index of the cached location in the Program
{
Shader::Shader(Dali::Shader::Hint::Value& hints)
: mHints(hints),
- mProgram(nullptr),
mConnectionObservers()
{
AddUniformMapObserver(*this);
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)
// 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>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
- * @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
/**
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
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.");
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.
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.
{
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
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