../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
- ../dali-toolkit/dali-toolkit-test-utils/test-render-surface.cpp
../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
dali-toolkit-test-utils/toolkit-text-utils.cpp
../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
- ../dali-toolkit/dali-toolkit-test-utils/test-render-surface.cpp
../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
)
../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
- ../dali-toolkit/dali-toolkit-test-utils/test-render-surface.cpp
../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
)
dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
dali-toolkit-test-utils/test-platform-abstraction.cpp
dali-toolkit-test-utils/test-render-controller.cpp
- dali-toolkit-test-utils/test-render-surface.cpp
dali-toolkit-test-utils/test-trace-call-stack.cpp
dali-toolkit-test-utils/test-native-image.cpp
)
uint32_t horizontalDpi,
uint32_t verticalDpi,
bool initialize )
-: mRenderSurface( NULL ),
- mCore( NULL ),
+: mCore( NULL ),
mSurfaceWidth( surfaceWidth ),
mSurfaceHeight( surfaceHeight ),
mFrame( 0u ),
void TestApplication::CreateScene()
{
- mRenderSurface = new TestRenderSurface( Dali::PositionSize( 0, 0, mSurfaceWidth, mSurfaceHeight ) );
- mScene = Dali::Integration::Scene::New( *mRenderSurface );
+ mScene = Dali::Integration::Scene::New( Size( static_cast<float>( mSurfaceWidth ), static_cast<float>( mSurfaceHeight ) ) );
mScene.SetDpi( Vector2( static_cast<float>( mDpi.x ), static_cast<float>( mDpi.y ) ) );
}
TestApplication::~TestApplication()
{
Dali::Integration::Log::UninstallLogFunction();
- delete mRenderSurface;
delete mCore;
}
bool TestApplication::Render( uint32_t intervalMilliseconds, const char* location )
{
DoUpdate( intervalMilliseconds, location );
- mCore->Render( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
+
+ mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
+ mCore->RenderScene( mScene, true /*render the off-screen buffers*/);
+ mCore->RenderScene( mScene, false /*render the surface*/);
+ mCore->PostRender( false /*do not skip rendering*/ );
mFrame++;
bool TestApplication::RenderOnly( )
{
// Update Time values
- mCore->Render( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
+ mCore->PreRender( mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/ );
+ mCore->RenderScene( mScene, true /*render the off-screen buffers*/);
+ mCore->RenderScene( mScene, false /*render the surface*/);
+ mCore->PostRender( false /*do not skip rendering*/ );
mFrame++;
#include "test-gl-abstraction.h"
#include "test-gl-context-helper-abstraction.h"
#include "test-render-controller.h"
-#include "test-render-surface.h"
#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/resource-policies.h>
#include <dali/integration-api/trace.h>
TestGlAbstraction mGlAbstraction;
TestGlSyncAbstraction mGlSyncAbstraction;
TestGlContextHelperAbstraction mGlContextHelperAbstraction;
- TestRenderSurface* mRenderSurface;
Integration::UpdateStatus mStatus;
Integration::RenderStatus mRenderStatus;
#define TEST_GL_CONTEXT_HELPER_ABSTRACTION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
virtual void MakeSurfacelessContextCurrent() {};
/**
- * @brief Switch to the GL context of the specific render surface
- * @param[in] surface The render surface
- */
- virtual void MakeContextCurrent( Integration::RenderSurface* surface ) {};
-
- /**
* @brief Clear the GL context
*/
virtual void MakeContextNull() {};
+++ /dev/null
-/*
- * Copyright (c) 2019 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 "test-render-surface.h"
-
-namespace Dali
-{
-
-TestRenderSurface::TestRenderSurface( Dali::PositionSize positionSize )
-: mPositionSize( positionSize ),
- mBackgroundColor()
-{
-}
-
-TestRenderSurface::~TestRenderSurface()
-{
-}
-
-Dali::PositionSize TestRenderSurface::GetPositionSize() const
-{
- return mPositionSize;
-};
-
-void TestRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
-{
- dpiHorizontal = dpiVertical = 96;
-};
-
-void TestRenderSurface::InitializeGraphics()
-{
-}
-
-void TestRenderSurface::CreateSurface()
-{
-}
-
-void TestRenderSurface::DestroySurface()
-{
-}
-
-bool TestRenderSurface::ReplaceGraphicsSurface()
-{
- return false;
-}
-
-void TestRenderSurface::MoveResize( Dali::PositionSize positionSize )
-{
- mPositionSize = positionSize;
-}
-
-void TestRenderSurface::StartRender()
-{
-}
-
-bool TestRenderSurface::PreRender( bool resizingSurface )
-{
- return true;
-}
-
-void TestRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
-{
-}
-
-void TestRenderSurface::StopRender()
-{
-}
-
-void TestRenderSurface::ReleaseLock()
-{
-}
-
-Dali::Integration::RenderSurface::Type TestRenderSurface::GetSurfaceType()
-{
- return WINDOW_RENDER_SURFACE;
-}
-
-void TestRenderSurface::MakeContextCurrent()
-{
-}
-
-Integration::DepthBufferAvailable TestRenderSurface::GetDepthBufferRequired()
-{
- return Integration::DepthBufferAvailable::TRUE;
-}
-
-Integration::StencilBufferAvailable TestRenderSurface::GetStencilBufferRequired()
-{
- return Integration::StencilBufferAvailable::TRUE;
-}
-
-void TestRenderSurface::SetBackgroundColor( Vector4 color )
-{
- mBackgroundColor = color;
-}
-
-Vector4 TestRenderSurface::GetBackgroundColor()
-{
- return mBackgroundColor;
-}
-
-} // Namespace dali
+++ /dev/null
-#ifndef TEST_REENDER_SURFACE_H
-#define TEST_REENDER_SURFACE_H
-
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/integration-api/render-surface.h>
-
-namespace Dali
-{
-
-/**
- * Concrete implementation of the RenderSurface class.
- */
-class DALI_CORE_API TestRenderSurface : public Dali::Integration::RenderSurface
-{
-public:
-
- /**
- * @copydoc Dali::Integration::RenderSurface::RenderSurface
- */
- TestRenderSurface( Dali::PositionSize positionSize );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::~RenderSurface
- */
- virtual ~TestRenderSurface();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetPositionSize
- */
- virtual Dali::PositionSize GetPositionSize() const;
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetDpi
- */
- virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::InitializeGraphics
- */
- virtual void InitializeGraphics();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::CreateSurface
- */
- virtual void CreateSurface();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::DestroySurface
- */
- virtual void DestroySurface();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface
- */
- virtual bool ReplaceGraphicsSurface();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::MoveResize
- */
- virtual void MoveResize( Dali::PositionSize positionSize );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::StartRender
- */
- virtual void StartRender();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::PreRender
- */
- virtual bool PreRender( bool resizingSurface );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::PostRender
- */
- virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::StopRender
- */
- virtual void StopRender();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::ReleaseLock
- */
- virtual void ReleaseLock();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetSurfaceType
- */
- virtual Dali::Integration::RenderSurface::Type GetSurfaceType();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent
- */
- virtual void MakeContextCurrent();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetDepthBufferRequired
- */
- virtual Integration::DepthBufferAvailable GetDepthBufferRequired();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetStencilBufferRequired
- */
- virtual Integration::StencilBufferAvailable GetStencilBufferRequired();
-
- /**
- * @copydoc Dali::Integration::RenderSurface::SetBackgroundColor
- */
- virtual void SetBackgroundColor( Vector4 color );
-
- /**
- * @copydoc Dali::Integration::RenderSurface::GetBackgroundColor
- */
- virtual Vector4 GetBackgroundColor();
-
-private:
-
- /**
- * @brief Undefined copy constructor. RenderSurface cannot be copied
- */
- TestRenderSurface( const TestRenderSurface& rhs );
-
- /**
- * @brief Undefined assignment operator. RenderSurface cannot be copied
- */
- TestRenderSurface& operator=( const TestRenderSurface& rhs );
-
-private:
-
- Dali::PositionSize mPositionSize;
- Vector4 mBackgroundColor; ///< The background color of the surface
-};
-
-} // Dali
-
-#endif
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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/integration-api/debug.h>
#include <dali/integration-api/scene.h>
#include <test-application.h>
-#include <test-render-surface.h>
namespace Dali
{
#define DALI_TOOLKIT_SCENE_HOLDER_IMPL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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 <test-render-surface.h>
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/integration-api/scene.h>
#include <dali/public-api/actors/layer.h>
namespace Dali
{
+class TestRenderSurface : public Dali::RenderSurfaceInterface
+{
+public:
+
+ TestRenderSurface( PositionSize positionSize ) {};
+
+ virtual PositionSize GetPositionSize() const { PositionSize size; return size; };
+
+ virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { dpiHorizontal = dpiVertical = 96; }
+
+ virtual void InitializeGraphics() {};
+
+ virtual void CreateSurface() {};
+
+ virtual void DestroySurface() {};
+
+ virtual bool ReplaceGraphicsSurface() { return false; };
+
+ virtual void MoveResize( Dali::PositionSize positionSize ) {};
+
+ virtual void StartRender() {};
+
+ virtual bool PreRender( bool resizingSurface ) { return false; };
+
+ virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) {};
+
+ virtual void StopRender() {};
+
+ virtual void ReleaseLock() {};
+
+ virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {};
+
+ virtual RenderSurfaceInterface::Type GetSurfaceType() { return RenderSurfaceInterface::WINDOW_RENDER_SURFACE; };
+
+ virtual void MakeContextCurrent() {};
+
+ virtual Integration::DepthBufferAvailable GetDepthBufferRequired() { return Integration::DepthBufferAvailable::FALSE; };
+
+ virtual Integration::StencilBufferAvailable GetStencilBufferRequired() { return Integration::StencilBufferAvailable::FALSE; };
+
+ virtual void SetBackgroundColor( Vector4 color ) {};
+
+ virtual Vector4 GetBackgroundColor() { return Color::WHITE; };
+};
+
namespace Internal
{
Integration::Scene GetScene();
- Integration::RenderSurface& GetRenderSurface();
+ Dali::RenderSurfaceInterface& GetRenderSurface();
private:
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
SceneHolder::SceneHolder( const Dali::Rect<int>& positionSize )
: mRenderSurface( positionSize ),
- mScene( Dali::Integration::Scene::New( mRenderSurface ) )
+ mScene( Dali::Integration::Scene::New( Dali::Size( static_cast<float>( positionSize.width ), static_cast<float>( positionSize.height ) ) ) )
{
}
return mScene;
}
-Integration::RenderSurface& SceneHolder::GetRenderSurface()
+Dali::RenderSurfaceInterface& SceneHolder::GetRenderSurface()
{
return mRenderSurface;
}
// The window will create a Scene & surface and set up the scene's surface appropriately.
*mMainWindow = Window::New( PositionSize( 0, 0, surfaceWidth, surfaceHeight ), "" );
mScene = AdaptorImpl::GetScene( *mMainWindow );
- mRenderSurface = dynamic_cast< TestRenderSurface* >( mScene.GetSurface() );
mScene.SetDpi( Vector2( horizontalDpi, verticalDpi ) );
// Core needs to be initialized next before we start the adaptor
// Need to delete core before we delete the adaptor.
delete mCore;
mCore = NULL;
-
- // Set mRenderSurface to null, it will be deleted by the window that owns it
- mRenderSurface = nullptr;
}
void ToolkitTestApplication::RunIdles()
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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/integration-api/adaptor-framework/adaptor.h>
#include <toolkit-adaptor-impl.h>
-// INTERNAL INCLUDES
-#include "test-render-surface.h"
-
using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
namespace Dali
return GetImplementation( *this ).GetScene();
}
-Integration::RenderSurface& Window::GetRenderSurface()
+Dali::RenderSurfaceInterface& Window::GetRenderSurface()
{
return GetImplementation( *this ).GetRenderSurface();
}
#define TOOLKIT_WINDOW_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
class Actor;
class Layer;
+class RenderSurfaceInterface;
struct KeyEvent;
class TouchData;
struct WheelEvent;
Window& operator=(const Window& rhs);
Integration::Scene GetScene();
- Integration::RenderSurface& GetRenderSurface();
+ Dali::RenderSurfaceInterface& GetRenderSurface();
void Add( Dali::Actor actor );
void Remove( Dali::Actor actor );
Dali::Layer GetRootLayer() const;
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
}
+int UtcDaliAnimatedImageVisualJumpToAction(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Property::Array urls;
+ CopyUrlsIntoArray( urls );
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
+ propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
+ propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 12);
+ propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ Stage::GetCurrent().Add( dummyControl );
+ application.SendNotification();
+ application.Render(20);
+
+ tet_infoline( "Ready the visual after the visual is on stage" );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
+
+ tet_infoline( "Test that a timer has been started" );
+ DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
+
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
+
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
+
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 20 );
+
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
+
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 6 );
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 6 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliAnimatedImageVisualStopBehavior(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ Property::Array urls;
+ CopyUrlsIntoArray( urls );
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, Property::Value(urls) );
+ propertyMap.Insert( DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME);
+ propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 4);
+ propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 8);
+ propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ // Expect that a batch of 4 textures has been requested. These will be serially loaded
+ // below.
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ Stage::GetCurrent().Add( dummyControl );
+ application.SendNotification();
+ application.Render(20);
+
+ tet_infoline( "Ready the visual after the visual is on stage" );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
+
+ tet_infoline( "Test that a timer has been started" );
+ DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
+
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, Property::Map() );
+
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
+
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::JUMP_TO, 1 );
+
+ // Expect the second batch has been requested
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 4 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 4, TEST_LOCATION );
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliAnimatedImageVisualGif01(void)
+{
+ ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 4);
+ propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ // Expect that a batch of 4 textures has been requested. These will be serially loaded
+ // below.
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ Stage::GetCurrent().Add( dummyControl );
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 2, TEST_LOCATION );
+
+ tet_infoline( "Test that a timer has been started" );
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ Test::EmitGlobalTimerSignal();
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS( gl.GetLastGenTextureId(), 4, TEST_LOCATION );
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(20);
+ DALI_TEST_EQUALS( gl.GetNumGeneratedTextures(), 0, TEST_LOCATION );
+
+ END_TEST;
+}
int UtcDaliAnimatedImageVisualMultiImage01(void)
tet_infoline( "Test that a timer has been created" );
DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_INNER_LOCATION( location ) );
- for ( uint16_t i = 0; i <= loopCount; i++ )
+ for ( uint16_t i = 0; i < loopCount; i++ )
{
for ( uint16_t j = 0; j < frameCount; j++ )
{
+ if( i == 0 && j == 0 )
+ {
+ continue; // Because first frame is already showed and we call 2nd frame at the first time of timer animation.
+ }
tet_printf( "Test that after %u ticks, and we have %u frame \n", j + 1u, j + 1u );
Test::EmitGlobalTimerSignal();
application.SendNotification();
RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
+ DALI_TEST_CHECK( 2u == view.GetChildCount() );
view.Deactivate();
RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
+ DALI_TEST_CHECK( 1u == view.GetChildCount() );
+
END_TEST;
}
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE);
propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 10.0f );
+ propertyMap.Insert( DevelColorVisual::Property::BLUR_RADIUS, 20.0f );
Visual::Base colorVisual = factory.CreateVisual( propertyMap );
Property::Map resultMap;
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
- Property::Value* radiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
- DALI_TEST_CHECK( radiusValue );
- DALI_TEST_CHECK( radiusValue->Get< float >() == 10.0f );
+ Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( cornerRadiusValue );
+ DALI_TEST_CHECK( cornerRadiusValue->Get< float >() == 10.0f );
+
+ Property::Value* blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( blurRadiusValue );
+ DALI_TEST_CHECK( blurRadiusValue->Get< float >() == 20.0f );
// change the blend color
propertyMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
+ // Test wrong values
+ propertyMap[DevelColorVisual::Property::BLUR_RADIUS] = "3.0f";
+
+ colorVisual = factory.CreateVisual( propertyMap );
+ colorVisual.CreatePropertyMap( resultMap );
+
+ blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( blurRadiusValue );
+ DALI_TEST_CHECK( blurRadiusValue->Get< float >() == 0.0f );
+
END_TEST;
}
END_TEST;
}
+
+int UtcDaliColorVisualBlurRadius(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliColorVisualBlurRadius" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ float blurRadius = 20.0f;
+
+ properties[Visual::Property::TYPE] = Visual::COLOR;
+ properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+ properties["blurRadius"] = blurRadius;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummy.SetSize( 200.f, 200.f );
+ dummy.SetParentOrigin( ParentOrigin::CENTER );
+ Stage::GetCurrent().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "blurRadius", blurRadius ), true, TEST_LOCATION );
+
+ END_TEST;
+}
int UtcDaliVisualFactoryGetNPatchVisual3(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request n-patch visual with a Property::Map" );
VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( factory );
END_TEST;
}
+int UtcDaliVisualFactoryGetNPatchVisual7(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual7: Add 9-patch visual on stage and instantly remove it." );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize( TEST_9_PATCH_FILE_NAME );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, false );
+ {
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ Vector2 naturalSize( 0.0f, 0.0f );
+ visual.GetNaturalSize( naturalSize );
+ DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth(), imageSize.GetHeight() ), TEST_LOCATION );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger(1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
int UtcDaliNPatchVisualAuxiliaryImage(void)
{
ToolkitTestApplication application;
#define DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_IMAGE_VISUAL_ACTIONS_DEVEL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
{
PLAY, ///< Play the animated GIF. This is also Default playback mode.
PAUSE, ///< Pause the animated GIF.
- STOP ///< Stop the animated GIF.
+ STOP, ///< Stop the animated GIF.
+ JUMP_TO ///< Jump to the specified frame. Property::INTEGER value should be passed.
};
} // namespace Action
#define DALI_TOOLKIT_COLOR_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
* @note By default it's false, i.e. ColorVisual will not render if the MIX_COLOR is transparent.
*/
RENDER_IF_TRANSPARENT = MIX_COLOR + 1,
+
+ /**
+ * @brief The blur radius of the visual.
+ * @details Name "blurRadius", type Property::FLOAT.
+ * If the value is 0, the edge is sharp. Otherwise, the larger the value, the more the edge is blurred.
+ * @note Optional.
+ * @note The default is 0.
+ * @note The visual size increases by the blur radius.
+ */
+ BLUR_RADIUS = MIX_COLOR + 2,
};
} // namespace Property
#define DALI_TOOLKIT_DEVEL_API_VISUALS_IMAGE_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
TOTAL_FRAME_NUMBER = ORIENTATION_CORRECTION + 7,
/**
- * @brief The stop behavior the AnimatedVectorImageVisual will use.
+ * @brief The stop behavior the AnimatedImageVisual and AnimatedVectorImageVisual will use.
* @details Name "stopBehavior", Type StopBehavior::Type (Property::INTEGER)
* @note Default value is StopBehavior::CURRENT_FRAME.
*/
#define DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
/**
* @brief The radius for the rounded corners of the visual
- * @details Name "cornerRadius", type Property::FLOAT or Property::VECTOR4.
+ * @details Name "cornerRadius", type Property::FLOAT.
* @note Optional.
*/
CORNER_RADIUS = OPACITY + 2,
//////////////////////////////////////////////////////
// Connect to actor tree
Self().Add( mChildrenRoot );
- Self().Add( mInternalRoot );
mInternalRoot.Add( mHorizBlurActor );
mInternalRoot.Add( mVertBlurActor );
mInternalRoot.Add( mRenderDownsampledCamera );
void GaussianBlurView::Activate()
{
// make sure resources are allocated and start the render tasks processing
+ Self().Add( mInternalRoot );
AllocateResources();
CreateRenderTasks();
mActivated = true;
{
// stop render tasks processing
// Note: render target resources are automatically freed since we set the Image::Unused flag
+ mInternalRoot.Unparent();
RemoveRenderTasks();
mRenderTargetForRenderingChildren.Reset();
mRenderTarget1.Reset();
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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
{
+// stop behavior
+DALI_ENUM_TO_STRING_TABLE_BEGIN( STOP_BEHAVIOR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, CURRENT_FRAME )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, FIRST_FRAME )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::DevelImageVisual::StopBehavior, LAST_FRAME )
+DALI_ENUM_TO_STRING_TABLE_END( STOP_BEHAVIOR )
+
// wrap modes
DALI_ENUM_TO_STRING_TABLE_BEGIN( WRAP_MODE )
DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, DEFAULT )
mWrapModeU( WrapMode::DEFAULT ),
mWrapModeV( WrapMode::DEFAULT ),
mActionStatus( DevelAnimatedImageVisual::Action::PLAY ),
- mStartFirstFrame(false)
+ mStopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ),
+ mStartFirstFrame(false),
+ mIsJumpTo( false )
{}
AnimatedImageVisual::~AnimatedImageVisual()
map.Insert( Toolkit::ImageVisual::Property::CACHE_SIZE, static_cast<int>(mCacheSize) );
map.Insert( Toolkit::ImageVisual::Property::FRAME_DELAY, static_cast<int>(mFrameDelay) );
map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, static_cast<int>(mLoopCount) );
+
+ map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
}
void AnimatedImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
{
// STOP reset functionality will actually be done in a future change
// Stop will be executed on next timer tick
- mCurrentFrameIndex = 0;
mActionStatus = DevelAnimatedImageVisual::Action::STOP;
+ if( IsOnStage() )
+ {
+ DisplayNextFrame();
+ }
+ break;
+ }
+ case DevelAnimatedImageVisual::Action::JUMP_TO:
+ {
+ int32_t frameNumber;
+ if( attributes.Get( frameNumber ) )
+ {
+ if( frameNumber < 0 || frameNumber >= static_cast<int32_t>( mFrameCount ) )
+ {
+ DALI_LOG_ERROR( "Invalid frame index used.\n" );
+ }
+ else
+ {
+ mIsJumpTo = true;
+ mCurrentFrameIndex = frameNumber;
+ if( IsOnStage() )
+ {
+ DisplayNextFrame();
+ }
+ }
+ }
break;
}
}
{
DoSetProperty( Toolkit::DevelImageVisual::Property::LOOP_COUNT, keyValue.second );
}
+ else if( keyValue.first == STOP_BEHAVIOR_NAME )
+ {
+ DoSetProperty( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, keyValue.second );
+ }
}
}
}
}
break;
}
+
+ case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
+ {
+ int32_t stopBehavior = mStopBehavior;
+ if( Scripting::GetEnumerationProperty( value, STOP_BEHAVIOR_TABLE, STOP_BEHAVIOR_TABLE_COUNT, stopBehavior ) )
+ {
+ mStopBehavior = DevelImageVisual::StopBehavior::Type( stopBehavior );
+ }
+ break;
+ }
}
}
if (!mImageCache)
{
- DALI_LOG_ERROR("mImageCache is null");
+ DALI_LOG_ERROR("mImageCache is null\n");
}
}
bool AnimatedImageVisual::DisplayNextFrame()
{
- if( mActionStatus == DevelAnimatedImageVisual::Action::STOP || mActionStatus == DevelAnimatedImageVisual::Action::PAUSE )
+ if( mIsJumpTo )
+ {
+ mIsJumpTo = false;
+ }
+ else if( mActionStatus == DevelAnimatedImageVisual::Action::PAUSE )
{
return false;
}
- if( mFrameCount > 1 )
+ else if( mActionStatus == DevelAnimatedImageVisual::Action::STOP )
{
- // Wrap the frame index
- ++mCurrentFrameIndex;
-
- if( mLoopCount < 0 || mCurrentLoopIndex <= mLoopCount)
+ mCurrentLoopIndex = 0;
+ if( mStopBehavior == DevelImageVisual::StopBehavior::FIRST_FRAME )
{
- mCurrentFrameIndex %= mFrameCount;
- if( mCurrentFrameIndex == 0 )
- {
- ++mCurrentLoopIndex;
- }
+ mCurrentFrameIndex = 0;
+ }
+ else if( mStopBehavior == DevelImageVisual::StopBehavior::LAST_FRAME )
+ {
+ mCurrentFrameIndex = mFrameCount - 1;
}
else
{
- // This will stop timer
- return false;
+ return false; // Do not draw already rendered scene twice.
}
}
- DALI_LOG_INFO( gAnimImgLogFilter,Debug::Concise,"AnimatedImageVisual::DisplayNextFrame(this:%p) FrameCount:%d\n", this, mCurrentFrameIndex);
-
- if( mFrameDelayContainer.Count() > 0 )
+ else
{
- unsigned int delay = mFrameDelayContainer[mCurrentFrameIndex];
+ if( mFrameCount > 1 )
+ {
+ // Wrap the frame index
+ bool finished = false;
+ ++mCurrentFrameIndex;
+ if( mCurrentFrameIndex >= mFrameCount )
+ {
+ ++mCurrentLoopIndex;
+ finished = true;
+ }
- if( mFrameDelayTimer.GetInterval() != delay )
+ if( mLoopCount < 0 || mCurrentLoopIndex < mLoopCount)
+ {
+ if( finished )
+ {
+ mCurrentFrameIndex = 0; // Back to the first frame
+ }
+ }
+ else
+ {
+ // This will stop timer
+ mActionStatus = DevelAnimatedImageVisual::Action::STOP;
+ return DisplayNextFrame();
+ }
+ }
+
+ if( mFrameDelayContainer.Count() > 0 )
{
- mFrameDelayTimer.SetInterval( delay );
+ unsigned int delay = mFrameDelayContainer[mCurrentFrameIndex];
+
+ if( mFrameDelayTimer.GetInterval() != delay )
+ {
+ mFrameDelayTimer.SetInterval( delay );
+ }
}
}
+ DALI_LOG_INFO( gAnimImgLogFilter,Debug::Concise,"AnimatedImageVisual::DisplayNextFrame(this:%p) CurrentFrameIndex:%d\n", this, mCurrentFrameIndex);
+
TextureSet textureSet;
if( mImageCache )
{
- textureSet = mImageCache->NextFrame();
+ textureSet = mImageCache->Frame( mCurrentFrameIndex );
if( textureSet )
{
SetImageSize( textureSet );
}
}
- // Keep timer ticking
- return true;
+ return ( mActionStatus == DevelAnimatedImageVisual::Action::PLAY ) ? true : false;
}
#define DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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::WrapMode::Type mWrapModeU:3;
Dali::WrapMode::Type mWrapModeV:3;
DevelAnimatedImageVisual::Action::Type mActionStatus:3;
+ DevelImageVisual::StopBehavior::Type mStopBehavior:2;
bool mStartFirstFrame:1;
+ bool mIsJumpTo:1;
};
} // namespace Internal
}
}
+TextureSet FixedImageCache::Frame( uint32_t frameIndex )
+{
+ while( frameIndex > mFront )
+ {
+ NextFrame();
+ }
+ mFront = frameIndex;
+
+ TextureSet textureSet;
+ if( IsFrontReady() == true )
+ {
+ textureSet = GetFrontTextureSet();
+ }
+ else
+ {
+ mWaitingForReadyFrame = true;
+ }
+
+ return textureSet;
+}
+
TextureSet FixedImageCache::FirstFrame()
{
TextureSet textureSet = GetFrontTextureSet();
{
mWaitingForReadyFrame = true;
}
-
LoadBatch();
return textureSet;
// Try and load up to mBatchSize images, until the cache is filled.
// Once the cache is filled, mUrlIndex exceeds mImageUrls size and
// no more images are loaded.
- bool frontFrameReady = IsFrontReady();;
+ bool frontFrameReady = IsFrontReady();
for( unsigned int i=0; i< mBatchSize && mUrlIndex < mImageUrls.size(); ++i )
{
virtual ~FixedImageCache();
/**
+ * Get the Nth frame. If it's not ready, this will trigger the
+ * sending of FrameReady() when the image becomes ready.
+ */
+ TextureSet Frame( uint32_t frameIndex ) override;
+
+ /**
* Get the first frame. If it's not ready, this will trigger the
* sending of FrameReady() when the image becomes ready.
*/
#define DALI_TOOLKIT_INTERNAL_IMAGE_CACHE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
struct UrlStore
{
- TextureManager::TextureId mTextureId;
+ TextureManager::TextureId mTextureId = TextureManager::INVALID_TEXTURE_ID;
std::string mUrl;
};
*/
virtual TextureSet NextFrame() = 0;
+ /**
+ * Get the Nth frame. If it's not ready, this will trigger the
+ * sending of FrameReady() when the image becomes ready.
+ */
+ virtual TextureSet Frame( uint32_t frameIndex ) = 0;
+
private:
/**
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
}
}
+TextureSet RollingGifImageCache::Frame( uint32_t frameIndex )
+{
+ // If a frame of frameIndex is not loaded, clear the queue and remove all loaded textures.
+ if( mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID )
+ {
+ mFrameIndex = frameIndex;
+ while( !mQueue.IsEmpty() )
+ {
+ ImageFrame imageFrame = mQueue.PopFront();
+ Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
+ mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ }
+ LoadBatch();
+ }
+ // If the frame is already loaded, remove previous frames of the frame in the queue
+ // and load new frames amount of removed frames.
+ else
+ {
+ bool popExist = false;
+ while( !mQueue.IsEmpty() && mQueue.Front().mFrameNumber != frameIndex )
+ {
+ ImageFrame imageFrame = mQueue.PopFront();
+ Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
+ mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ popExist = true;
+ }
+ if( popExist )
+ {
+ mFrameIndex = ( mQueue.Back().mFrameNumber + 1 ) % mFrameCount;
+ LoadBatch();
+ }
+ }
+
+ return GetFrontTextureSet();
+}
TextureSet RollingGifImageCache::FirstFrame()
{
- return GetFrontTextureSet();
+ return Frame( 0u );
}
TextureSet RollingGifImageCache::NextFrame()
{
- TextureSet textureSet;
-
ImageFrame imageFrame = mQueue.PopFront();
Dali::Toolkit::TextureManager::RemoveTexture( mImageUrls[ imageFrame.mFrameNumber ].mUrl );
mImageUrls[ imageFrame.mFrameNumber ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
int batchSize = std::min( std::size_t(mBatchSize), mCacheSize - mQueue.Count() );
DALI_LOG_INFO( gAnimImgLogFilter, Debug::Concise, "RollingGifImageCache::LoadBatch() mFrameIndex:%d batchSize:%d\n", mFrameIndex, batchSize );
- if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) )
+ if( mGifLoading.LoadNextNFrames( mFrameIndex, batchSize, pixelDataList) )
{
unsigned int pixelDataListCount = pixelDataList.size();
#define DALI_TOOLKIT_INTERNAL_ROLLING_GIF_IMAGE_CACHE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
virtual ~RollingGifImageCache();
/**
+ * Get the Nth frame. If it's not ready, this will trigger the
+ * sending of FrameReady() when the image becomes ready.
+ */
+ TextureSet Frame( uint32_t frameIndex ) override;
+
+ /**
* Get the first frame. If it's not ready, this will trigger the
* sending of FrameReady() when the image becomes ready.
*/
}
}
-TextureSet RollingImageCache::FirstFrame()
+TextureSet RollingImageCache::Frame( uint32_t frameIndex )
{
- TextureSet textureSet = GetFrontTextureSet();
+ // If a frame of frameIndex is not loaded, clear the queue and remove all loaded textures.
+ if( mImageUrls[ frameIndex ].mTextureId == TextureManager::INVALID_TEXTURE_ID )
+ {
+ mUrlIndex = frameIndex;
+ while( !mQueue.IsEmpty() )
+ {
+ ImageFrame imageFrame = mQueue.PopFront();
+ mTextureManager.Remove( mImageUrls[ imageFrame.mUrlIndex ].mTextureId, this );
+ mImageUrls[ imageFrame.mUrlIndex ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ }
+ LoadBatch();
+ }
+ // If the frame is already loaded, remove previous frames of the frame in the queue
+ // and load new frames amount of removed frames.
+ else
+ {
+ bool popExist = false;
+ while( !mQueue.IsEmpty() && mQueue.Front().mUrlIndex != frameIndex )
+ {
+ ImageFrame imageFrame = mQueue.PopFront();
+ mTextureManager.Remove( mImageUrls[ imageFrame.mUrlIndex ].mTextureId, this );
+ mImageUrls[ imageFrame.mUrlIndex ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ popExist = true;
+ }
+ if( popExist )
+ {
+ mUrlIndex = ( mQueue.Back().mUrlIndex + 1 ) % mImageUrls.size();
+ LoadBatch();
+ }
+ }
- if( ! textureSet )
+ TextureSet textureSet;
+ if( IsFrontReady() == true )
+ {
+ textureSet = GetFrontTextureSet();
+ }
+ else
{
mWaitingForReadyFrame = true;
}
return textureSet;
}
+TextureSet RollingImageCache::FirstFrame()
+{
+ return Frame( 0u );
+}
+
TextureSet RollingImageCache::NextFrame()
{
TextureSet textureSet;
mTextureManager.Remove( mImageUrls[ imageFrame.mUrlIndex ].mTextureId, this );
mImageUrls[ imageFrame.mUrlIndex ].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+ LoadBatch();
+
if( IsFrontReady() == true )
{
textureSet = GetFrontTextureSet();
mWaitingForReadyFrame = true;
}
- LoadBatch();
-
return textureSet;
}
// Try and load up to mBatchSize images, until the cache is filled.
// Once the cache is filled, as frames progress, the old frame is
// cleared, but not erased, and another image is loaded
- bool frontFrameReady = IsFrontReady();;
+ bool frontFrameReady = IsFrontReady();
for( unsigned int i=0; i< mBatchSize && !mQueue.IsFull(); ++i )
{
virtual ~RollingImageCache();
/**
+ * Get the Nth frame. If it's not ready, this will trigger the
+ * sending of FrameReady() when the image becomes ready.
+ */
+ TextureSet Frame( uint32_t frameIndex ) override;
+
+ /**
* Get the first frame. If it's not ready, this will trigger the
* sending of FrameReady() when the image becomes ready.
*/
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
{\n
mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - cornerRadius;\n
gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
- gl_FragColor.a *= smoothstep( 1.0, -1.0, dist );\n
+ gl_FragColor.a *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
+ }\n
+);
+
+const char* VERTEX_SHADER_BLUR_EDGE = DALI_COMPOSE_SHADER(
+ attribute mediump vec2 aPosition;\n
+ uniform highp mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ varying mediump vec2 vPosition;\n
+ varying mediump vec2 vRectSize;\n
+ \n
+ //Visual size and offset
+ uniform mediump vec2 offset;\n
+ uniform mediump vec2 size;\n
+ uniform mediump vec4 offsetSizeMode;\n
+ uniform mediump vec2 origin;\n
+ uniform mediump vec2 anchorPoint;\n
+ uniform mediump float blurRadius;\n
+ \n
+ vec4 ComputeVertexPosition()\n
+ {\n
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + blurRadius * 2.0;\n
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
+ vRectSize = visualSize / 2.0;\n
+ vPosition = aPosition* visualSize;\n
+ return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
+ }\n
+ \n
+ void main()\n
+ {\n
+ gl_Position = uMvpMatrix * ComputeVertexPosition();\n
+ }\n
+);
+
+const char* FRAGMENT_SHADER_BLUR_EDGE = DALI_COMPOSE_SHADER(
+ varying mediump vec2 vPosition;\n
+ varying mediump vec2 vRectSize;\n
+ uniform lowp vec4 uColor;\n
+ uniform lowp vec3 mixColor;\n
+ uniform mediump float blurRadius;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );\n
+ gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
+ gl_FragColor.a *= blur.x * blur.y;\n
}\n
);
ColorVisual::ColorVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache, Visual::FittingMode::FILL ),
+ mBlurRadius( 0.0f ),
mRenderIfTransparent( false )
{
}
DALI_LOG_ERROR( "ColorVisual: renderIfTransparent property has incorrect type: %d\n", renderIfTransparentValue->GetType() );
}
}
+
+ Property::Value* blurRadiusValue = propertyMap.Find( Toolkit::DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME );
+ if( blurRadiusValue )
+ {
+ if( !blurRadiusValue->Get( mBlurRadius ) )
+ {
+ DALI_LOG_ERROR( "ColorVisual:DoSetProperties:: BLUR_RADIUS property has incorrect type: %d\n", blurRadiusValue->GetType() );
+ }
+ }
}
void ColorVisual::DoSetOnStage( Actor& actor )
map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR );
map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor );
map.Insert( Toolkit::DevelColorVisual::Property::RENDER_IF_TRANSPARENT, mRenderIfTransparent );
+ map.Insert( Toolkit::DevelColorVisual::Property::BLUR_RADIUS, mBlurRadius );
}
void ColorVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
Shader shader;
- if( !IsRoundedCornerRequired() )
+ if( !EqualsZero( mBlurRadius ) )
+ {
+ shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE );
+ if( !shader )
+ {
+ shader = Shader::New( VERTEX_SHADER_BLUR_EDGE, FRAGMENT_SHADER_BLUR_EDGE );
+ mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, shader );
+ }
+ }
+ else if( !IsRoundedCornerRequired() )
{
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER );
if( !shader )
// String keys will get to this property.
mImpl->mMixColorIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::ColorVisual::Property::MIX_COLOR, MIX_COLOR, Vector3(mImpl->mMixColor) );
- if( mImpl->mMixColor.a < 1.f )
+ mImpl->mRenderer.RegisterProperty( BLUR_RADIUS_NAME, mBlurRadius );
+
+ if( mImpl->mMixColor.a < 1.f || !EqualsZero( mBlurRadius ) )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
#define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
private:
+ float mBlurRadius; ///< The blur radius
bool mRenderIfTransparent; ///< Whether we should render even if the mix-color is transparent.
};
void NPatchVisual::SetResource()
{
const NPatchLoader::Data* data;
- if( mLoader.GetNPatchData( mId, data ) )
+ if( mImpl->mRenderer && mLoader.GetNPatchData( mId, data ) )
{
Geometry geometry = CreateGeometry();
Shader shader = CreateShader();
#define DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
{
COLOR_SHADER,
COLOR_SHADER_ROUNDED_CORNER,
+ COLOR_SHADER_BLUR_EDGE,
BORDER_SHADER,
BORDER_SHADER_ANTI_ALIASING,
GRADIENT_SHADER_LINEAR_USER_SPACE,
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// Color visual
const char * const RENDER_IF_TRANSPARENT_NAME( "renderIfTransparent" );
+const char * const BLUR_RADIUS_NAME( "blurRadius" );
// Image visual
const char * const IMAGE_URL_NAME( "url" );
#define DALI_TOOLKIT_INTERNAL_VISUAL_STRING_CONSTANTS_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
// Color visual
extern const char * const RENDER_IF_TRANSPARENT_NAME;
+extern const char * const BLUR_RADIUS_NAME;
// Image visual
extern const char * const IMAGE_URL_NAME;
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 5;
-const unsigned int TOOLKIT_MICRO_VERSION = 4;
+const unsigned int TOOLKIT_MICRO_VERSION = 5;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.5.4
+Version: 1.5.5
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT