../dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-lifecycle-controller.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-physical-keyboard.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp
../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
../dali-toolkit/dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp
../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-feedback-player.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-file-loader.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-lifecycle-controller.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-native-image-source.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-physical-keyboard.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp
../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
../dali-toolkit/dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp
dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
dali-toolkit-test-utils/toolkit-environment-variable.cpp
dali-toolkit-test-utils/toolkit-input-method-context.cpp
+ dali-toolkit-test-utils/toolkit-lifecycle-controller.cpp
dali-toolkit-test-utils/toolkit-orientation.cpp
dali-toolkit-test-utils/toolkit-physical-keyboard.cpp
dali-toolkit-test-utils/toolkit-style-monitor.cpp
dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp
dali-toolkit-test-utils/toolkit-video-player.cpp
dali-toolkit-test-utils/toolkit-web-engine.cpp
+ dali-toolkit-test-utils/toolkit-window.cpp
dali-toolkit-test-utils/toolkit-trigger-event-factory.cpp
dali-toolkit-test-utils/dali-test-suite-utils.cpp
dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp
class EglInterface;
class DisplayConnection;
class ThreadSynchronizationInterface;
+class Window;
+
+using WindowContainer = std::vector<Window>;
namespace Internal
{
public:
static Dali::RenderSurfaceInterface& GetSurface();
+ static Dali::WindowContainer GetWindows();
static Dali::Adaptor::AdaptorSignalType& AdaptorSignal();
+ static Dali::Adaptor::WindowCreatedSignalType& WindowCreatedSignal();
static bool mAvailable;
static Vector<CallbackBase*> mCallbacks;
+ static Dali::WindowContainer mWindows;
+ static Dali::Adaptor::WindowCreatedSignalType* mWindowCreatedSignal;
};
} // namespace Adaptor
*
*/
-// CLASS HEADER
+#include <toolkit-window.h>
+
+// Don't want to include the actual window.h which otherwise will be indirectly included by adaptor.h.
+#define DALI_WINDOW_H
#include <dali/integration-api/adaptors/adaptor.h>
+
#include <dali/integration-api/adaptors/scene-holder.h>
#include <dali/public-api/object/base-object.h>
bool Adaptor::mAvailable = false;
Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
+Dali::WindowContainer Adaptor::mWindows;
+Dali::Adaptor::WindowCreatedSignalType* Adaptor::mWindowCreatedSignal = nullptr;
Dali::Adaptor& Adaptor::Get()
{
return *renderSurface;
}
+Dali::WindowContainer Adaptor::GetWindows()
+{
+ return Adaptor::mWindows;
+}
+
Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
{
Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
return *signal;
}
+Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
+{
+ if ( !Adaptor::mWindowCreatedSignal )
+ {
+ Adaptor::mWindowCreatedSignal = new Dali::Adaptor::WindowCreatedSignalType;
+ }
+
+ return *Adaptor::mWindowCreatedSignal;
+}
+
} // namespace Adaptor
} // namespace Internal
return Internal::Adaptor::Adaptor::AdaptorSignal();
}
+Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
+{
+ return Internal::Adaptor::Adaptor::WindowCreatedSignal();
+}
+
Dali::RenderSurfaceInterface& Adaptor::GetSurface()
{
return Internal::Adaptor::Adaptor::GetSurface();
}
+Dali::WindowContainer Adaptor::GetWindows() const
+{
+ return Internal::Adaptor::Adaptor::GetWindows();
+}
+
Any Adaptor::GetNativeWindowHandle()
{
Any window;
Adaptor::Adaptor()
: mImpl( NULL )
{
+ Dali::PositionSize win_size;
+ win_size.width = 640;
+ win_size.height = 800;
+
+ Dali::Window window = Dali::Window::New( win_size, "" );
+ Internal::Adaptor::Adaptor::mWindows.push_back( window );
}
} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2018 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 "toolkit-lifecycle-controller.h"
+
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/dali-signal.h>
+
+namespace Dali
+{
+
+/********************************************************************************
+ * Stub for Dali::Internal::Adaptor::LifecycleController
+ ********************************************************************************/
+namespace Internal
+{
+namespace Adaptor
+{
+class LifecycleController : public BaseObject
+{
+public: // Creation & Destruction
+
+ LifecycleController();
+ ~LifecycleController();
+ static Dali::LifecycleController Get();
+
+
+public: // Signals
+ Dali::LifecycleController::LifecycleSignalType& InitSignal();
+
+private:
+ Dali::LifecycleController::LifecycleSignalType mInitSignal;
+ static Dali::LifecycleController mLifecycleController;
+};
+
+Dali::LifecycleController LifecycleController::mLifecycleController;
+
+LifecycleController::LifecycleController()
+{
+}
+
+LifecycleController::~LifecycleController()
+{
+}
+
+Dali::LifecycleController LifecycleController::Get()
+{
+ if( ! mLifecycleController )
+ {
+ mLifecycleController = Dali::LifecycleController(new Internal::Adaptor::LifecycleController());
+ }
+ return mLifecycleController;
+}
+
+Dali::LifecycleController::LifecycleSignalType& LifecycleController::InitSignal()
+{
+ return mInitSignal;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+
+
+/********************************************************************************
+ * Stub for Dali::LifecycleController
+ ********************************************************************************/
+
+LifecycleController::LifecycleController(){}
+LifecycleController::~LifecycleController(){}
+
+LifecycleController LifecycleController::Get()
+{
+ // Get the physical keyboard handle
+ LifecycleController handle = Internal::Adaptor::LifecycleController::Get();
+ return handle;
+}
+
+LifecycleController::LifecycleSignalType& LifecycleController::InitSignal()
+{
+ BaseObject& object = GetBaseObject();
+ Internal::Adaptor::LifecycleController& controller = static_cast< Internal::Adaptor::LifecycleController& >( object );
+ return controller.InitSignal();
+}
+
+LifecycleController::LifecycleController( Internal::Adaptor::LifecycleController *impl )
+: BaseHandle(impl)
+{
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef TOOLKIT_LIFECYCLE_CONTROLLER_H
+#define TOOLKIT_LIFECYCLE_CONTROLLER_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class LifecycleController;
+}
+}
+
+class LifecycleController : public BaseHandle
+{
+public:
+ typedef Signal< void (void) > LifecycleSignalType;
+ LifecycleController();
+ ~LifecycleController();
+ static LifecycleController Get();
+ LifecycleSignalType& InitSignal();
+ LifecycleController( Internal::Adaptor::LifecycleController* impl );
+};
+
+
+} // namespace Dali
+
+#endif // TOOLKIT_LIFECYCLE_CONTROLLER_H
#include <dali/integration-api/adaptors/adaptor.h>
#include <toolkit-adaptor-impl.h>
#include <toolkit-singleton-service.h>
+#include <toolkit-lifecycle-controller.h>
namespace Dali
{
{
fontClient.SetDpi( mDpi.x, mDpi.y );
}
+
+ bool isAdaptorAvailable = Dali::Internal::Adaptor::Adaptor::Get().IsAvailable();
+ if ( isAdaptorAvailable )
+ {
+ Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
+ lifecycleController.InitSignal().Emit();
+
+ Dali::Window window = Dali::Internal::Adaptor::Adaptor::mWindows.front();
+ if ( window )
+ {
+ Dali::Internal::Adaptor::Adaptor::WindowCreatedSignal().Emit( window );
+ }
+ }
}
~ToolkitTestApplication()
--- /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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include "toolkit-window.h"
+
+namespace Dali
+{
+
+class Window;
+
+/********************************************************************************
+ * Stub for Dali::Internal::Adaptor::Window
+ ********************************************************************************/
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+class Window : public Dali::BaseObject
+{
+public:
+
+ Window()
+ {
+ }
+
+ virtual ~Window()
+ {
+ }
+
+ static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
+ {
+ return new Window();
+ }
+
+ static Dali::Window Get( Dali::Actor actor )
+ {
+ return Dali::Window();
+ }
+};
+
+} // Adaptor
+} // Internal
+
+Window::Window()
+{
+}
+
+Window::~Window()
+{
+}
+
+Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
+{
+ Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent );
+ return Window( window );
+}
+
+Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
+{
+ Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
+ return Window( window );
+}
+
+Dali::Layer Window::GetRootLayer() const
+{
+ return Dali::Stage::GetCurrent().GetRootLayer();
+}
+
+Window::Window( Internal::Adaptor::Window* window )
+: BaseHandle( window )
+{
+}
+
+namespace DevelWindow
+{
+
+Window Get( Actor actor )
+{
+ return Internal::Adaptor::Window::Get( actor );
+}
+
+KeyEventSignalType& KeyEventSignal( Window window )
+{
+ return Dali::Stage::GetCurrent().KeyEventSignal();
+}
+
+TouchSignalType& TouchSignal( Window window )
+{
+ return Dali::Stage::GetCurrent().TouchSignal();
+}
+
+} // namespace DevelWindow
+
+} // Dali
--- /dev/null
+#ifndef TOOLKIT_WINDOW_H
+#define TOOLKIT_WINDOW_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.
+ *
+ */
+
+//EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal.h>
+
+namespace Dali
+{
+
+class Actor;
+class Layer;
+class KeyEvent;
+class TouchData;
+
+typedef Dali::Rect<int> PositionSize;
+
+namespace Internal
+{
+namespace Adaptor
+{
+class Window;
+}
+}
+
+class Window : public BaseHandle
+{
+public:
+
+ static Window New(PositionSize windowPosition, const std::string& name, bool isTransparent = false);
+ static Window New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
+ Window();
+ ~Window();
+ Window(const Window& handle);
+ Window& operator=(const Window& rhs);
+ Layer GetRootLayer() const;
+
+public:
+ explicit Window( Internal::Adaptor::Window* window );
+};
+
+namespace DevelWindow
+{
+
+typedef Signal< void (const KeyEvent&) > KeyEventSignalType;
+typedef Signal< void (const TouchData&) > TouchSignalType;
+
+Dali::Window Get( Actor actor );
+KeyEventSignalType& KeyEventSignal( Dali::Window window );
+TouchSignalType& TouchSignal( Dali::Window window );
+
+}
+
+} // namespace Dali
+
+#endif // TOOLKIT_WINDOW_H
namespace DevelAsyncImageLoader
{
+uint32_t Load( AsyncImageLoader asyncImageLoader,
+ const std::string& url,
+ ImageDimensions dimensions,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad )
+{
+ return GetImplementation( asyncImageLoader ).Load( Toolkit::Internal::VisualUrl(url), dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
+}
+
PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader )
{
return GetImplementation( asyncImageLoader ).PixelBufferLoadedSignal();
typedef Signal< void ( uint32_t, Devel::PixelBuffer ) > PixelBufferLoadedSignalType;
/**
+ * @brief Whether to multiply alpha into color channels on load
+ */
+enum class PreMultiplyOnLoad
+{
+ OFF = 0, ///< Don't modify the image
+ ON ///< Multiply alpha into color channels on load
+};
+
+/**
+ * @brief Starts an image loading task.
+ * @REMARK_INTERNET
+ * @REMARK_STORAGE
+ * @param[in] asyncImageLoader The ayncImageLoader
+ * @param[in] url The URL of the image file to load
+ * @param[in] dimensions The width and height to fit the loaded image to
+ * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
+ * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
+ * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
+ * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha
+ * @return The loading task id
+ */
+DALI_TOOLKIT_API uint32_t Load( AsyncImageLoader asyncImageLoader,
+ const std::string& url,
+ ImageDimensions dimensions,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
+
+/**
* Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
* @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
*/
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * 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.
#include <dali/public-api/actors/layer.h>
#include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
#include <dali/devel-api/adaptor-framework/singleton-service.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/key-event.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/property-map.h>
#include <dali/public-api/images/resource-image.h>
+#include <dali/integration-api/adaptors/adaptor.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
mCustomAlgorithmInterface(NULL)
{
// TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorShown.
- Stage::GetCurrent().KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
- Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+
+ LifecycleController::Get().InitSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnAdaptorInit );
+}
+
+void KeyboardFocusManager::OnAdaptorInit()
+{
+ if( Adaptor::IsAvailable() )
+ {
+ // Retrieve all the existing widnows
+ Dali::WindowContainer windows = Adaptor::Get().GetWindows();
+ for ( auto iter = windows.begin(); iter != windows.end(); ++iter )
+ {
+ DevelWindow::KeyEventSignal( *iter ).Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
+ DevelWindow::TouchSignal( *iter ).Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch);
+ }
+
+ // Get notified when any new window is created afterwards
+ Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowCreated);
+ }
+}
+
+void KeyboardFocusManager::OnWindowCreated( Dali::Window& window )
+{
+ DevelWindow::KeyEventSignal( window ).Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
+ DevelWindow::TouchSignal( window ).Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch);
}
KeyboardFocusManager::~KeyboardFocusManager()
Toolkit::Control KeyboardFocusManager::GetParentLayoutControl(Actor actor) const
{
// Get the actor's parent layout control that supports two dimensional keyboard navigation
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
+ Actor rootActor;
Actor parent;
if(actor)
{
+ rootActor = DevelWindow::Get( actor ).GetRootLayer();
parent = actor.GetParent();
}
if( !nextFocusableActor )
{
- nextFocusableActor = Stage::GetCurrent().GetRootLayer().FindChildById( actorId );
+ nextFocusableActor = DevelWindow::Get( currentFocusActor ).GetRootLayer().FindChildById( actorId );
}
}
}
namespace Dali
{
+class Window;
+
namespace Toolkit
{
/**
* @copydoc Toolkit::KeyboardFocusManager
*/
-class KeyboardFocusManager : public Dali::BaseObject
+class KeyboardFocusManager : public Dali::BaseObject, public ConnectionTracker
{
public:
typedef FocusStack::iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
/**
+ * This will be called when the adaptor is initialized
+ */
+ void OnAdaptorInit();
+
+ /**
+ * This will be called when a new wndow is created
+ * @param window The new window
+ */
+ void OnWindowCreated( Dali::Window& window );
+
+ /**
* Get configuration from StyleManager.
*/
void GetConfigurationFromStyleManger();
ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
- bool orientationCorrection )
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
{
if( !mIsLoadThreadStarted )
{
mLoadThread.Start();
mIsLoadThreadStarted = true;
}
-
- mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection ) );
+ mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad ) );
return mLoadTaskId;
}
static IntrusivePtr<AsyncImageLoader> New();
/**
- * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions, FittingMode::Type, SamplingMode::Type, bool )
+ * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions, FittingMode::Type, SamplingMode::Type, bool , DevelAsyncImageLoader::PreMultiplyOnLoad )
*/
uint32_t Load( const VisualUrl& url,
ImageDimensions dimensions,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
- bool orientationCorrection );
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
/**
* @copydoc Toolkit::AsyncImageLoader::ImageLoadedSignal
unsigned int packPositionY = 0;
if( mPacker.Pack( dimensions.GetWidth(), dimensions.GetHeight(), packPositionX, packPositionY ) )
{
- unsigned short loadId = mAsyncLoader.Load( url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection );
+ unsigned short loadId = mAsyncLoader.Load( url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection);
mLoadingTaskInfoContainer.PushBack( new LoadingTaskInfo( loadId, packPositionX, packPositionY, dimensions.GetWidth(), dimensions.GetHeight(), atlasUploadObserver ) );
// apply the half pixel correction
textureRect.x = ( static_cast<float>( packPositionX ) +0.5f ) / mWidth; // left
{
LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
- FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
+ FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad )
: pixelBuffer(),
url( url ),
id( id ),
dimensions( dimensions ),
fittingMode( fittingMode ),
samplingMode( samplingMode ),
- orientationCorrection( orientationCorrection )
+ orientationCorrection( orientationCorrection ),
+ preMultiplyOnLoad( preMultiplyOnLoad )
{
}
{
pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
}
+
+ if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) )
+ {
+ if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON )
+ {
+ pixelBuffer.MultiplyColorByAlpha();
+ }
+ }
}
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/adaptors/log-factory-interface.h>
#include <dali-toolkit/internal/visuals/visual-url.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
namespace Dali
{
* @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
* @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
* @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+ * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha.
*/
LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
FittingMode::Type fittingMode, SamplingMode::Type samplingMode,
- bool orientationCorrection );
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
/**
* Load the image
FittingMode::Type fittingMode; ///< fitting options
SamplingMode::Type samplingMode; ///< sampling options
bool orientationCorrection:1; ///< if orientation correction is needed
-
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad; //< if the image's color should be multiplied by it's alpha
};
{
auto& loadersContainer = textureInfo.url.IsLocalResource() ? mAsyncLocalLoaders : mAsyncRemoteLoaders;
auto loadingHelperIt = loadersContainer.GetNext();
+ auto premultiplyOnLoad = textureInfo.preMultiplyOnLoad? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF;
DALI_ASSERT_ALWAYS(loadingHelperIt != loadersContainer.End());
loadingHelperIt->Load(textureInfo.textureId, textureInfo.url,
textureInfo.desiredSize, textureInfo.fittingMode,
- textureInfo.samplingMode, textureInfo.orientationCorrection );
+ textureInfo.samplingMode, textureInfo.orientationCorrection,
+ premultiplyOnLoad );
}
ObserveTexture( textureInfo, observer );
}
{
DALI_LOG_INFO( gTextureManagerLogFilter, Debug::General, " TextureManager::UploadTexture() New Texture for textureId:%d\n", textureInfo.textureId );
- // If the texture doesn't have an alpha channel, can't pre-multiply it.
- // Ensure that we don't change the load parameter (it's used for hashing), and instead set
- // the status for use in the observer.
- auto preMultiply = textureInfo.preMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD :
- TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
- PreMultiply( pixelBuffer, preMultiply );
- textureInfo.preMultiplied = (preMultiply == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD );
+ // Check if this pixelBuffer is premultiplied
+ textureInfo.preMultiplied = pixelBuffer.IsAlphaPreMultiplied();
Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(),
pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
ImageDimensions desiredSize,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
- bool orientationCorrection)
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
{
mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId));
- auto id = mLoader.Load(url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection);
+ auto id = DevelAsyncImageLoader::Load(mLoader, url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad);
mLoadingInfoContainer.back().loadId = id;
}
* @param[in] samplingMode The SamplingMode to use
* @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image,
* e.g., from portrait to landscape
+ * @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha.
*/
void Load(TextureId textureId,
const VisualUrl& url,
ImageDimensions desiredSize,
FittingMode::Type fittingMode,
SamplingMode::Type samplingMode,
- bool orientationCorrection);
+ bool orientationCorrection,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
public:
AsyncLoadingHelper(const AsyncLoadingHelper&) = delete;
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 4;
-const unsigned int TOOLKIT_MICRO_VERSION = 23;
+const unsigned int TOOLKIT_MICRO_VERSION = 24;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
uint32_t AsyncImageLoader::Load( const std::string& url )
{
- return GetImplementation( *this ).Load( Toolkit::Internal::VisualUrl(url), ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+ return GetImplementation( *this ).Load( Toolkit::Internal::VisualUrl(url), ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF );
}
uint32_t AsyncImageLoader::Load( const std::string& url, ImageDimensions dimensions )
{
- return GetImplementation( *this ).Load( Toolkit::Internal::VisualUrl(url), dimensions, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true );
+ return GetImplementation( *this ).Load( Toolkit::Internal::VisualUrl(url), dimensions, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true , DevelAsyncImageLoader::PreMultiplyOnLoad::OFF );
}
uint32_t AsyncImageLoader::Load( const std::string& url,
SamplingMode::Type samplingMode,
bool orientationCorrection )
{
- return GetImplementation(*this).Load( Toolkit::Internal::VisualUrl(url), dimensions, fittingMode, samplingMode, orientationCorrection );
+ return GetImplementation(*this).Load( Toolkit::Internal::VisualUrl(url), dimensions, fittingMode, samplingMode, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF );
}
bool AsyncImageLoader::Cancel( uint32_t loadingTaskId )
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.4.23
+Version: 1.4.24
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT