using MethodType = TestDBusWrapper::MethodType;
using MessagePtr = DBusWrapper::MessagePtr;
+ static bool MoveOutedCalled = false;
+
void TestEnableSC(bool b) {
static bool firstTime = true;
if (b && firstTime) {
[wr](const MessagePtr &m) -> MessagePtr {
return wr->newReplyMessage(m);
};
+ wr->testMethods[std::tuple<std::string, std::string, std::string, MethodType>{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Object", "MoveOuted", MethodType::Method}] =
+ [wr](const MessagePtr &m) -> MessagePtr {
+ MoveOutedCalled = true;
+ return wr->newReplyMessage(m);
+ };
}
auto wr = static_cast<TestDBusWrapper*>(DBusWrapper::Installed());
wr->fromTestChangeProperty("/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", b);
return std::move(std::get<0>(chs));
}
+ void TestResetMoveOutedCalled ()
+ {
+ MoveOutedCalled = false;
+ }
+
+ bool TestGetMoveOutedCalled ()
+ {
+ return MoveOutedCalled;
+ }
void printTree(const Address &root, size_t depth)
{
bool TestDoAction ( const Address &adr, const std::string& name );
std::string TestGetActionKeyBinding ( const Address &adr, size_t index );
std::string TestGetActionDescription ( const Address &adr, size_t index );
-
+ void TestResetMoveOutedCalled ();
+ bool TestGetMoveOutedCalled ();
}
}
Dali::Accessibility::TestEnableSC( false );
END_TEST;
}
+
+int UtcDaliAccessibilityCheckHighlight(void)
+{
+ ToolkitTestApplication application;
+ Dali::Accessibility::TestEnableSC( true );
+ Dali::Accessibility::TestResetMoveOutedCalled();
+
+ // Make precondition two children exist in parent area
+ PushButton parentButton = PushButton::New();
+ parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ parentButton.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f) );
+ parentButton.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 200.0f) );
+ application.GetScene().Add( parentButton );
+
+ PushButton buttonA = PushButton::New();
+ buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f) );
+ buttonA.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f) );
+ parentButton.Add(buttonA);
+
+ PushButton buttonB = PushButton::New();
+ buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 100.0f) );
+ buttonB.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f) );
+ parentButton.Add(buttonB);
+ Wait(application);
+
+ // Move second child out of parent area
+ auto* accessible = dynamic_cast<DevelControl::AccessibleImpl*>(Dali::Accessibility::Accessible::Get(buttonA));
+ DALI_TEST_CHECK(accessible);
+ accessible->GrabHighlight();
+ Wait(application);
+
+ buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, -200.0f) );
+ Wait(application);
+ // Need one more seding notificaiton to get correct updated position
+ application.SendNotification();
+ DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
+
+ // Reset verdict data
+ Dali::Accessibility::TestResetMoveOutedCalled();
+
+ // Move second child out of parent area
+ accessible = dynamic_cast<DevelControl::AccessibleImpl*>(Dali::Accessibility::Accessible::Get(buttonB));
+ DALI_TEST_CHECK(accessible);
+ accessible->GrabHighlight();
+ Wait(application);
+
+ buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(300.0f, 100.0f) );
+ Wait(application);
+ // Need one more seding notificaiton to get correct updated position
+ application.SendNotification();
+ DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
+
+ Dali::Accessibility::TestEnableSC( false );
+ END_TEST;
+}
DALI_TEST_EQUALS( true, visualUrl3.IsValid(), TEST_LOCATION );
DALI_TEST_EQUALS( visualUrl3.GetType(), VisualUrl::GIF, TEST_LOCATION );
DALI_TEST_EQUALS( visualUrl3.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+
+ VisualUrl visualUrl4("dali://0");
+ visualUrl4 = visualUrl;
+ DALI_TEST_EQUALS( true, visualUrl4.IsValid(), TEST_LOCATION );
+ DALI_TEST_EQUALS( visualUrl4.GetType(), VisualUrl::GIF, TEST_LOCATION );
+ DALI_TEST_EQUALS( visualUrl4.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+
+ VisualUrl visualUrl5("dali://1");
+ visualUrl4 = visualUrl5;
+ DALI_TEST_EQUALS( true, visualUrl4.IsValid(), TEST_LOCATION );
+ DALI_TEST_EQUALS( visualUrl4.GetType(), VisualUrl::REGULAR_IMAGE, TEST_LOCATION );
+ DALI_TEST_EQUALS( visualUrl4.GetProtocolType(), VisualUrl::TEXTURE, TEST_LOCATION );
END_TEST;
}
utc-Dali-Image.cpp
utc-Dali-ImageView.cpp
utc-Dali-ImageVisual.cpp
+ utc-Dali-ImageUrl.cpp
utc-Dali-JsonParser.cpp
utc-Dali-KeyInputFocusManager.cpp
utc-Dali-PageTurnView.cpp
/*
- * 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);
mCallStack.PushCall("GetCustomFragmentPrefix", "");
return "#extension GL_OES_EGL_image_external:require\n";
};
+ inline virtual bool ApplyNativeFragmentShader(std::string& shader)
+ {
+ mCallStack.PushCall("ApplyNativeFragmentShader", "");
+ shader = "#extension GL_OES_EGL_image_external:require\n" + shader;
+
+ //Get custom sampler type name
+ const char* customSamplerTypename = GetCustomSamplerTypename();
+ if(customSamplerTypename)
+ {
+ size_t samplerPosition = shader.find("sampler2D");
+ if(samplerPosition != std::string::npos)
+ {
+ shader.replace(samplerPosition, strlen("sampler2D"), customSamplerTypename);
+ }
+ }
+ return true;
+ };
inline const char* GetCustomSamplerTypename() const override
{
mCallStack.PushCall("GetCustomSamplerTypename", "");
return "";
}
+bool NativeImageSource::ApplyNativeFragmentShader(std::string& shader)
+{
+ return true;
+}
+
const char* NativeImageSource::GetCustomSamplerTypename() const
{
return "";
application.SendNotification();
application.Render();
+ // Trigger count is 1 - render the first frame
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
Property::Map attributes;
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
application.SendNotification();
application.Render();
- // Trigger count is 1 - render the first frame
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
-
// Wait for calculating frame drops
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
// Check dropped frame
uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
- DALI_TEST_CHECK(frames >= 9);
+ DALI_TEST_CHECK(frames > 0);
END_TEST;
}
#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali-toolkit/public-api/image-loader/image.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
using namespace Dali;
using namespace Dali::Toolkit;
FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
DALI_TEST_CHECK( frameBuffer );
- std::string url = Dali::Toolkit::Image::GenerateUrl( frameBuffer, Pixel::Format::RGBA8888, width, height );
+ ImageUrl url = Dali::Toolkit::Image::GenerateUrl( frameBuffer, Pixel::Format::RGBA8888, width, height );
- DALI_TEST_CHECK( url.size() > 0u );
+ DALI_TEST_CHECK( url.GetUrl().size() > 0u );
END_TEST;
}
Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
frameBuffer.AttachColorTexture( texture );
- DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( frameBuffer, 0 ).size() > 0u );
+ DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( frameBuffer, 0 ).GetUrl().size() > 0u );
END_TEST;
}
unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE );
- DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( pixelData ).size() > 0u );
+ DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( pixelData ).GetUrl().size() > 0u );
END_TEST;
}
{
NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, height, NativeImageSource::COLOR_DEPTH_DEFAULT );
- DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( nativeImageSource ).size() > 0u );
+ DALI_TEST_CHECK( Dali::Toolkit::Image::GenerateUrl( nativeImageSource ).GetUrl().size() > 0u );
}
catch(Dali::DaliException& e)
{
--- /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.
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+int UtcImageUrlConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcImageUrlValid ");
+
+ // Test default constructor.
+ ImageUrl imageUrl;
+ DALI_TEST_CHECK( !imageUrl );
+
+ // Test object creation
+ Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u); // test texture
+ imageUrl = ImageUrl::New(image);
+ DALI_TEST_CHECK( imageUrl );
+
+ // Test copy constructor
+ ImageUrl ImageUrlCopy( imageUrl );
+ DALI_TEST_CHECK( ImageUrlCopy );
+
+ // Test down cast
+ BaseHandle baseUrl;
+ baseUrl = imageUrl;
+ ImageUrl downcastUrl = ImageUrl::DownCast( baseUrl );
+ DALI_TEST_CHECK( downcastUrl );
+ END_TEST;
+}
\ No newline at end of file
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
#include <dali-toolkit/public-api/image-loader/image.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
#include <dali-toolkit/dali-toolkit.h>
#include "dummy-control.h"
tet_infoline( "Use Native Image as url" );
NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
- std::string url = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
+ ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
+ std::string url = imageUrl.GetUrl();
VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
END_TEST;
}
+int UtcDaliImageVisualWithNativeImageRemoved(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Use Native Image as url" );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
+ ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
+ std::string url = imageUrl.GetUrl();
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, url );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ application.GetScene().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
+
+ tet_infoline( "No delete texture because reference count is not zero" );
+ imageUrl.Reset();
+ application.GetScene().Remove( actor );
+ dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
+
+ tet_infoline( "Delete texture because reference count is zero" );
+ visual.Reset();
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliImageVisualTextureReuse1(void)
{
ToolkitTestApplication application;
focusChangedCallback.Reset();
// without set the navigation properties, but we can focus move
+ // enable the default algorithm
+ Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
+ DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
// Move the focus towards right
// button1 -- [button2]
DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliKeyboardFocusManagerEnableDefaultAlgorithm(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyboardFocusManagerEnableDefaultAlgorithm");
+
+ // Register Type
+ TypeInfo type;
+ type = TypeRegistry::Get().GetTypeInfo( "KeyboardFocusManager" );
+ DALI_TEST_CHECK( type );
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool focusChangedSignalVerified = false;
+ FocusChangedCallback focusChangedCallback(focusChangedSignalVerified);
+ manager.FocusChangedSignal().Connect( &focusChangedCallback, &FocusChangedCallback::Callback );
+
+ PushButton button1 = PushButton::New();
+ PushButton button2 = PushButton::New();
+
+ button1.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
+ button2.SetProperty(Actor::Property::SIZE, Vector2(50, 50));
+
+ button1.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
+ button2.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE,true);
+
+ application.GetScene().Add(button1);
+ application.GetScene().Add(button2);
+
+ // set position
+ // button1 -- button2
+ button1.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+ button2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 0.0f));
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Set the focus to the button1
+ // [button1] -- button2
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(button1) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == button1);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
+ focusChangedCallback.Reset();
+
+ // without set the navigation properties, but we can focus move
+ // enable the default algorithm
+ Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
+ DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
+
+ // Move the focus towards right
+ // button1 -- [button2]
+ DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
+
+ // Confirm whether focus is moved to button2
+ DALI_TEST_EQUALS(button2.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button1);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button2);
+ focusChangedCallback.Reset();
+
+ // disable the default algorithm
+ Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, false);
+ DALI_TEST_CHECK( !Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
+
+ // Move the focus towards left, The focus move will fail because the default algorithm is disabled.
+ DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == false);
+
+ // enable the default algorithm
+ Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true);
+ DALI_TEST_CHECK( Dali::Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled(manager) );
+
+ // Move the focus towards left, The focus move will success because the default algorithm is enabled.
+ // [button1] -- button2
+ DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
+ // Confirm whether focus is moved to button2
+ DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
+ focusChangedCallback.Reset();
+
+
+ END_TEST;
+}
}
}
+void AccessibleImpl::RegisterPositionPropertyNotification()
+{
+ auto control = Dali::Toolkit::Control::DownCast(Self());
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl);
+ controlImpl.RegisterAccessibilityPositionPropertyNotification();
+}
+
+void AccessibleImpl::UnregisterPositionPropertyNotification()
+{
+ auto control = Dali::Toolkit::Control::DownCast(Self());
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl);
+ controlImpl.UnregisterAccessibilityPositionPropertyNotification();
+}
+
bool AccessibleImpl::GrabHighlight()
{
Dali::Actor self = Self();
SetHighlightActor(highlight);
}
- highlight.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
- highlight.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ highlight.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
highlight.SetProperty(Actor::Property::POSITION_Z, 1.0f);
highlight.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+ // Need to set resize policy again, to update SIZE property which is set by
+ // AccessibleImpl_NUI. The highlight could move from AccessibleImpl_NUI to
+ // AccessibleImpl. In this case, highlight has incorrect size.
+ highlight.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
+
// Remember the highlight actor, so that when the default is changed with
// SetHighlightActor(), the currently displayed highlight can still be cleared.
mCurrentHighlightActor = highlight;
self.Add(highlight);
SetCurrentlyHighlightedActor(self);
EmitHighlighted(true);
+ RegisterPositionPropertyNotification();
return true;
}
if(GetCurrentlyHighlightedActor() == self)
{
+ UnregisterPositionPropertyNotification();
self.Remove(mCurrentHighlightActor.GetHandle());
mCurrentHighlightActor = {};
SetCurrentlyHighlightedActor({});
return Dali::Property::INVALID_INDEX;
}
+void AccessibleImpl::SetLastPosition(Vector2 position)
+{
+ mLastPosition = position;
+}
+
+Vector2 AccessibleImpl::GetLastPosition() const
+{
+ return mLastPosition;
+}
+
} // namespace Dali::Toolkit::DevelControl
public virtual Dali::Accessibility::Action
{
protected:
+ Vector2 mLastPosition{0.0f, 0.0f};
Dali::WeakHandle<Dali::Actor> mSelf;
Dali::WeakHandle<Dali::Actor> mCurrentHighlightActor;
bool mIsModal = false;
void ScrollToSelf();
+ /**
+ * @brief Register property notification to check highlighted object position
+ */
+ void RegisterPositionPropertyNotification();
+
+ /**
+ * @brief Remove property notification added by RegisterPropertyNotification
+ */
+ void UnregisterPositionPropertyNotification();
+
public:
AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false);
* @brief Returns the index of the property that represents this actor's description
*/
virtual Dali::Property::Index GetDescriptionPropertyIndex();
+
+ /**
+ * @brief Sets last object position
+ * @param[in] position Last object position
+ */
+ void SetLastPosition(Vector2 position);
+
+ /**
+ * @brief Gets last object position
+ * @return The Last object position
+ */
+ Vector2 GetLastPosition() const;
};
} // namespace Dali::Toolkit::DevelControl
/*
- * 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.
return GetImpl(keyboardFocusManager).IsFocusIndicatorEnabled();
}
+void EnableDefaultAlgorithm(KeyboardFocusManager keyboardFocusManager, bool enable)
+{
+ GetImpl(keyboardFocusManager).EnableDefaultAlgorithm(enable);
+}
+
+bool IsDefaultAlgorithmEnabled(KeyboardFocusManager keyboardFocusManager)
+{
+ return GetImpl(keyboardFocusManager).IsDefaultAlgorithmEnabled();
+}
+
} // namespace DevelKeyboardFocusManager
} // namespace Toolkit
#define DALI_TOOLKIT_KEYBOARD_FOCUS_MANAGER_DEVEL_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.
*/
DALI_TOOLKIT_API bool IsFocusIndicatorEnabled(KeyboardFocusManager keyboardFocusManager);
+/**
+ * @brief Decide using default focus algorithm or not
+ *
+ * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
+ * @param[in] enable Whether using default focus algorithm or not
+ */
+DALI_TOOLKIT_API void EnableDefaultAlgorithm(KeyboardFocusManager keyboardFocusManager, bool enable);
+
+/**
+ * @brief Check default focus algorithm is enabled or not
+ *
+ * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
+ * @return True when default focus algorithm is enabled
+ */
+DALI_TOOLKIT_API bool IsDefaultAlgorithmEnabled(KeyboardFocusManager keyboardFocusManager);
+
} // namespace DevelKeyboardFocusManager
} // namespace Toolkit
mNativeTexture = Dali::Texture::New(*nativeImageSourcePtr);
Dali::Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Dali::Shader shader = CreateShader(nativeImageSourcePtr->GetCustomFragmentPrefix());
+ Dali::Shader shader = CreateShader(nativeImageSourcePtr);
Dali::TextureSet textureSet = Dali::TextureSet::New();
textureSet.SetTexture(0u, mNativeTexture);
mCameraPlayer.SetDisplayArea(mDisplayArea);
}
-Dali::Shader CameraView::CreateShader(const char* fragmentPrefix)
+Dali::Shader CameraView::CreateShader(Dali::NativeImageSourcePtr nativeImageSourcePtr)
{
- std::string fragmentShader = fragmentPrefix;
- std::string vertexShader;
+ std::string vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
+ std::string fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
- vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
- fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ nativeImageSourcePtr->ApplyNativeFragmentShader(fragmentShader);
return Dali::Shader::New(vertexShader, fragmentShader);
}
/**
* @brief CreateShader for native image target
- * @param[in] fragmentPrefix prefix of fragment
+ * @param[in] nativeImageSourcePtr to apply custom fragment prefix
* @return Returns the shader for NativeImage.
*/
- Dali::Shader CreateShader(const char* fragmentPrefix);
+ Dali::Shader CreateShader(Dali::NativeImageSourcePtr nativeImageSourcePtr);
private:
Dali::CameraPlayer mCameraPlayer;
}
}
+Dali::Rect<> GetShowingGeometry(Dali::Rect<> rect, Dali::Toolkit::DevelControl::AccessibleImpl* accessibleImpl)
+{
+ Rect<> parentRect;
+ Vector2 currentPosition;
+ auto parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(accessibleImpl->GetParent());
+
+ while(parent)
+ {
+ parentRect = parent->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
+
+ currentPosition.x = rect.x;
+ currentPosition.y = rect.y;
+
+ rect.x = rect.x > parentRect.x ? rect.x : parentRect.x;
+ rect.y = rect.y > parentRect.y ? rect.y : parentRect.y;
+ rect.width = currentPosition.x + rect.width < parentRect.x + parentRect.width ? currentPosition.x + rect.width - rect.x : parentRect.x + parentRect.width - rect.x;
+ rect.height = currentPosition.y + rect.height < parentRect.y + parentRect.height ? currentPosition.y + rect.height - rect.y : parentRect.y + parentRect.height - rect.y;
+
+ if(rect.width < 0 || rect.height < 0)
+ {
+ return rect;
+ }
+
+ parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(parent->GetParent());
+ }
+
+ return rect;
+}
+
} // unnamed namespace
// clang-format off
return *internalControl.mImpl;
}
+void Control::Impl::CheckHighlightedObjectGeometry(PropertyNotification& propertyNotification)
+{
+ auto accessibleImpl = dynamic_cast<Dali::Toolkit::DevelControl::AccessibleImpl*>(mAccessibilityObject.get());
+ auto lastPosition = accessibleImpl->GetLastPosition();
+ auto accessibleRect = accessibleImpl->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
+
+ if(lastPosition.x == accessibleRect.x && lastPosition.y == accessibleRect.y)
+ {
+ return;
+ }
+
+ auto rect = GetShowingGeometry(accessibleRect, accessibleImpl);
+
+ // MoveOuted is sent already, no need to send it again
+ if(mAccessibilityMovedOutOfScreenDirection != Dali::Accessibility::MovedOutOfScreenType::NONE)
+ {
+ if(rect.width > 0 && rect.height > 0)
+ {
+ // flick next does not use MoveOuted - ScrollToSelf makes object show, so reset for sending MoveOuted next
+ mAccessibilityMovedOutOfScreenDirection = Dali::Accessibility::MovedOutOfScreenType::NONE;
+ }
+ return;
+ }
+
+ if(rect.width < 0)
+ {
+ mAccessibilityMovedOutOfScreenDirection = (accessibleRect.x < lastPosition.x) ? Dali::Accessibility::MovedOutOfScreenType::TOP_LEFT : Dali::Accessibility::MovedOutOfScreenType::BOTTOM_RIGHT;
+ }
+
+ if(rect.height < 0)
+ {
+ mAccessibilityMovedOutOfScreenDirection = (accessibleRect.y < lastPosition.y) ? Dali::Accessibility::MovedOutOfScreenType::TOP_LEFT : Dali::Accessibility::MovedOutOfScreenType::BOTTOM_RIGHT;
+ }
+
+ if(mAccessibilityMovedOutOfScreenDirection != Dali::Accessibility::MovedOutOfScreenType::NONE)
+ {
+ mAccessibilityObject.get()->EmitMovedOutOfScreen(mAccessibilityMovedOutOfScreenDirection);
+ accessibleImpl->SetLastPosition(Vector2(0.0f, 0.0f));
+ return;
+ }
+
+ accessibleImpl->SetLastPosition(Vector2(accessibleRect.x, accessibleRect.y));
+}
+
+void Control::Impl::RegisterAccessibilityPositionPropertyNotification()
+{
+ if(mIsAccessibilityPositionPropertyNotificationSet)
+ {
+ return;
+ }
+
+ mAccessibilityMovedOutOfScreenDirection = Dali::Accessibility::MovedOutOfScreenType::NONE;
+ mAccessibilityPositionNotification = mControlImpl.Self().AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
+ mAccessibilityPositionNotification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
+ mAccessibilityPositionNotification.NotifySignal().Connect(this, &Control::Impl::CheckHighlightedObjectGeometry);
+ mIsAccessibilityPositionPropertyNotificationSet = true;
+}
+
+void Control::Impl::UnregisterAccessibilityPositionPropertyNotification()
+{
+ mControlImpl.Self().RemovePropertyNotification(mAccessibilityPositionNotification);
+ mIsAccessibilityPositionPropertyNotificationSet = false;
+}
+
// Gesture Detection Methods
void Control::Impl::PinchDetected(Actor actor, const PinchGesture& pinch)
{
*/
void OnIdleCallback();
+ /**
+ * @brief Checks highlighted object geometry if it is showing or not
+ * @param[in] propertyNotification PropertyNotification
+ */
+ void CheckHighlightedObjectGeometry(Dali::PropertyNotification& propertyNotification);
+
+ /**
+ * @brief Register property notification to check highlighted object position
+ */
+ void RegisterAccessibilityPositionPropertyNotification();
+
+ /**
+ * @brief Remove property notification added by RegisterPropertyNotification
+ */
+ void UnregisterAccessibilityPositionPropertyNotification();
+
public:
Control& mControlImpl;
DevelControl::State mState;
static const PropertyRegistration PROPERTY_20;
static const PropertyRegistration PROPERTY_21;
static const PropertyRegistration PROPERTY_22;
+
+private:
+ // Accessibility - notification for highlighted object to check if it is showing.
+ bool mIsAccessibilityPositionPropertyNotificationSet{false};
+ Dali::PropertyNotification mAccessibilityPositionNotification;
+ Dali::Accessibility::MovedOutOfScreenType mAccessibilityMovedOutOfScreenDirection;
};
} // namespace Internal
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/public-api/image-loader/image.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
namespace Dali
{
return Dali::Toolkit::ImageView();
}
- std::string url = Dali::Toolkit::Image::GenerateUrl(pixel);
- Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url);
+ Dali::Toolkit::ImageUrl url = Dali::Toolkit::Image::GenerateUrl(pixel);
+ Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url.GetUrl());
imageView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixel.GetWidth(), pixel.GetHeight()));
return imageView;
}
${toolkit_src_dir}/image-loader/atlas-packer.cpp
${toolkit_src_dir}/image-loader/image-atlas-impl.cpp
${toolkit_src_dir}/image-loader/image-load-thread.cpp
+ ${toolkit_src_dir}/image-loader/image-url-impl.cpp
${toolkit_src_dir}/styling/style-manager-impl.cpp
${toolkit_src_dir}/text/bidirectional-support.cpp
${toolkit_src_dir}/text/character-set-conversion.cpp
mAlwaysShowIndicator(ALWAYS_SHOW),
mFocusGroupLoopEnabled(false),
mIsWaitingKeyboardFocusChangeCommit(false),
- mClearFocusOnTouch(true)
+ mClearFocusOnTouch(true),
+ mEnableDefaultAlgorithm(false)
{
// TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorShown.
nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
mIsWaitingKeyboardFocusChangeCommit = false;
}
- else
+ else if(mEnableDefaultAlgorithm)
{
// We should find it among the actors nearby.
nextFocusableActor = Toolkit::FocusFinder::GetNearestFocusableActor(currentFocusActor, direction);
return (mEnableFocusIndicator == ENABLE);
}
+void KeyboardFocusManager::EnableDefaultAlgorithm(bool enable)
+{
+ mEnableDefaultAlgorithm = enable;
+}
+
+bool KeyboardFocusManager::IsDefaultAlgorithmEnabled() const
+{
+ return mEnableDefaultAlgorithm;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
bool IsFocusIndicatorEnabled() const;
+ /**
+ * @copydoc Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm
+ */
+ void EnableDefaultAlgorithm(bool enable);
+
+ /**
+ * @copydoc Toolkit::DevelKeyboardFocusManager::IsDefaultAlgorithmEnabled
+ */
+ bool IsDefaultAlgorithmEnabled() const;
+
public:
/**
* @copydoc Toolkit::KeyboardFocusManager::PreFocusChangeSignal()
bool mIsWaitingKeyboardFocusChangeCommit : 1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
bool mClearFocusOnTouch : 1; ///< Whether clear focus on touch.
+
+ bool mEnableDefaultAlgorithm : 1; ///< Whether use default algorithm focus
};
} // namespace Internal
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
+#include <dali-toolkit/internal/image-loader/image-url-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+ImageUrl::ImageUrl(Texture& texture)
+: mUrl("")
+{
+ mUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
+}
+
+ImageUrl::~ImageUrl()
+{
+ Dali::Toolkit::TextureManager::RemoveTexture(mUrl);
+}
+
+ImageUrlPtr ImageUrl::New(Texture& texture)
+{
+ ImageUrlPtr imageUrlPtr = new ImageUrl(texture);
+ return imageUrlPtr;
+}
+
+const std::string& ImageUrl::GetUrl() const
+{
+ return mUrl;
+}
+
+} // End of namespace Internal
+
+} // End of namespace Toolkit
+
+} // End of namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_IMAGE_URL_H
+#define DALI_TOOLKIT_INTERNAL_IMAGE_URL_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/public-api/object/base-object.h>
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/image-loader/image-url.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+class ImageUrl;
+using ImageUrlPtr = IntrusivePtr<ImageUrl>;
+
+class ImageUrl : public BaseObject
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ ImageUrl(Texture& texture);
+
+ /**
+ * @copydoc Dali::Toolkit::ImageUrl::New
+ */
+ static ImageUrlPtr New(Texture& texture);
+
+ /**
+ * @copydoc Dali::Toolkit::ImageUrl::GetUrl
+ */
+ const std::string& GetUrl() const;
+
+protected:
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~ImageUrl();
+
+private:
+ // Undefined
+ ImageUrl(const ImageUrl&);
+
+ // Undefined
+ ImageUrl& operator=(const ImageUrl& rhs);
+
+private:
+ std::string mUrl;
+};
+
+} // namespace Internal
+} // namespace Toolkit
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::ImageUrl& GetImpl(Dali::Toolkit::ImageUrl& imageUrl)
+{
+ DALI_ASSERT_ALWAYS(imageUrl && "ImageUrl handle is empty");
+
+ BaseObject& handle = imageUrl.GetBaseObject();
+
+ return static_cast<Toolkit::Internal::ImageUrl&>(handle);
+}
+
+inline const Toolkit::Internal::ImageUrl& GetImpl(const Dali::Toolkit::ImageUrl& imageUrl)
+{
+ DALI_ASSERT_ALWAYS(imageUrl && "ImageUrl handle is empty");
+
+ const BaseObject& handle = imageUrl.GetBaseObject();
+
+ return static_cast<const Toolkit::Internal::ImageUrl&>(handle);
+}
+
+} // End of namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_IMAGE_URL_H
lineInfoRun.visualToLogicalMapSecondHalf = reinterpret_cast<CharacterIndex*>(malloc(numberOfCharactersInSecondHalfLine * sizeof(CharacterIndex)));
- if(nullptr != lineInfoRun.visualToLogicalMap)
+ if(nullptr != lineInfoRun.visualToLogicalMap && nullptr != lineInfoRun.visualToLogicalMapSecondHalf)
{
// Reorders the line.
bidirectionalSupport.Reorder(bidirectionalParagraphInfo.bidirectionalInfoIndex,
linesBuffer[lineIndex].ellipsis = false;
}
numberOfLines--;
- ellipsisLineIndex = middleLineIndex > 0u ? middleLineIndex - 1u : 0u;
+ ellipsisLineIndex = middleLineIndex - 1u;
middleLineIndex = (numberOfLines) / 2u;
}
void Initialize(LineRun& line)
{
- line.glyphRun.glyphIndex = 0u;
- line.glyphRun.numberOfGlyphs = 0u;
- line.characterRun.characterIndex = 0u;
- line.characterRun.numberOfCharacters = 0u;
- line.width = 0.f;
- line.ascender = 0.f;
- line.descender = 0.f;
- line.extraLength = 0.f;
- line.alignmentOffset = 0.f;
- line.direction = LTR;
- line.ellipsis = false;
- line.lineSpacing = mDefaultLineSpacing;
+ line.glyphRun.glyphIndex = 0u;
+ line.glyphRun.numberOfGlyphs = 0u;
+ line.characterRun.characterIndex = 0u;
+ line.characterRun.numberOfCharacters = 0u;
+ line.width = 0.f;
+ line.ascender = 0.f;
+ line.descender = 0.f;
+ line.extraLength = 0.f;
+ line.alignmentOffset = 0.f;
+ line.direction = LTR;
+ line.ellipsis = false;
+ line.lineSpacing = mDefaultLineSpacing;
+ line.isSplitToTwoHalves = false;
+ line.glyphRunSecondHalf.glyphIndex = 0u;
+ line.glyphRunSecondHalf.numberOfGlyphs = 0u;
+ line.characterRunForSecondHalfLine.characterIndex = 0u;
+ line.characterRunForSecondHalfLine.numberOfCharacters = 0u;
}
Type mLayout;
{
mCopiedActor = Dali::Actor::New();
mTarget.GetParent().Add(mCopiedActor);
+
mCopiedActor[Dali::DevelActor::Property::SIBLING_ORDER] = static_cast<int32_t>(mTarget[Dali::DevelActor::Property::SIBLING_ORDER]) + 1;
- for(uint32_t i = 0; i < mTarget.GetChildCount(); ++i)
+ while(mTarget.GetChildCount() > 0)
{
- Dali::Actor child = mTarget.GetChildAt(i);
+ Dali::Actor child = mTarget.GetChildAt(0);
Dali::DevelActor::SwitchParent(child, mCopiedActor);
}
mTarget.SetProperties(mOriginalPropertyMap);
if(mMoveTargetChildren)
{
- for(uint32_t i = 0; i < mCopiedActor.GetChildCount(); ++i)
+ while(mCopiedActor.GetChildCount() > 0)
{
- Dali::Actor child = mCopiedActor.GetChildAt(i);
+ Dali::Actor child = mCopiedActor.GetChildAt(0);
Dali::DevelActor::SwitchParent(child, mTarget);
}
mCopiedActor.Unparent();
void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUploadObserver* observer)
{
int textureInfoIndex = GetCacheIndexFromId(textureId);
+
if(textureInfoIndex != INVALID_INDEX)
{
TextureInfo& textureInfo(mTextureInfoContainer[textureInfoIndex]);
info.textureId = GenerateUniqueTextureId();
info.textureSet = textureSet;
mExternalTextures.emplace_back(info);
+
return VisualUrl::CreateTextureUrl(std::to_string(info.textureId));
}
if(url.size() > 0u)
{
// get the location from the Url
- VisualUrl parseUrl(url);
- if(VisualUrl::TEXTURE == parseUrl.GetProtocolType())
+ if(VisualUrl::TEXTURE == VisualUrl::GetProtocolType(url))
{
- std::string location = parseUrl.GetLocation();
+ std::string location = VisualUrl::GetLocation(url);
if(location.size() > 0u)
{
TextureId id = std::stoi(location);
if(iter->textureId == id)
{
auto textureSet = iter->textureSet;
- mExternalTextures.erase(iter);
+ if(--(iter->referenceCount) <= 0)
+ {
+ mExternalTextures.erase(iter);
+ }
return textureSet;
}
}
return TextureSet();
}
+void TextureManager::UseExternalTexture(const VisualUrl& url)
+{
+ if(VisualUrl::TEXTURE == url.GetProtocolType())
+ {
+ std::string location = url.GetLocation();
+ if(location.size() > 0u)
+ {
+ TextureId id = std::stoi(location);
+ for(auto&& elem : mExternalTextures)
+ {
+ if(elem.textureId == id)
+ {
+ elem.referenceCount++;
+ return;
+ }
+ }
+ }
+ }
+}
+
void TextureManager::AddObserver(TextureManager::LifecycleObserver& observer)
{
// make sure an observer doesn't observe the same object twice
TextureSet RemoveExternalTexture(const std::string& url);
/**
+ * @brief Notify that external textures are used.
+ * @param[in] url The URL of the texture to use.
+ */
+ void UseExternalTexture(const VisualUrl& url);
+
+ /**
* Add an observer to the object.
* @param[in] observer The observer to add.
*/
{
TextureId textureId;
TextureSet textureSet;
+ int16_t referenceCount{1};
};
private:
// EXTERNAL HEADERS
#include <cstring> // for toupper()
+// INTERNAL HEADERS
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+
namespace Dali
{
namespace Toolkit
// TEXTURE location url doesn't need type resolving, REGULAR_IMAGE is fine
mType = ResolveType(url);
}
+ else
+ {
+ Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
+ if(factory)
+ {
+ GetImplementation(factory).GetTextureManager().UseExternalTexture(*this);
+ }
+ }
}
}
mType(url.mType),
mLocation(url.mLocation)
{
+ if(VisualUrl::TEXTURE == mLocation)
+ {
+ Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
+ if(factory)
+ {
+ GetImplementation(factory).GetTextureManager().UseExternalTexture(*this);
+ }
+ }
+}
+
+VisualUrl::~VisualUrl()
+{
+ if(VisualUrl::TEXTURE == mLocation)
+ {
+ Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
+ if(factory)
+ {
+ GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl);
+ }
+ }
}
VisualUrl& VisualUrl::operator=(const VisualUrl& url)
{
if(&url != this)
{
+ if(VisualUrl::TEXTURE == mLocation)
+ {
+ Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
+ if(factory)
+ {
+ GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl);
+ }
+ }
+
mUrl = url.mUrl;
mType = url.mType;
mLocation = url.mLocation;
+
+ if(VisualUrl::TEXTURE == mLocation)
+ {
+ Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
+ if(factory)
+ {
+ GetImplementation(factory).GetTextureManager().UseExternalTexture(*this);
+ }
+ }
}
return *this;
}
std::string VisualUrl::GetLocation() const
{
- const auto location = mUrl.find("://");
- if(std::string::npos != location)
- {
- return mUrl.substr(location + 3u); // 3 characters forwards from the start of ://
- }
- return mUrl;
+ return GetLocation(mUrl);
}
std::string VisualUrl::CreateTextureUrl(const std::string& location)
return "dali://" + location;
}
+VisualUrl::ProtocolType VisualUrl::GetProtocolType(const std::string& url)
+{
+ return ResolveLocation(url);
+}
+
+std::string VisualUrl::GetLocation(const std::string& url)
+{
+ const auto location = url.find("://");
+ if(std::string::npos != location)
+ {
+ return url.substr(location + 3u); // 3 characters forwards from the start of ://
+ }
+ return url;
+}
+
+
} // namespace Internal
} // namespace Toolkit
VisualUrl();
/**
+ * Default Destructor.
+ * Delete an external texture if if protocolType is TEXTURE.
+ */
+ ~VisualUrl();
+
+ /**
* Constructor.
* Determines type of visual and whether the url is local or remote
+ * Notify that it is using an external texture if if protocolType is TEXTURE.
+ *
* @param[in] url The URL to store and resolve
*/
VisualUrl(const std::string& url);
*/
static std::string CreateTextureUrl(const std::string& location);
+ /**
+ * Helper to get a ProtocolType from url
+ * @param url the url of the texture
+ * @return the protocol type
+ */
+ static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
+
+ /**
+ * Helper to get a location from url
+ * @param url the location of the texture
+ * @return the location
+ */
+ static std::string GetLocation(const std::string& url);
private:
std::string mUrl;
Type mType;
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 35;
+const unsigned int TOOLKIT_MICRO_VERSION = 36;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
${public_api_src_dir}/controls/video-view/video-view.cpp
${public_api_src_dir}/controls/camera-view/camera-view.cpp
${public_api_src_dir}/image-loader/image.cpp
+ ${public_api_src_dir}/image-loader/image-url.cpp
${public_api_src_dir}/image-loader/async-image-loader.cpp
${public_api_src_dir}/image-loader/sync-image-loader.cpp
${public_api_src_dir}/styling/style-manager.cpp
SET( public_api_image_loader_header_files
${public_api_src_dir}/image-loader/image.h
+ ${public_api_src_dir}/image-loader/image-url.h
${public_api_src_dir}/image-loader/async-image-loader.h
${public_api_src_dir}/image-loader/sync-image-loader.h
)
--- /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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/image-loader/image-url.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/image-loader/image-url-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+ImageUrl::ImageUrl()
+{
+}
+
+ImageUrl::~ImageUrl()
+{
+}
+
+ImageUrl ImageUrl::New(Texture& texture)
+{
+ Toolkit::Internal::ImageUrlPtr internal = Toolkit::Internal::ImageUrl::New(texture);
+ return ImageUrl(internal.Get());
+}
+
+ImageUrl ImageUrl::DownCast(BaseHandle handle)
+{
+ return ImageUrl(dynamic_cast<Toolkit::Internal::ImageUrl*>(handle.GetObjectPtr()));
+}
+
+ImageUrl::ImageUrl(const ImageUrl& rhs) = default;
+
+ImageUrl& ImageUrl::operator=(const ImageUrl& url) = default;
+
+ImageUrl::ImageUrl(ImageUrl&& rhs) = default;
+
+ImageUrl& ImageUrl::operator=(ImageUrl&& rhs) = default;
+
+const std::string& ImageUrl::GetUrl() const
+{
+ return GetImpl(*this).GetUrl();
+}
+
+ImageUrl::ImageUrl(Toolkit::Internal::ImageUrl* internal)
+: BaseHandle(internal)
+{
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_IMAGE_URL_H
+#define DALI_TOOLKIT_IMAGE_URL_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 <string>
+#include <dali/public-api/rendering/texture.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal DALI_INTERNAL
+{
+class ImageUrl;
+}
+/**
+ * @brief ImageUrl can be used to wrap an external buffer.
+ *
+ * An instance of ImageUrl can be created from Image::GenerateUrl().
+ * Application can get url from ImageUrl.
+ * When application does not use this anymore, the destructor of the ImageUrl is called.
+ * At this time, the buffer is deleted from the texture manager.
+ */
+class DALI_TOOLKIT_API ImageUrl : public BaseHandle
+{
+public:
+ /**
+ * Default Constructor.
+ * Resulting URL is not valid
+ */
+ ImageUrl();
+
+ /**
+ * Destructor
+ */
+ ~ImageUrl();
+
+ /**
+ * @brief Create an initialized ImageUrl.
+ *
+ * @param[in] texture The texture url is got from external buffer.
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static ImageUrl New(Texture& texture);
+
+ /**
+ * @brief Downcast an Object handle to ImageUrl handle.
+ *
+ * If handle points to a ImageUrl object the downcast produces valid
+ * handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle to An object.
+ * @return handle to a ImageUrl object or an uninitialized handle.
+ */
+ static ImageUrl DownCast(BaseHandle handle);
+
+ /**
+ * Copy constructor
+ * @param[in] url The url to copy
+ */
+ ImageUrl(const ImageUrl& url);
+
+ /**
+ * Assignment operator
+ * @param[in] url The url to copy
+ */
+ ImageUrl& operator=(const ImageUrl& url);
+
+ /**
+ * @brief Move constructor.
+ * @param[in] rhs A reference to the moved handle
+ */
+ ImageUrl(ImageUrl&& rhs);
+
+ /**
+ * @brief Move assignment operator.
+ * @param[in] rhs A reference to the moved handle
+ * @return A reference to this handle
+ */
+ ImageUrl& operator=(ImageUrl&& rhs);
+
+ /**
+ * Get the url
+ * @return Returns url's string
+ */
+ const std::string& GetUrl() const;
+
+public: // Not intended for application developers
+ /// @cond internal
+ /**
+ * @brief This constructor is used by New() methods.
+ *
+ * @param[in] internal A pointer to a newly allocated Dali resource.
+ */
+ explicit DALI_INTERNAL ImageUrl(Toolkit::Internal::ImageUrl* internal);
+ /// @endcond
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* DALI_TOOLKIT_IMAGE_URL_H */
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
// EXTERNAL INCLUDES
#include <dali/devel-api/rendering/frame-buffer-devel.h>
{
namespace Image
{
-std::string GenerateUrl(Dali::FrameBuffer frameBuffer, Pixel::Format pixelFormat, uint32_t width, uint32_t height)
+Dali::Toolkit::ImageUrl GenerateUrl(Dali::FrameBuffer frameBuffer, Pixel::Format pixelFormat, uint32_t width, uint32_t height)
{
Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D, pixelFormat, width, height);
frameBuffer.AttachColorTexture(texture, 0u, 0u);
- return Dali::Toolkit::TextureManager::AddTexture(texture);
+ Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(texture);
+ return imageUrl;
}
-std::string GenerateUrl(const Dali::FrameBuffer frameBuffer, uint8_t index)
+Dali::Toolkit::ImageUrl GenerateUrl(const Dali::FrameBuffer frameBuffer, uint8_t index)
{
Texture texture = Dali::DevelFrameBuffer::GetColorTexture(frameBuffer, index);
- return Dali::Toolkit::TextureManager::AddTexture(texture);
+ Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(texture);
+ return imageUrl;
}
-std::string GenerateUrl(const Dali::PixelData pixelData)
+Dali::Toolkit::ImageUrl GenerateUrl(const Dali::PixelData pixelData)
{
Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight());
texture.Upload(pixelData);
- return Dali::Toolkit::TextureManager::AddTexture(texture);
+ Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(texture);
+ return imageUrl;
}
-std::string GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource)
+Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource)
{
Texture texture = Dali::Texture::New(*nativeImageSource);
- return Dali::Toolkit::TextureManager::AddTexture(texture);
+ Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(texture);
+ return imageUrl;
}
} // namespace Image
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/dali-toolkit-common.h>
+#include <dali-toolkit/public-api/image-loader/image-url.h>
namespace Dali
{
* @param[in] pixelFormat the pixel format for this frame buffer
* @param[in] width the width for this frame buffer
* @param[in] height the height for this frame buffer
- * @return the Url string representing this frame buffer
+ * @return the ImageUrl representing this frame buffer
*/
-DALI_TOOLKIT_API std::string GenerateUrl(const Dali::FrameBuffer frameBuffer, Pixel::Format pixelFormat, uint32_t width, uint32_t height);
+DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::FrameBuffer frameBuffer, Pixel::Format pixelFormat, uint32_t width, uint32_t height);
/**
* @brief Generate a Url from frame buffer.
* This method does not check for duplicates, If same frame buffer is entered multiple times, a different URL is returned each time.
* @param[in] frameBuffer the frame buffer to converted to Url
* @param[in] index the index of the attached color texture.
- * @return the Url string representing this frame buffer
+ * @return the ImageUrl representing this frame buffer
*/
-DALI_TOOLKIT_API std::string GenerateUrl(const Dali::FrameBuffer frameBuffer, uint8_t index);
+DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::FrameBuffer frameBuffer, uint8_t index);
/**
* @brief Generate a Url from Pixel data.
* This Url can be used in visuals to render the pixel data.
* @note This method does not check for duplicates, If same pixel data is entered multiple times, a different URL is returned each time.
* @param[in] pixelData the pixel data to converted to Url
- * @return the Url string representing this pixel data
+ * @return the ImageUrl representing this pixel data
*/
-DALI_TOOLKIT_API std::string GenerateUrl(const Dali::PixelData pixelData);
+DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::PixelData pixelData);
/**
* @brief Generate a Url from native image source.
* This Url can be used in visuals to render the native image source.
* @note This method does not check for duplicates, If same native image source is entered multiple times, a different URL is returned each time.
* @param[in] nativeImageSource the native image source to converted to Url
- * @return the Url string representing this native image source
+ * @return the ImageUrl representing this native image source
*/
-DALI_TOOLKIT_API std::string GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource);
+DALI_TOOLKIT_API Dali::Toolkit::ImageUrl GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource);
} // namespace Image
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.0.35
+Version: 2.0.36
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT