const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf";
const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf";
const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli";
+const char* TEST_DLI_EXERCISE_FILE_NAME = TEST_RESOURCE_DIR "/exercise.dli";
/**
* For the diffuse and specular cube map texture.
* These textures are based off version of Wave engine sample
END_TEST;
}
+int UtcDaliModelAnimation03(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME);
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t animationCount = model.GetAnimationCount();
+ DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION);
+
+ Animation animationByIndex = model.GetAnimation(0u);
+ DALI_TEST_CHECK(animationByIndex);
+
+ Animation animationByName = model.GetAnimation("idleClip");
+ DALI_TEST_CHECK(animationByName);
+ DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliModelMultiplePrimitives(void)
{
ToolkitTestApplication application;
void EnableVideoHole(bool enabled) override {}
bool SendHoverEvent(const HoverEvent& event) override { return false; }
bool SendWheelEvent(const WheelEvent& event) override { return false; }
- WebEngineFrameRenderedSignalType& FrameRenderedSignal() override { return frameRenderedSignal; }
+ void RegisterFrameRenderedCallback(WebEngineFrameRenderedCallback callback) override {}
void RegisterPageLoadStartedCallback(WebEnginePageLoadCallback callback) override {}
void RegisterPageLoadInProgressCallback(WebEnginePageLoadCallback callback) override {}
void RegisterPageLoadFinishedCallback(WebEnginePageLoadCallback callback) override {}
void RegisterConsoleMessageReceivedCallback(WebEngineConsoleMessageReceivedCallback callback) override {}
void RegisterResponsePolicyDecidedCallback(WebEngineResponsePolicyDecidedCallback callback) override {}
void RegisterNavigationPolicyDecidedCallback(WebEngineNavigationPolicyDecidedCallback callback) override {}
+ void RegisterNewWindowCreatedCallback(WebEngineNewWindowCreatedCallback callback) override {}
void RegisterCertificateConfirmedCallback(WebEngineCertificateCallback callback) override {}
void RegisterSslCertificateChangedCallback(WebEngineCertificateCallback callback) override {}
void RegisterHttpAuthHandlerCallback(WebEngineHttpAuthHandlerCallback callback) override {}
private:
MockWebEngineSettings settings;
MockWebEngineBackForwardList backForwardList;
- WebEngineFrameRenderedSignalType frameRenderedSignal;
};
Dali::WebEnginePlugin* GetWebEnginePlugin()
}
}
- Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal()
+ void RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
{
- return mFrameRenderedSignal;
+ mFrameRenderedCallback = callback;
}
void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
mNavigationPolicyDecisionCallback = callback;
}
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+ {
+ mNewWindowCreatedCallback = callback;
+ }
+
void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
mCertificateConfirmCallback = callback;
size_t mCurrentPlusOnePos;
std::string mUserAgent;
- Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType mFrameRenderedSignal;
-
bool mEvaluating;
float mPageZoomFactor;
float mTextZoomFactor;
Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback mConsoleMessageCallback;
Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback mResponsePolicyDecisionCallback;
Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback mNavigationPolicyDecisionCallback;
+ Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback mNewWindowCreatedCallback;
Dali::WebEnginePlugin::WebEngineCertificateCallback mCertificateConfirmCallback;
Dali::WebEnginePlugin::WebEngineCertificateCallback mSslCertificateChangedCallback;
Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback mHttpAuthHandlerCallback;
std::unique_ptr<Dali::WebEngineFormRepostDecision> repostDecision(new MockWebEngineFormRepostDecision());
gInstance->mFormRepostDecidedCallback(std::move(repostDecision));
}
- gInstance->mFrameRenderedSignal.Emit();
if (gInstance->mFrameRenderedCallback)
{
gInstance->mFrameRenderedCallback();
std::unique_ptr<Dali::WebEnginePolicyDecision> policyDecision(new MockWebEnginePolicyDecision());
gInstance->mNavigationPolicyDecisionCallback(std::move(policyDecision));
}
+ if (gInstance->mNewWindowCreatedCallback)
+ {
+ Dali::WebEnginePlugin* plugin = 0;
+ gInstance->mNewWindowCreatedCallback(plugin);
+ }
if (gInstance->mCertificateConfirmCallback)
{
std::unique_ptr<Dali::WebEngineCertificate> certificate(new MockWebEngineCertificate());
{
}
-Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
+void WebEngine::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
{
- return Internal::Adaptor::GetImplementation(*this).FrameRenderedSignal();
+ Internal::Adaptor::GetImplementation(*this).RegisterFrameRenderedCallback(callback);
}
void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
Internal::Adaptor::GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
}
+void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ Internal::Adaptor::GetImplementation(*this).RegisterNewWindowCreatedCallback(callback);
+}
+
void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
Internal::Adaptor::GetImplementation( *this ).RegisterCertificateConfirmedCallback(callback);
static std::unique_ptr<Dali::WebEngineConsoleMessage> gConsoleMessageInstance = nullptr;
static int gResponsePolicyDecidedCallbackCalled = 0;
static int gNavigationPolicyDecidedCallbackCalled = 0;
+static int gNewWindowCreatedCallbackCalled = 0;
static std::unique_ptr<Dali::WebEnginePolicyDecision> gResponsePolicyDecisionInstance = nullptr;
static int gCertificateConfirmCallbackCalled = 0;
static std::unique_ptr<Dali::WebEngineCertificate> gCertificateConfirmInstance = nullptr;
gNavigationPolicyDecidedCallbackCalled++;
}
+static void OnNewWindowCreated(Dali::WebEnginePlugin*& outPlugin)
+{
+ gNewWindowCreatedCallbackCalled++;
+ WebView newView = WebView::New();
+ outPlugin = newView.GetPlugin();
+}
+
static void OnUrlChanged(const std::string& url)
{
gUrlChangedCallbackCalled++;
END_TEST;
}
+int UtcDaliWebViewNewWindowCreated(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK(view);
+
+ // load url.
+ view.RegisterNewWindowCreatedCallback(&OnNewWindowCreated);
+ DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 0, TEST_LOCATION);
+
+ view.LoadUrl(TEST_URL1);
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_EQUALS(gNewWindowCreatedCallbackCalled, 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliWebViewHitTest(void)
{
ToolkitTestApplication application;
if(!animations.empty())
{
- auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property) {
- return mModelRoot.FindChildById(scene.GetNode(property.mNodeIndex)->mNodeId);
+ auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property)
+ {
+ Dali::Actor actor;
+ if(property.mNodeIndex != Scene3D::Loader::INVALID_INDEX)
+ {
+ auto* node = scene.GetNode(property.mNodeIndex);
+ if(node != nullptr)
+ {
+ actor = mModelRoot.FindChildById(node->mNodeId);
+ }
+ }
+ else
+ {
+ actor = mModelRoot.FindChildByName(property.mNodeName);
+ }
+ return actor;
};
mAnimations.clear();
NodeDefinition* SceneDefinition::GetNode(Index iNode)
{
- return mNodes[iNode].get();
+ if(iNode != Scene3D::Loader::INVALID_INDEX && iNode < mNodes.size())
+ {
+ return mNodes[iNode].get();
+ }
+ return nullptr;
}
void SceneDefinition::Visit(Index iNode, const Customization::Choices& choices, NodeDefinition::IVisitor& v)
return Dali::Toolkit::GetImpl(*this).GetBackForwardList();
}
+Dali::WebEnginePlugin* WebView::GetPlugin() const
+{
+ return Dali::Toolkit::GetImpl(*this).GetPlugin();
+}
+
Dali::Toolkit::ImageView WebView::GetFavicon() const
{
return Dali::Toolkit::GetImpl(*this).GetFavicon();
Dali::Toolkit::GetImpl(*this).RegisterNavigationPolicyDecidedCallback(callback);
}
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ Dali::Toolkit::GetImpl(*this).RegisterNewWindowCreatedCallback(callback);
+}
+
void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
Dali::Toolkit::GetImpl(*this).RegisterCertificateConfirmedCallback(callback);
namespace Dali
{
+class WebEngineContext;
+class WebEngineCookieManager;
+
namespace Toolkit
{
class ImageView;
class WebBackForwardList;
-class WebContext;
-class WebCookieManager;
class WebSettings;
namespace Internal DALI_INTERNAL
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @brief Gets web engine plugin.
+ */
+ Dali::WebEnginePlugin* GetPlugin() const;
+
+ /**
* @brief Get favicon of web page.
*
* @return Handle to a favicon
void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
/**
+ * @brief Callback to be called when a new window would be created.
+ *
+ * @param[in] callback
+ */
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+ /**
* @brief Callback to be called when certificate need be confirmed.
*
* @param[in] callback
#include "web-view-impl.h"
// EXTERNAL INCLUDES
+#include <cstring>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-back-forward-list.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-certificate.h>
#include <dali/devel-api/adaptor-framework/web-engine/web-engine-console-message.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/type-registry.h>
-#include <cstring>
-#include <memory>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/public-api/image-loader/image-url.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <functional>
+#include <memory>
+
namespace Dali
{
namespace Toolkit
} // namespace
-#define GET_ENUM_STRING(structName, inputExp) \
- Scripting::GetLinearEnumerationName<Toolkit::WebView::structName::Type>(static_cast<Toolkit::WebView::structName::Type>(inputExp), structName##_TABLE, structName##_TABLE_COUNT)
-
-#define GET_ENUM_VALUE(structName, inputExp, outputExp) \
- Scripting::GetEnumerationProperty<Toolkit::WebView::structName::Type>(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp)
-
std::unordered_map<Dali::WebEnginePlugin*, Dali::WeakHandle<Toolkit::WebView>> WebView::mPluginWebViewMap;
WebView::WebView(const std::string& locale, const std::string& timezoneId)
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
mKeyEventsEnabled(true),
- mScreenshotCapturedCallback(nullptr)
+ mScreenshotCapturedCallback{nullptr},
+ mFrameRenderedCallback{nullptr}
{
mWebEngine = Dali::WebEngine::New();
mVideoHoleEnabled(false),
mMouseEventsEnabled(true),
mKeyEventsEnabled(true),
- mScreenshotCapturedCallback(nullptr)
+ mScreenshotCapturedCallback{nullptr},
+ mFrameRenderedCallback{nullptr}
{
mWebEngine = Dali::WebEngine::New();
{
if(mWebEngine)
{
- mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnFrameRendered);
auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin());
if (iter != mPluginWebViewMap.end())
{
mPositionUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
mSizeUpdateNotification = self.AddPropertyNotification(Actor::Property::SIZE, StepCondition(1.0f, 1.0f));
mScaleUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_SCALE, StepCondition(0.1f, 1.0f));
- mPositionUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
- mSizeUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
- mScaleUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
+ mPositionUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
+ mSizeUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
+ mScaleUpdateNotification.NotifySignal().Connect(this, &WebView::OnDisplayAreaUpdated);
if(mWebEngine)
{
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
+ mWebEngine.RegisterFrameRenderedCallback(std::bind(&WebView::OnFrameRendered, this));
mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>(new WebSettings(mWebEngine.GetSettings()));
mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>(new WebBackForwardList(mWebEngine.GetBackForwardList()));
}
self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::FILLER);
}
-Dali::WebEnginePlugin* WebView::GetPlugin() const
-{
- return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
-}
-
DevelControl::ControlAccessible* WebView::CreateAccessibleObject()
{
return new WebViewAccessible(Self(), mWebEngine);
return mWebBackForwardList.get();
}
+Dali::WebEnginePlugin* WebView::GetPlugin() const
+{
+ return mWebEngine ? mWebEngine.GetPlugin() : nullptr;
+}
+
Dali::Toolkit::ImageView WebView::GetFavicon() const
{
Dali::Toolkit::ImageView faviconView;
{
if(mWebEngine)
{
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
mWebEngine.LoadUrl(url);
}
}
{
if(mWebEngine)
{
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
mWebEngine.LoadHtmlString(htmlString);
}
}
if(!mWebEngine)
return false;
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
return mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
}
if(!mWebEngine)
return false;
- if(!mVisual)
- {
- mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnInitialFrameRendered);
- }
-
return mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri);
}
}
}
-void WebView::UpdateDisplayArea(Dali::PropertyNotification& /*source*/)
-{
- if(!mWebEngine)
- return;
-
- Actor self(Self());
-
- bool positionUsesAnchorPoint = self.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
- Vector3 actorSize = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::SCALE);
- Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
- Vector2 screenPosition = self.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
-
- Dali::Rect<int32_t> displayArea;
- displayArea.x = screenPosition.x - anchorPointOffSet.x;
- displayArea.y = screenPosition.y - anchorPointOffSet.y;
- displayArea.width = actorSize.x;
- displayArea.height = actorSize.y;
-
- Size displaySize = Size(displayArea.width, displayArea.height);
- if(mWebViewSize != displaySize)
- {
- mWebViewSize = displaySize;
- }
-
- if(mWebViewArea != displayArea)
- {
- mWebViewArea = displayArea;
- mWebEngine.UpdateDisplayArea(mWebViewArea);
- }
-}
-
void WebView::EnableVideoHole(bool enabled)
{
mVideoHoleEnabled = enabled;
}
}
+void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+ if(mWebEngine)
+ {
+ mWebEngine.RegisterNewWindowCreatedCallback(callback);
+ }
+}
+
void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback)
{
if(mWebEngine)
{
mFrameRenderedCallback();
}
-}
-void WebView::OnInitialFrameRendered()
-{
- mWebEngine.FrameRenderedSignal().Disconnect(this, &WebView::OnInitialFrameRendered);
+ // Make sure that mVisual is created only once.
+ if (mVisual)
+ return;
Dali::Toolkit::ImageUrl nativeImageUrl = Dali::Toolkit::Image::GenerateUrl(mWebEngine.GetNativeImageSource());
mVisual = Toolkit::VisualFactory::Get().CreateVisual({{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE}, {Toolkit::ImageVisual::Property::URL, nativeImageUrl.GetUrl()}});
-
if(mVisual)
{
DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
}
}
+void WebView::OnDisplayAreaUpdated(Dali::PropertyNotification& /*source*/)
+{
+ if(!mWebEngine)
+ return;
+
+ Actor self(Self());
+
+ bool positionUsesAnchorPoint = self.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
+ Vector3 actorSize = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::SCALE);
+ Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+ Vector2 screenPosition = self.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+
+ Dali::Rect<int32_t> displayArea;
+ displayArea.x = screenPosition.x - anchorPointOffSet.x;
+ displayArea.y = screenPosition.y - anchorPointOffSet.y;
+ displayArea.width = actorSize.x;
+ displayArea.height = actorSize.y;
+
+ Size displaySize = Size(displayArea.width, displayArea.height);
+ if(mWebViewSize != displaySize)
+ {
+ mWebViewSize = displaySize;
+ }
+
+ if(mWebViewArea != displayArea)
+ {
+ mWebViewArea = displayArea;
+ mWebEngine.UpdateDisplayArea(mWebViewArea);
+ }
+}
+
void WebView::OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type)
{
if(type == Dali::DevelActor::VisibilityChange::Type::SELF)
OnChildrenChanged();
}
-#undef GET_ENUM_STRING
-#undef GET_ENUM_VALUE
-
} // namespace Internal
} // namespace Toolkit
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
+ * @copydoc Dali::Toolkit::WebView::GetPlugin()
+ */
+ Dali::WebEnginePlugin* GetPlugin() const;
+
+ /**
* @copydoc Dali::Toolkit::WebView::GetFavicon()
*/
Dali::Toolkit::ImageView GetFavicon() const;
void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
/**
+ * @copydoc Dali::Toolkit::WebView::RegisterNewWindowCreatedCallback()
+ */
+ void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+ /**
* @copydoc Dali::Toolkit::WebView::RegisterCertificateConfirmedCallback()
*/
void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback);
WebView& operator=(const WebView& webView);
/**
- * @brief Gets web engine plugin.
- */
- Dali::WebEnginePlugin* GetPlugin() const;
-
- /**
* @brief Set an absolute scroll of the given view.
* @param[in] x The coordinate x of scroll
* @param[in] y The coordinate y of scroll
bool SetVisibility(bool visible);
/**
- * @brief Update display area of web view.
- * @param[in] source The soource triggers Notification.
- */
- void UpdateDisplayArea(Dali::PropertyNotification& source);
-
- /**
* @brief Enable/Disable video hole for video playing.
* @param[in] enabled True if video hole is enabled, false otherwise.
*/
void OnFrameRendered();
/**
- * @brief Callback function to be called when frame is rendered. This is to check initial buffer is ready.
+ * @brief Callback for updating display area of web view.
+ * @param[in] source The soource triggers Notification.
*/
- void OnInitialFrameRendered();
+ void OnDisplayAreaUpdated(Dali::PropertyNotification& source);
/**
* @brief Callback function to be called when visibility is changed.
${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-manager.cpp
${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-task.cpp
${toolkit_src_dir}/visuals/animated-vector-image/vector-animation-thread.cpp
- ${toolkit_src_dir}/visuals/animated-vector-image/vector-rasterize-thread.cpp
${toolkit_src_dir}/visuals/arc/arc-visual.cpp
${toolkit_src_dir}/visuals/border/border-visual.cpp
${toolkit_src_dir}/visuals/color/color-visual.cpp
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
} // unnamed namespace
VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache)
-: mUrl(),
+: AsyncTask(MakeCallback(this, &VectorAnimationTask::TaskCompleted), AsyncTask::ThreadType::WORKER_THREAD),
+ mUrl(),
mVectorRenderer(VectorAnimationRenderer::New()),
mAnimationData(),
mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()),
mAnimationDataUpdated(false),
mDestroyTask(false),
mLoadRequest(false),
- mLoadFailed(false)
+ mLoadFailed(false),
+ mRasterized(false),
+ mKeepAnimation(false)
{
mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted);
}
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::~VectorAnimationTask: destructor [%p]\n", this);
}
+void VectorAnimationTask::Process()
+{
+ mRasterized = Rasterize();
+}
+
+bool VectorAnimationTask::IsReady()
+{
+ return true;
+}
+
void VectorAnimationTask::Finalize()
{
ConditionalWait::ScopedLock lock(mConditionalWait);
mDestroyTask = true;
}
+void VectorAnimationTask::TaskCompleted(VectorAnimationTaskPtr task)
+{
+ mVectorAnimationThread.OnTaskCompleted(task, task->IsRasterized(), task->IsAnimating());
+}
+
+bool VectorAnimationTask::IsRasterized()
+{
+ return mRasterized;
+}
+
+bool VectorAnimationTask::IsAnimating()
+{
+ return mKeepAnimation;
+}
+
bool VectorAnimationTask::Load(bool synchronousLoading)
{
if(!mVectorRenderer.Load(mUrl))
return mResourceReadySignal;
}
-bool VectorAnimationTask::Rasterize(bool& keepAnimation)
+bool VectorAnimationTask::Rasterize()
{
bool stopped = false;
uint32_t currentFrame;
- keepAnimation = false;
+ mKeepAnimation = false;
{
ConditionalWait::ScopedLock lock(mConditionalWait);
if(mPlayState != PlayState::PAUSED && mPlayState != PlayState::STOPPED)
{
- keepAnimation = true;
+ mKeepAnimation = true;
}
return true;
#define DALI_TOOLKIT_VECTOR_ANIMATION_TASK_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali/devel-api/adaptor-framework/event-thread-callback.h>
#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/public-api/adaptor-framework/async-task-manager.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/property-array.h>
#include <chrono>
/**
* The task of the vector animation.
*/
-class VectorAnimationTask : public RefObject, public ConnectionTracker
+class VectorAnimationTask : public AsyncTask, public ConnectionTracker
{
public:
enum class ResourceStatus
~VectorAnimationTask() override;
/**
+ * Process the task accodring to the type
+ */
+ void Process() override;
+
+ /**
+ * Whether the task is ready to process.
+ * @return True if the task is ready to process.
+ */
+ bool IsReady() override;
+
+ /**
* @brief Finalizes the task.
*/
void Finalize();
/**
* @brief Rasterizes the current frame.
- * @param[out] keepAnimation true if the animation is running, false otherwise.
* @return true if the rasterization succeeded, false otherwise.
*/
- bool Rasterize(bool& keepAnimation);
+ bool Rasterize();
/**
* @brief Calculates the time for the next frame rasterization.
*/
TimePoint GetNextFrameTime();
+ /**
+ * @brief Called when the rasterization is completed from the asyncTaskManager
+ * @param[in] task The completed task
+ */
+ void TaskCompleted(VectorAnimationTaskPtr task);
+
+ /**
+ * @brief Check the rasterization succeeded
+ * @return true if the rasterization succeeded, false otherwise.
+ */
+ bool IsRasterized();
+
+ /**
+ * @brief Check the animation is running
+ * @return true if the animation is running, false otherwise.
+ */
+ bool IsAnimating();
+
private:
/**
* @brief Loads the animation file.
bool mDestroyTask;
bool mLoadRequest;
bool mLoadFailed;
+ bool mRasterized;
+ bool mKeepAnimation;
};
} // namespace Internal
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
{
namespace
{
-constexpr auto DEFAULT_NUMBER_OF_RASTERIZE_THREADS = size_t{4u};
-constexpr auto NUMBER_OF_RASTERIZE_THREADS_ENV = "DALI_VECTOR_RASTERIZE_THREADS";
-
-size_t GetNumberOfThreads(const char* environmentVariable, size_t defaultValue)
-{
- using Dali::EnvironmentVariable::GetEnvironmentVariable;
- auto numberString = GetEnvironmentVariable(environmentVariable);
- auto numberOfThreads = numberString ? std::strtoul(numberString, nullptr, 10) : 0;
- constexpr auto MAX_NUMBER_OF_THREADS = 100u;
- DALI_ASSERT_DEBUG(numberOfThreads < MAX_NUMBER_OF_THREADS);
- return (numberOfThreads > 0 && numberOfThreads < MAX_NUMBER_OF_THREADS) ? numberOfThreads : defaultValue;
-}
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VECTOR_ANIMATION");
#endif
: mAnimationTasks(),
mCompletedTasks(),
mWorkingTasks(),
- mRasterizers(GetNumberOfThreads(NUMBER_OF_RASTERIZE_THREADS_ENV, DEFAULT_NUMBER_OF_RASTERIZE_THREADS), [&]() { return RasterizeHelper(*this); }),
mSleepThread(MakeCallback(this, &VectorAnimationThread::OnAwakeFromSleep)),
mConditionalWait(),
mNeedToSleep(false),
mDestroyThread(false),
mLogFactory(Dali::Adaptor::Get().GetLogFactory())
{
+ mAsyncTaskManager = Dali::AsyncTaskManager::Get();
mSleepThread.Start();
}
// DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationThread::Rasterize: [next time = %lld]\n", duration.count());
#endif
-
if(nextFrameTime <= currentTime)
{
// If the task is not in the working list
// Add it to the working list
mWorkingTasks.push_back(nextTask);
-
- auto rasterizerHelperIt = mRasterizers.GetNext();
- DALI_ASSERT_ALWAYS(rasterizerHelperIt != mRasterizers.End());
-
- rasterizerHelperIt->Rasterize(nextTask);
+ mAsyncTaskManager.AddTask(nextTask);
}
else
{
}
}
-VectorAnimationThread::RasterizeHelper::RasterizeHelper(VectorAnimationThread& animationThread)
-: RasterizeHelper(std::unique_ptr<VectorRasterizeThread>(new VectorRasterizeThread()), animationThread)
-{
-}
-
-VectorAnimationThread::RasterizeHelper::RasterizeHelper(RasterizeHelper&& rhs)
-: RasterizeHelper(std::move(rhs.mRasterizer), rhs.mAnimationThread)
-{
-}
-
-VectorAnimationThread::RasterizeHelper::RasterizeHelper(std::unique_ptr<VectorRasterizeThread> rasterizer, VectorAnimationThread& animationThread)
-: mRasterizer(std::move(rasterizer)),
- mAnimationThread(animationThread)
-{
- mRasterizer->SetCompletedCallback(MakeCallback(&mAnimationThread, &VectorAnimationThread::OnTaskCompleted));
-}
-
-void VectorAnimationThread::RasterizeHelper::Rasterize(VectorAnimationTaskPtr task)
-{
- if(task)
- {
- mRasterizer->AddTask(task);
- }
-}
-
VectorAnimationThread::SleepThread::SleepThread(CallbackBase* callback)
: mConditionalWait(),
mAwakeCallback(std::unique_ptr<CallbackBase>(callback)),
#define DALI_TOOLKIT_VECTOR_ANIMATION_THREAD_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <dali/devel-api/threading/conditional-wait.h>
#include <dali/devel-api/threading/thread.h>
#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
-#include <dali/public-api/signals/connection-tracker.h>
#include <dali/public-api/adaptor-framework/round-robin-container-view.h>
+#include <dali/public-api/signals/connection-tracker.h>
#include <memory>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
-#include <dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h>
namespace Dali
{
*/
void Rasterize();
-private:
- /**
- * @brief Helper class to keep the relation between VectorRasterizeThread and corresponding container
- */
- class RasterizeHelper : public ConnectionTracker
- {
- public:
- /**
- * @brief Create an RasterizeHelper.
- *
- * @param[in] animationThread Reference to the VectorAnimationThread
- */
- RasterizeHelper(VectorAnimationThread& animationThread);
-
- /**
- * @brief Rasterizes the task.
- *
- * @param[in] task The task to rasterize.
- */
- void Rasterize(VectorAnimationTaskPtr task);
-
- public:
- RasterizeHelper(const RasterizeHelper&) = delete;
- RasterizeHelper& operator=(const RasterizeHelper&) = delete;
-
- RasterizeHelper(RasterizeHelper&& rhs);
- RasterizeHelper& operator=(RasterizeHelper&& rhs) = delete;
-
- private:
- /**
- * @brief Main constructor that used by all other constructors
- */
- RasterizeHelper(std::unique_ptr<VectorRasterizeThread> rasterizer, VectorAnimationThread& animationThread);
-
- private:
- std::unique_ptr<VectorRasterizeThread> mRasterizer;
- VectorAnimationThread& mAnimationThread;
- };
-
/**
* @brief The thread to sleep until the next frame time.
*/
VectorAnimationThread& operator=(const VectorAnimationThread& thread) = delete;
private:
- std::vector<VectorAnimationTaskPtr> mAnimationTasks;
- std::vector<VectorAnimationTaskPtr> mCompletedTasks;
- std::vector<VectorAnimationTaskPtr> mWorkingTasks;
- RoundRobinContainerView<RasterizeHelper> mRasterizers;
- SleepThread mSleepThread;
- ConditionalWait mConditionalWait;
- bool mNeedToSleep;
- bool mDestroyThread;
- const Dali::LogFactoryInterface& mLogFactory;
+ std::vector<VectorAnimationTaskPtr> mAnimationTasks;
+ std::vector<VectorAnimationTaskPtr> mCompletedTasks;
+ std::vector<VectorAnimationTaskPtr> mWorkingTasks;
+ SleepThread mSleepThread;
+ ConditionalWait mConditionalWait;
+ bool mNeedToSleep;
+ bool mDestroyThread;
+ const Dali::LogFactoryInterface& mLogFactory;
+ Dali::AsyncTaskManager mAsyncTaskManager;
};
} // namespace Internal
+++ /dev/null
-/*
- * 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.
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h>
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/thread-settings.h>
-#include <dali/integration-api/adaptor-framework/adaptor.h>
-#include <dali/integration-api/debug.h>
-#include <chrono>
-#include <thread>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-namespace
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VECTOR_ANIMATION");
-#endif
-
-} // unnamed namespace
-
-VectorRasterizeThread::VectorRasterizeThread()
-: mRasterizeTasks(),
- mConditionalWait(),
- mCompletedCallback(),
- mDestroyThread(false),
- mIsThreadStarted(false),
- mLogFactory(Dali::Adaptor::Get().GetLogFactory())
-{
-}
-
-VectorRasterizeThread::~VectorRasterizeThread()
-{
- // Stop the thread
- {
- ConditionalWait::ScopedLock lock(mConditionalWait);
- mDestroyThread = true;
- mConditionalWait.Notify(lock);
- }
-
- DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::~VectorRasterizeThread: Join [%p]\n", this);
-
- Join();
-}
-
-void VectorRasterizeThread::SetCompletedCallback(CallbackBase* callback)
-{
- ConditionalWait::ScopedLock lock(mConditionalWait);
-
- mCompletedCallback = std::unique_ptr<CallbackBase>(callback);
-}
-
-void VectorRasterizeThread::AddTask(VectorAnimationTaskPtr task)
-{
- // Lock while adding task to the queue
- ConditionalWait::ScopedLock lock(mConditionalWait);
-
- if(!mIsThreadStarted)
- {
- Start();
- mIsThreadStarted = true;
- }
-
- if(mRasterizeTasks.end() == std::find(mRasterizeTasks.begin(), mRasterizeTasks.end(), task))
- {
- mRasterizeTasks.push_back(task);
-
- // wake up the animation thread
- mConditionalWait.Notify(lock);
- }
-}
-
-void VectorRasterizeThread::Run()
-{
- SetThreadName("VectorRasterizeThread");
- mLogFactory.InstallLogFunction();
-
- while(!mDestroyThread)
- {
- Rasterize();
- }
-}
-
-void VectorRasterizeThread::Rasterize()
-{
- VectorAnimationTaskPtr nextTask;
- {
- // Lock while popping task out from the queue
- ConditionalWait::ScopedLock lock(mConditionalWait);
-
- // conditional wait
- if(mRasterizeTasks.empty())
- {
- mConditionalWait.Wait(lock);
- }
-
- // pop out the next task from the queue
- if(!mRasterizeTasks.empty())
- {
- std::vector<VectorAnimationTaskPtr>::iterator next = mRasterizeTasks.begin();
- nextTask = *next;
- mRasterizeTasks.erase(next);
- }
- }
-
- if(nextTask)
- {
- bool keepAnimation;
- bool success = nextTask->Rasterize(keepAnimation);
-
- if(mCompletedCallback)
- {
- CallbackBase::Execute(*mCompletedCallback, nextTask, success, keepAnimation);
- }
- }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H
-#define DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_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.
- */
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/threading/conditional-wait.h>
-#include <dali/devel-api/threading/thread.h>
-#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
-#include <memory>
-#include <vector>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-/**
- * The worker thread for vector image rasterization.
- */
-class VectorRasterizeThread : public Thread
-{
-public:
- /**
- * @brief Constructor.
- */
- VectorRasterizeThread();
-
- /**
- * @brief Destructor.
- */
- ~VectorRasterizeThread() override;
-
- /**
- * The callback is called from the rasterize thread after the rasterization is completed.
- * @param[in] callBack The function to call.
- */
- void SetCompletedCallback(CallbackBase* callback);
-
- /**
- * Add a task to rasterize.
- *
- * @param[in] task The task to rasterize
- */
- void AddTask(VectorAnimationTaskPtr task);
-
-protected:
- /**
- * @brief The entry function of the worker thread.
- * It rasterizes the vector image.
- */
- void Run() override;
-
-private:
- /**
- * Rasterizes the tasks.
- */
- void Rasterize();
-
-private:
- // Undefined
- VectorRasterizeThread(const VectorRasterizeThread& thread) = delete;
-
- // Undefined
- VectorRasterizeThread& operator=(const VectorRasterizeThread& thread) = delete;
-
-private:
- std::vector<VectorAnimationTaskPtr> mRasterizeTasks;
- ConditionalWait mConditionalWait;
- std::unique_ptr<CallbackBase> mCompletedCallback;
- bool mDestroyThread; ///< Whether the thread be destroyed
- bool mIsThreadStarted;
- const Dali::LogFactoryInterface& mLogFactory; ///< The log factory
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 7;
+const unsigned int TOOLKIT_MICRO_VERSION = 8;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.2.7
+Version: 2.2.8
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT