/*
- * Copyright (c) 2020 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.
application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, time));
}
+void TestTriggerTap(TestApplication& application)
+{
+ application.GetPlatform().TriggerTimer();
+}
+
void TestGenerateTap(TestApplication& application, float x, float y, uint32_t time_down)
{
application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(x, y), time_down));
application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(x, y), time_down + 20));
+ TestTriggerTap(application);
}
void TestGenerateTwoPointTap(TestApplication& application, float x1, float y1, float x2, float y2, uint32_t time_down)
{
application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(x1, y1), PointState::DOWN, Vector2(x2, y2), time_down));
application.ProcessEvent(GenerateDoubleTouch(PointState::UP, Vector2(x1, y1), PointState::UP, Vector2(x2, y2), time_down + 20));
+ TestTriggerTap(application);
}
void TestGenerateRotation(TestApplication& application)
#define DALI_TEST_GESTURE_GENERATOR_H
/*
- * Copyright (c) 2020 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.
void TestEndPan(TestApplication& application, Vector2 pos, uint32_t time = 500);
/**
+ * Triggers the timer to begin a tap gesture
+ */
+void TestTriggerTap(TestApplication& application);
+
+/**
* Produces a single point tap gesture with a 20ms interval
*/
void TestGenerateTap(TestApplication& application, float x = 20.0f, float y = 20.0f, uint32_t time_down = 100);
return true;
}
-std::vector<Dali::Graphics::UniformInfo> TestGraphicsReflection::GetSamplers() const
+const std::vector<Dali::Graphics::UniformInfo>& TestGraphicsReflection::GetSamplers() const
{
- return std::vector<Dali::Graphics::UniformInfo>{};
+ static std::vector<Dali::Graphics::UniformInfo> samplers{};
+ return samplers;
}
Graphics::ShaderLanguage TestGraphicsReflection::GetLanguage() const
public:
TestGraphicsReflection(TestGlAbstraction& gl, Property::Array& vertexFormats, const Graphics::ProgramCreateInfo& createInfo, std::vector<UniformData>& customUniforms);
- uint32_t GetVertexAttributeLocation(const std::string& name) const override;
- Dali::Graphics::VertexInputAttributeFormat GetVertexAttributeFormat(uint32_t location) const override;
- std::string GetVertexAttributeName(uint32_t location) const override;
- std::vector<uint32_t> GetVertexAttributeLocations() const override;
- uint32_t GetUniformBlockCount() const override;
- uint32_t GetUniformBlockBinding(uint32_t index) const override;
- uint32_t GetUniformBlockSize(uint32_t index) const override;
- bool GetUniformBlock(uint32_t index, Dali::Graphics::UniformBlockInfo& out) const override;
- std::vector<uint32_t> GetUniformBlockLocations() const override;
- std::string GetUniformBlockName(uint32_t blockIndex) const override;
- uint32_t GetUniformBlockMemberCount(uint32_t blockIndex) const override;
- std::string GetUniformBlockMemberName(uint32_t blockIndex, uint32_t memberLocation) const override;
- uint32_t GetUniformBlockMemberOffset(uint32_t blockIndex, uint32_t memberLocation) const override;
- bool GetNamedUniform(const std::string& name, Dali::Graphics::UniformInfo& out) const override;
- std::vector<Dali::Graphics::UniformInfo> GetSamplers() const override;
- Graphics::ShaderLanguage GetLanguage() const override;
+ uint32_t GetVertexAttributeLocation(const std::string& name) const override;
+ Dali::Graphics::VertexInputAttributeFormat GetVertexAttributeFormat(uint32_t location) const override;
+ std::string GetVertexAttributeName(uint32_t location) const override;
+ std::vector<uint32_t> GetVertexAttributeLocations() const override;
+ uint32_t GetUniformBlockCount() const override;
+ uint32_t GetUniformBlockBinding(uint32_t index) const override;
+ uint32_t GetUniformBlockSize(uint32_t index) const override;
+ bool GetUniformBlock(uint32_t index, Dali::Graphics::UniformBlockInfo& out) const override;
+ std::vector<uint32_t> GetUniformBlockLocations() const override;
+ std::string GetUniformBlockName(uint32_t blockIndex) const override;
+ uint32_t GetUniformBlockMemberCount(uint32_t blockIndex) const override;
+ std::string GetUniformBlockMemberName(uint32_t blockIndex, uint32_t memberLocation) const override;
+ uint32_t GetUniformBlockMemberOffset(uint32_t blockIndex, uint32_t memberLocation) const override;
+ bool GetNamedUniform(const std::string& name, Dali::Graphics::UniformInfo& out) const override;
+ const std::vector<Dali::Graphics::UniformInfo>& GetSamplers() const override;
+ Graphics::ShaderLanguage GetLanguage() const override;
public: // Test methods
void SetAttributes(std::vector<std::string> locations)
END_TEST;
}
-int UtcDaliLongPressGestureInterruptedWhenTouchConsumed(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- application.GetScene().Add(actor);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- LongPressGestureDetector detector = LongPressGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the gesture as the touch is NOT being consumed
- TestGenerateLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- data.Reset();
- TestEndLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- data.Reset();
-
- // Another gesture in the same location, this time we will not receive it as touch is being consumed
- consume = true;
- TestGenerateLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
- data.Reset();
- TestEndLongPress(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
-
- END_TEST;
-}
-
int UtcDaliLongPressGestureDisableDetectionDuringLongPressN(void)
{
// Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
END_TEST;
}
-int UtcDaliPanGestureInterruptedWhenTouchConsumed(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- application.GetScene().Add(actor);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- PanGestureDetector detector = PanGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the pan as the touch is NOT being consumed
- uint32_t time = 100;
- TestStartPan(application, Vector2(10.0f, 20.0f), Vector2(26.0f, 20.0f), time);
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
- data.Reset();
-
- // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
- consume = true;
-
- TestMovePan(application, Vector2(26.0f, 4.0f), time);
- time += TestGetFrameInterval();
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::CANCELLED, data.receivedGesture.GetState(), TEST_LOCATION);
-
- END_TEST;
-}
-
int UtcDaliPanGestureDisableDetectionDuringPanN(void)
{
// Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
END_TEST;
}
-int UtcDaliPinchGestureInterruptedWhenTouchConsumed(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- application.GetScene().Add(actor);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- PinchGestureDetector detector = PinchGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the pinch as the touch is NOT being consumed
- TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
- data.Reset();
-
- // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
- consume = true;
-
- TestContinuePinch(application, Vector2(112.0f, 100.0f), Vector2(112.0f, 124.0f), Vector2(5.0f, 5.0f), Vector2(35.0f, 35.0f), 200);
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::CANCELLED, data.receivedGesture.GetState(), TEST_LOCATION);
- data.Reset();
-
- // Start another pinch, we should not even get the callback this time
- TestStartPinch(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
-
- END_TEST;
-}
-
int UtcDaliPinchGestureDisableDetectionDuringPinchN(void)
{
// Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
END_TEST;
}
-int UtcDaliRotationGestureInterruptedWhenTouchConsumed(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- application.GetScene().Add(actor);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- RotationGestureDetector detector = RotationGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the rotation as the touch is NOT being consumed
- TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::STARTED, data.receivedGesture.GetState(), TEST_LOCATION);
- data.Reset();
-
- // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
- consume = true;
-
- TestContinueRotation(application, Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), Vector2(15.0f, 20.0f), Vector2(25.0f, 20.0f), 500);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(GestureState::CANCELLED, data.receivedGesture.GetState(), TEST_LOCATION);
- data.Reset();
-
- // Start another rotation, we should not even get the callback this time
- TestStartRotation(application, Vector2(2.0f, 20.0f), Vector2(38.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
-
- END_TEST;
-}
-
int UtcDaliRotationGestureDisableDetectionDuringRotationN(void)
{
// Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
END_TEST;
}
-int UtcDaliTapGestureInterruptedWhenTouchConsumed(void)
-{
- TestApplication application;
-
- Actor actor = Actor::New();
- actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- application.GetScene().Add(actor);
-
- bool consume = false;
- TouchEventFunctorConsumeSetter touchFunctor(consume);
- actor.TouchedSignal().Connect(&application, touchFunctor);
-
- // Render and notify
- application.SendNotification();
- application.Render();
-
- SignalData data;
- GestureReceivedFunctor functor(data);
-
- TapGestureDetector detector = TapGestureDetector::New();
- detector.Attach(actor);
- detector.DetectedSignal().Connect(&application, functor);
-
- // Start gesture within the actor's area, we should receive the gesture as the touch is NOT being consumed
- TestGenerateTap(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- data.Reset();
-
- // Another gesture in the same location, this time we will not receive it as touch is being consumed
- consume = true;
- TestGenerateTap(application, 50.0f, 50.0f);
- DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
- data.Reset();
-
- END_TEST;
-}
-
int UtcDaliTapGestureDisableDetectionDuringTapN(void)
{
// Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
TestApplication application;
TapGestureDetector detector = TapGestureDetector::New();
+ detector.SetMaximumTapsRequired(2);
Actor actor = Actor::New();
actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
application.SendNotification();
+ application.GetPlatform().TriggerTimer();
DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
END_TEST;
application.SendNotification();
+ application.GetPlatform().TriggerTimer();
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(true, actor == data.tappedActor, TEST_LOCATION);
data.Reset();
application.SendNotification();
+ application.GetPlatform().TriggerTimer();
DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
DALI_TEST_EQUALS(true, data2.functorCalled, TEST_LOCATION);
*
* @return A vector of the sampler uniforms
*/
- virtual std::vector<Dali::Graphics::UniformInfo> GetSamplers() const = 0;
+ virtual const std::vector<Dali::Graphics::UniformInfo>& GetSamplers() const = 0;
// Language
case Event::Touch:
{
Integration::TouchEvent& touchEvent = static_cast<Integration::TouchEvent&>(*event);
- const bool consumed = mTouchEventProcessor.ProcessTouchEvent(touchEvent);
-
- // If touch is consumed, then gestures should be cancelled
- // Do this by sending an interrupted event to the GestureEventProcessor
- if(consumed)
- {
- Integration::Point& point = touchEvent.GetPoint(0);
- point.SetState(PointState::INTERRUPTED);
- }
+ mTouchEventProcessor.ProcessTouchEvent(touchEvent);
mGestureEventProcessor.ProcessTouchEvent(mScene, touchEvent);
break;
#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
// INTERNAL INCLUDES
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/platform-abstraction.h>
#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/events/gesture-requests.h>
namespace Dali
// TODO: Set these according to DPI
const float MAXIMUM_MOTION_ALLOWED = 20.0f;
const unsigned long MAXIMUM_TIME_ALLOWED = 500u;
+const uint32_t WAIT_TIME = 330u;
} // unnamed namespace
TapGestureRecognizer::TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request)
mTouchPosition(),
mTouchTime(0u),
mLastTapTime(0u),
- mGestureSourceType(GestureSourceType::INVALID)
+ mEventTime(0u),
+ mGestureSourceType(GestureSourceType::INVALID),
+ mTimerId(0)
{
}
-TapGestureRecognizer::~TapGestureRecognizer() = default;
+TapGestureRecognizer::~TapGestureRecognizer()
+{
+ if(mTimerId != 0 && ThreadLocalStorage::Created())
+ {
+ Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
+ platformAbstraction.CancelTimer(mTimerId);
+ }
+}
void TapGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
if(event.GetPointCount() == 1)
{
- const Integration::Point& point = event.points[0];
- PointState::Type pointState = point.GetState();
+ const Integration::Point& point = event.points[0];
+ PointState::Type pointState = point.GetState();
+ Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
MouseButton::Type mouseButton = point.GetMouseButton();
switch(mouseButton)
{
if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
+ if(mMaximumTapsRequired > mMinimumTapsRequired)
+ {
+ mEventTime = event.time;
+ mTimerId = platformAbstraction.StartTimer(WAIT_TIME, MakeCallback(this, &TapGestureRecognizer::TimerCallback));
+ }
+
mLastTapTime = mTouchTime;
EmitSingleTap(event.time, point);
mState = REGISTERED;
else if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
++mTapsRegistered;
- EmitGesture(GestureState::STARTED, event.time);
+ if(mMaximumTapsRequired > mMinimumTapsRequired)
+ {
+ mEventTime = event.time;
+ mTimerId = platformAbstraction.StartTimer(WAIT_TIME, MakeCallback(this, &TapGestureRecognizer::TimerCallback));
+ }
+ else
+ {
+ EmitGesture(GestureState::STARTED, event.time);
+ }
}
else // Delta between touch down and touch up too long to be considered a TAP event
{
{
EmitPossibleState(event);
}
+
+ if(mTimerId != 0)
+ {
+ platformAbstraction.CancelTimer(mTimerId);
+ mTimerId = 0;
+ }
}
break;
}
}
}
+bool TapGestureRecognizer::TimerCallback()
+{
+ EmitGesture(GestureState::STARTED, mEventTime);
+
+ mTimerId = 0;
+ return false;
+}
+
void TapGestureRecognizer::SetupForTouchDown(const Integration::TouchEvent& event, const Integration::Point& point)
{
mTouchPosition = point.GetScreenPosition();
Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
std::abs(mTouchPosition.y - screen.y));
+ mTapsRegistered = 1u;
if(distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
distanceDelta.y > MAXIMUM_MOTION_ALLOWED)
{
event.state = GestureState::CANCELLED;
+ if(mTimerId != 0)
+ {
+ Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
+ platformAbstraction.CancelTimer(mTimerId);
+ mTimerId = 0;
+ }
+ }
+ if(mTimerId == 0)
+ {
+ EmitTap(time, event);
}
- mTapsRegistered = 1u;
- EmitTap(time, event);
}
void TapGestureRecognizer::EmitTap(uint32_t time, TapGestureEvent& event)
*/
void ProcessEvent(TapGestureEvent& event);
+ /**
+ * Timer Callback
+ * @return will return false; one-shot timer.
+ */
+ bool TimerCallback();
+
private:
// Reference to the gesture processor for this recognizer
Observer& mObserver;
Vector2 mTouchPosition; ///< The initial touch down position.
uint32_t mTouchTime; ///< The initial touch down time.
uint32_t mLastTapTime; ///< Time last tap gesture was registered
+ uint32_t mEventTime; ///< The touch event time.
GestureSourceType mGestureSourceType; /// < Gesture input source type value.
+
+ uint32_t mTimerId;
};
} // namespace Internal
void RenderManager::RemoveGeometry(Render::Geometry* geometry)
{
- mImpl->geometryContainer.EraseObject(geometry);
+ auto it = std::find_if( mImpl->geometryContainer.begin(), mImpl->geometryContainer.end(),[geometry]( auto& item )
+ {
+ return geometry == item;
+ });
+
+ if(it != mImpl->geometryContainer.end())
+ {
+ mImpl->geometryContainer.Erase(it);
+ }
}
void RenderManager::AttachVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
DALI_LOG_INFO(gLogFilter, Debug::General, "Render: Processing\n");
// Upload the geometries
- for(auto& i : mImpl->sceneContainer)
+ for(auto&& geom : mImpl->geometryContainer)
{
- RenderInstructionContainer& instructions = i->GetRenderInstructions();
- for(uint32_t j = 0; j < instructions.Count(mImpl->renderBufferIndex); ++j)
- {
- RenderInstruction& instruction = instructions.At(mImpl->renderBufferIndex, j);
-
- const Matrix* viewMatrix = instruction.GetViewMatrix(mImpl->renderBufferIndex);
- const Matrix* projectionMatrix = instruction.GetProjectionMatrix(mImpl->renderBufferIndex);
-
- DALI_ASSERT_DEBUG(viewMatrix);
- DALI_ASSERT_DEBUG(projectionMatrix);
-
- if(viewMatrix && projectionMatrix)
- {
- const RenderListContainer::SizeType renderListCount = instruction.RenderListCount();
-
- // Iterate through each render list.
- for(RenderListContainer::SizeType index = 0; index < renderListCount; ++index)
- {
- const RenderList* renderList = instruction.GetRenderList(index);
-
- if(renderList && !renderList->IsEmpty())
- {
- const std::size_t itemCount = renderList->Count();
- for(uint32_t itemIndex = 0u; itemIndex < itemCount; ++itemIndex)
- {
- const RenderItem& item = renderList->GetItem(itemIndex);
- if(DALI_LIKELY(item.mRenderer))
- {
- item.mRenderer->Upload();
- }
- }
- }
- }
- }
- }
+ geom->Upload( mImpl->graphicsController );
}
}
}
* Check if the attributes for the geometry have changed
* @return True if vertex buffers have been added or removed since last frame, false otherwise
*/
- [[nodiscard]] bool AttributesChanged() const
+ [[maybe_unused]] [[nodiscard]] bool AttributesChanged() const
{
return mAttributesChanged;
}
mUniformIndexMap.Resize(mapIndex);
}
-
- // @todo Temporary workaround to reduce workload each frame. Find a better way.
- auto& sceneGraphRenderer = const_cast<SceneGraph::Renderer&>(static_cast<const SceneGraph::Renderer&>(uniformMapDataProvider));
- sceneGraphRenderer.AgeUniformMap();
}
void Renderer::WriteUniformBuffer(
iter != end;
++iter)
{
- // @todo This means parsing the uniform string every frame. Instead, store the array index if present.
- int arrayIndex = (*iter).arrayIndex;
+ auto& uniform = *iter;
+ int arrayIndex = uniform.arrayIndex;
+
+ if(!uniform.uniformFunc)
+ {
+ auto uniformInfo = Graphics::UniformInfo{};
+ auto uniformFound = program.GetUniform(uniform.uniformName.GetCString(),
+ uniform.uniformNameHashNoArray ? uniform.uniformNameHashNoArray
+ : uniform.uniformNameHash,
+ uniformInfo);
+
+ uniform.uniformOffset = uniformInfo.offset;
+ uniform.uniformLocation = uniformInfo.location;
+
+ if (uniformFound)
+ {
+ auto dst = ubo.GetOffset() + uniformInfo.offset;
+ const auto typeSize = GetPropertyValueSizeForUniform((*iter).propertyValue->GetType());
+ const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = GetPropertyValueGetter((*iter).propertyValue->GetType());
- auto uniformInfo = Graphics::UniformInfo{};
- auto uniformFound = program.GetUniform((*iter).uniformName.GetCString(),
- (*iter).uniformNameHashNoArray ? (*iter).uniformNameHashNoArray
- : (*iter).uniformNameHash,
- uniformInfo);
+ ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex),
+ typeSize,
+ dest);
- if(uniformFound)
+ uniform.uniformSize = typeSize;
+ uniform.uniformFunc = func;
+ }
+ }
+ else
{
- auto dst = ubo.GetOffset() + uniformInfo.offset;
- const auto typeSize = GetPropertyValueSizeForUniform( (*iter).propertyValue->GetType() );
- const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
- const auto func = GetPropertyValueGetter((*iter).propertyValue->GetType());
+ auto dst = ubo.GetOffset() + uniform.uniformOffset;
+ const auto typeSize = uniform.uniformSize;
+ const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = uniform.uniformFunc;
+
+
ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex),
typeSize,
dest);
Render::PipelineCache* mPipelineCache{nullptr};
using Hash = unsigned long;
+
+ typedef const float&(PropertyInputImpl::*FuncGetter )(BufferIndex) const;
+
struct UniformIndexMap
{
ConstString uniformName; ///< The uniform name
Hash uniformNameHash{0u};
Hash uniformNameHashNoArray{0u};
int32_t arrayIndex{-1}; ///< The array index
+
+ int16_t uniformLocation{0u};
+ uint16_t uniformOffset{0u};
+ uint16_t uniformSize{0u};
+ FuncGetter uniformFunc{0};
};
using UniformIndexMappings = Dali::Vector<UniformIndexMap>;
void* ptr = bufferDesc.memory->LockRegion(bufferOffset, size);
if(ptr && bufferOffset + size < mSize)
{
- memcpy(ptr, data, size);
+ // size always divides by 4 (std140 alignment rules, so we can replace memcpy with unrolled assignments)
+ auto ptr32 = reinterpret_cast<uint32_t*>(ptr);
+ auto data32 = reinterpret_cast<const uint32_t*>(data);
+ for(auto i = 0u; i < size; i +=4 )
+ {
+ *ptr32++ = *data32++;;
+ }
}
bufferDesc.memory->Unlock(true);
}
bool Renderer::PrepareRender(BufferIndex updateBufferIndex)
{
- switch(mRegenerateUniformMap)
+ if(mRegenerateUniformMap == UNIFORM_MAP_READY)
{
- case UNIFORM_MAP_READY: // Now, only set to zero on start and by render side
- {
- mUniformMapChanged[updateBufferIndex] = false;
- break;
- }
- case REGENERATE_UNIFORM_MAP:
+ mUniformMapChanged[updateBufferIndex] = false;
+ }
+ else
+ {
+ if(mRegenerateUniformMap == REGENERATE_UNIFORM_MAP)
{
CollectedUniformMap& localMap = mCollectedUniformMap[updateBufferIndex];
localMap.Clear();
{
AddMappings(localMap, mShader->GetUniformMap());
}
- mUniformMapChanged[updateBufferIndex] = true;
- break;
}
- case COPY_UNIFORM_MAP:
+ else if(mRegenerateUniformMap == COPY_UNIFORM_MAP)
{
// Copy old map into current map
CollectedUniformMap& localMap = mCollectedUniformMap[updateBufferIndex];
{
localMap[index] = *iter;
}
- mUniformMapChanged[updateBufferIndex] = true;
- break;
}
+
+ mUniformMapChanged[updateBufferIndex] = true;
+ mRegenerateUniformMap--;
}
bool rendererUpdated = mUniformMapChanged[updateBufferIndex] || mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY;
return rendererUpdated;
}
-void Renderer::AgeUniformMap()
-{
- if(mRegenerateUniformMap > 0)
- {
- mRegenerateUniformMap--;
- }
-}
-
void Renderer::SetTextures(TextureSet* textureSet)
{
DALI_ASSERT_DEBUG(textureSet != NULL && "Texture set pointer is NULL");
void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
- /**
- * Temporary fix to age mRegenerateUniformMap from render side.
- * (aging should only be done if renderer is visible, not when PrepareRender is called)
- */
- void AgeUniformMap();
-
private:
/**
* Protected constructor; See also Renderer::New()
#define DALI_ACTOR_H
/*
- * Copyright (c) 2020 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.
* @endcode
* The return value of True, indicates that the touch event has been consumed.
* Otherwise the signal will be emitted on the next sensitive parent of the actor.
- * A true return will also cancel any ongoing gestures.
* @SINCE_1_9.28
* @return The signal to connect to
* @pre The Actor has been initialized.
{
const uint32_t CORE_MAJOR_VERSION = 2;
const uint32_t CORE_MINOR_VERSION = 0;
-const uint32_t CORE_MICRO_VERSION = 32;
+const uint32_t CORE_MICRO_VERSION = 35;
const char* const CORE_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2
Summary: DALi 3D Engine
-Version: 2.0.32
+Version: 2.0.35
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT